We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Getting this failure
rubocop -A app/controllers/bonuses_controller.rb Inspecting 1 file C Offenses: app/controllers/bonuses_controller.rb:45:26: C: [Corrected] Style/SelectByRegexp: Prefer grep to select with a regexp match. matching = bonuses_on_date.to_a.select { |bonus| bt =~ bonus } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ app/controllers/bonuses_controller.rb:117:24: C: [Corrected] Style/SelectByRegexp: Prefer grep to select with a regexp match. matching = bonuses_on_date.to_a.select { |bonus| bt =~ bonus } ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
the "corrected version" replace it for
index 6e0c9a9bf3..7f95ffa945 100644 --- a/app/controllers/bonuses_controller.rb +++ b/app/controllers/bonuses_controller.rb @@ -42,7 +42,7 @@ class BonusesController < ApplicationController if level_template level_template.enable_override_for employee bonuses_on_date = employee.payments.where(:kind => "bonus", :date => @period.last+1) - matching = bonuses_on_date.to_a.select { |bonus| bt =~ bonus } + matching = bonuses_on_date.to_a.grep(bonus) if matching.length == 0 if v == "yes" # create @@ -114,7 +114,7 @@ protected level_template = compensation_level.bonus_template_levels.find_by_bonus_template_id(bt.id) if level_template level_template.enable_override_for emp - matching = bonuses_on_date.to_a.select { |bonus| bt =~ bonus } + matching = bonuses_on_date.to_a.grep(bonus) if matching.length == 0 @statuses["#{emp.id}|#{bt.id}"] = "no" elsif matching.length == 1
the var should be bt not bonus
bt
bonus
wrong var is replaced in grep call
see above
1.22.1 (using Parser 3.0.2.0, rubocop-ast 1.12.0, running on ruby 2.6.8 x86_64-linux) - rubocop-rails 2.12.4
The text was updated successfully, but these errors were encountered:
Style/SelectByRegexp
Thank you for the feedback. I've opened #10218.
Sorry, something went wrong.
[Fix rubocop#10216] Fix an incorrect autocorrect for `Style/SelectByR…
fc47845
…egexp` Fix rubocop#10216. This PR fixes an incorrect autocorrect for `Style/SelectByRegexp` when using `lvar =~ blockvar` in a block.
[Fix #10216] Fix an incorrect autocorrect for Style/SelectByRegexp
6f92906
Fix #10216. This PR fixes an incorrect autocorrect for `Style/SelectByRegexp` when using `lvar =~ blockvar` in a block.
Successfully merging a pull request may close this issue.
Getting this failure
the "corrected version" replace it for
Expected behavior
the var should be
bt
notbonus
Actual behavior
wrong var is replaced in grep call
Steps to reproduce the problem
see above
RuboCop version
The text was updated successfully, but these errors were encountered: