-
-
Notifications
You must be signed in to change notification settings - Fork 279
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
There is a case where the auto-correction for Rails/RedundantActiveRecordAllMethod
failed. I apologize for the recurring oversights.
When all
has parentheses and Style/MethodCallWithoutArgsParentheses
is disabled, running rubocop results in a failed auto-correction.
User.all().order(:created_at)
Expected behavior
The code should be corrected to:
User.order(:created_at)
Actual behavior
But instead, it gets corrected to:
User.()order(:created_at)
Steps to reproduce the problem
- Run rubocop with only
Rails/RedundantActiveRecordAllMethod
enabled:
$ bundle exec rubocop --only Rails/RedundantActiveRecordAllMethod -A ./app/controllers/user_controller.rb
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Inspecting 1 file
F
Offenses:
app/controllers/user_controller.rb:3:6: C: [Corrected] Rails/RedundantActiveRecordAllMethod: Redundant all detected.
User.all().order(:created_at)
^^^
app/controllers/user_controller.rb:3:8: F: Lint/Syntax: unexpected token tIDENTIFIER
(Using Ruby 3.2 parser; configure using TargetRubyVersion parameter, under AllCops)
User.()order(:created_at)
^^^^^
1 file inspected, 2 offenses detected, 1 offense corrected
result: User.()order(:created_at)
- When
Style/MethodCallWithoutArgsParentheses
is enabled, this issue does not occur.
$ bundle exec rubocop --only Style/MethodCallWithoutArgsParentheses,Rails/RedundantActiveRecordAllMethod -A ./app/controllers/user_controller.rb
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
Inspecting 1 file
C
Offenses:
app/controllers/user_controller.rb:3:6: C: [Corrected] Rails/RedundantActiveRecordAllMethod: Redundant all detected.
User.all().order(:created_at)
^^^
app/controllers/user_controller.rb:3:9: C: [Corrected] Style/MethodCallWithoutArgsParentheses: Do not use parentheses for method calls with no arguments.
User.all().order(:created_at)
^^
1 file inspected, 2 offenses detected, 2 offenses corrected
result: User.order(:created_at)
RuboCop version
$ bundle exec rubocop -V
Calling `DidYouMean::SPELL_CHECKERS.merge!(error_name => spell_checker)' has been deprecated. Please call `DidYouMean.correct_error(error_name, spell_checker)' instead.
1.56.0 (using Parser 3.2.2.3, rubocop-ast 1.29.0, running on ruby 3.2.2) [x86_64-darwin22]
- rubocop-rails 2.21.1
- rubocop-rspec 2.23.2
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working