Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails/Exit cop not catching all uses of exit? #1274

Open
nestor-custodio opened this issue May 8, 2024 · 0 comments
Open

Rails/Exit cop not catching all uses of exit? #1274

nestor-custodio opened this issue May 8, 2024 · 0 comments

Comments

@nestor-custodio
Copy link

nestor-custodio commented May 8, 2024

Preamble: Spent an entire day tracking down a CI issue that came down to an exit in a Rails task. That seemed to me like the kind of thing 'rubocop-rails' should catch, so I popped in here to make a feature request only to realize (as I was doing my pre-issue due diligence) that there is a cop for it and it just didn't catch this for whatever reason.

The Problem: An exit in a Rails task went unreported by RuboCop. The project's RuboCop config has no exceptions for this rule, nor is the path ignored.

Offending Code:

~/dev $vars rubocop
RUBOCOP_OPTS="--format='simple' --format='offenses' --color"
# ".rubocop.yml"

require:
  -⸱rubocop-faker
  -⸱rubocop-rails

AllCops:
  TargetRubyVersion:⸱3.2
  TargetRailsVersion:⸱6.1
  NewCops:⸱enable
  SuggestExtensions:⸱false

Style/FrozenStringLiteralComment:
  # Enforces use of the frozen_string_literal comment in every file.
  Enabled: false
# "lib/tasks/weekly_update.rake"

namespace :weekly do
  desc '...'
  task update: [:environment, :logs] do
    exit unless Date.current.sunday?

    # ...
  end
end

Expected behavior

A RuboCop error from the Rails/Exit cop for file "lib/tasks/weekly_update.rake" on the exit line.

Actual behavior

~/dev $rubocop lib/tasks/weekly_update.rake

1 file inspected, no offenses detected

--
0  Total in 0 files

Steps to reproduce the problem

Offending code (and config) is provided above.

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:
You can see extension cop versions (e.g. rubocop-rails, rubocop-performance, and others) output by rubocop -V,
include them as well. Here's an example:

~/dev $bundle exec rubocop -V
1.63.4 (using Parser 3.3.1.0, rubocop-ast 1.31.3, running on ruby 3.2.2) +server [x86_64-linux]
  - rubocop-faker 1.1.0
  - rubocop-rails 2.24.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant