-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
[Fix #551] Fix a false positive for Rails/FindEach
#552
Merged
koic
merged 1 commit into
rubocop:master
from
koic:fix_a_false_positive_for_rails_find_each
Sep 25, 2021
Merged
[Fix #551] Fix a false positive for Rails/FindEach
#552
koic
merged 1 commit into
rubocop:master
from
koic:fix_a_false_positive_for_rails_find_each
Sep 25, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes rubocop#551. This PR fixes a false positive for `Rails/FindEach` when using `model.errors.where` in Rails 6.1.
This has resulted in a undefined method `send_type?' for nil:NilClass
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-rails-2.12.3/lib/rubocop/cop/rails/find_each.rb:58:in `active_model_error?'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-rails-2.12.3/lib/rubocop/cop/rails/find_each.rb:54:in `active_model_error_where?'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-rails-2.12.3/lib/rubocop/cop/rails/find_each.rb:46:in `ignored?'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-rails-2.12.3/lib/rubocop/cop/rails/find_each.rb:35:in `on_send'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:136:in `public_send'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:136:in `block (2 levels) in trigger_restricted_cops'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:160:in `with_cop_error_handling'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:135:in `block in trigger_restricted_cops'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:134:in `each'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:134:in `trigger_restricted_cops'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:70:in `on_send'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.12.0/lib/rubocop/ast/traversal.rb:158:in `on_block'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:71:in `on_block'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.12.0/lib/rubocop/ast/traversal.rb:137:in `block in on_dstr'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.12.0/lib/rubocop/ast/traversal.rb:137:in `each'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.12.0/lib/rubocop/ast/traversal.rb:137:in `on_dstr'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:71:in `on_begin'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.12.0/lib/rubocop/ast/traversal.rb:154:in `on_class'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.12.0/lib/rubocop/ast/traversal.rb:154:in `on_class'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:71:in `on_class'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.12.0/lib/rubocop/ast/traversal.rb:138:in `on_while'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:71:in `on_module'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-ast-1.12.0/lib/rubocop/ast/traversal.rb:20:in `walk'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/commissioner.rb:86:in `investigate'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/team.rb:155:in `investigate_partial'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cop/team.rb:83:in `investigate'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:309:in `inspect_file'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:253:in `block in do_inspection_loop'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:287:in `block in iterate_until_no_changes'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:280:in `loop'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:280:in `iterate_until_no_changes'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:249:in `do_inspection_loop'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:130:in `block in file_offenses'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:155:in `file_offense_cache'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:129:in `file_offenses'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:67:in `block in warm_cache'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:515:in `call_with_index'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:485:in `process_incoming_jobs'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:465:in `block in worker'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:456:in `fork'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:456:in `worker'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:447:in `block in create_workers'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:446:in `each'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:446:in `each_with_index'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:446:in `create_workers'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:386:in `work_in_processes'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:289:in `map'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/parallel-1.21.0/lib/parallel.rb:238:in `each'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:67:in `warm_cache'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/runner.rb:46:in `run'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cli/command/execute_runner.rb:26:in `block in execute_runner'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cli/command/execute_runner.rb:52:in `with_redirect'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cli/command/execute_runner.rb:25:in `execute_runner'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cli/command/execute_runner.rb:17:in `run'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cli/command.rb:11:in `run'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cli/environment.rb:18:in `run'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cli.rb:71:in `run_command'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cli.rb:78:in `execute_runners'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/lib/rubocop/cli.rb:47:in `run'
/usr/local/var/rbenv/versions/3.0.2/lib/ruby/gems/3.0.0/gems/rubocop-1.22.1/exe/rubocop:12:in `block in <top (required)>' The code in question looks like this: where(record: [record1, record2]).each(&:touch) Previously, we had been explicitly disabling |
koic
added a commit
to koic/rubocop-rails
that referenced
this pull request
Oct 7, 2021
Follow up to rubocop#552 (comment). This PR fixes an error for `Rails/FindEach` when using `where` with no receiver.
koic
added a commit
to koic/rubocop-rails
that referenced
this pull request
Oct 7, 2021
Follow up to rubocop#552 (comment). This PR fixes an error for `Rails/FindEach` when using `where` with no receiver.
koic
added a commit
to koic/rubocop-rails
that referenced
this pull request
Oct 7, 2021
Follow up to rubocop#552 (comment). This PR fixes an error for `Rails/FindEach` when using `where` with no receiver.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #551.
This PR fixes a false positive for
Rails/FindEach
when usingmodel.errors.where
in Rails 6.1.Before submitting the PR make sure the following are checked:
[Fix #issue-number]
(if the related issue exists).master
(if not - rebase it).{change_type}_{change_description}.md
if the new code introduces user-observable changes. See changelog entry format for details.and description in grammatically correct, complete sentences.
bundle exec rake default
. It executes all tests and RuboCop for itself, and generates the documentation.