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
If a class has a method blank? and that method is called with if blank? then the cop Rails/Presence throws an exception
blank?
if blank?
Rails/Presence
An error occurred while Rails/Presence cop was inspecting /Users/dominic/tmp/a.rb:5:4. undefined method `source' for nil:NilClass
I expect the Rails/Presence cop not to throw an exception when parsing syntactically correct code
The Rails/Presence cop throws an exception when parsing a reference to a locally defined blank? method
tmp/a.rb
class A def blank?; end def foo puts "bar" if blank? end end
rubocop --debug tmp/a.rb
For /Users/dominic: configuration from /Users/dominic/.rubocop.yml Default configuration from /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/config/default.yml Inheriting configuration from /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/config/enabled.yml Inheriting configuration from /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/config/disabled.yml Inspecting 1 file Scanning /Users/dominic/tmp/a.rb An error occurred while Rails/Presence cop was inspecting /Users/dominic/tmp/a.rb:5:4. undefined method `source' for nil:NilClass /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/rails/presence.rb:113:in `replacement' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/rails/presence.rb:107:in `message' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/rails/presence.rb:76:in `block in on_if' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/rails/presence.rb:45:in `redundant_receiver_and_other' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/rails/presence.rb:74:in `on_if' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/commissioner.rb:44:in `block (2 levels) in on_if' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/commissioner.rb:109:in `with_cop_error_handling' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/commissioner.rb:43:in `block in on_if' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/commissioner.rb:42:in `each' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/commissioner.rb:42:in `on_if' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/ast/traversal.rb:95:in `on_def' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/commissioner.rb:48:in `on_def' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/ast/traversal.rb:49:in `block in on_begin' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/ast/traversal.rb:49:in `each' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/ast/traversal.rb:49:in `on_begin' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/commissioner.rb:48:in `on_begin' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/ast/traversal.rb:88:in `on_class' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/commissioner.rb:48:in `on_class' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/ast/traversal.rb:12:in `walk' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/commissioner.rb:60:in `investigate' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/team.rb:114:in `investigate' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/team.rb:102:in `offenses' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cop/team.rb:44:in `inspect_file' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:258:in `inspect_file' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:205:in `block in do_inspection_loop' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:237:in `block in iterate_until_no_changes' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:230:in `loop' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:230:in `iterate_until_no_changes' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:201:in `do_inspection_loop' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:111:in `block in file_offenses' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:121:in `file_offense_cache' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:109:in `file_offenses' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:100:in `process_file' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:78:in `block in each_inspected_file' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:75:in `each' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:75:in `reduce' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:75:in `each_inspected_file' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:67:in `inspect_files' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/runner.rb:39:in `run' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cli.rb:150:in `execute_runner' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cli.rb:78:in `execute_runners' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/lib/rubocop/cli.rb:38:in `run' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/bin/rubocop:13:in `block in <top (required)>' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/2.2.0/benchmark.rb:303:in `realtime' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rubocop-0.52.1/bin/rubocop:12:in `<top (required)>' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bin/rubocop:23:in `load' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bin/rubocop:23:in `<top (required)>' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/cli/exec.rb:75:in `load' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/cli/exec.rb:75:in `kernel_load' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/cli/exec.rb:28:in `run' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/cli.rb:424:in `exec' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/cli.rb:27:in `dispatch' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/cli.rb:18:in `start' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/exe/bundle:30:in `block in <top (required)>' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/lib/bundler/friendly_errors.rb:122:in `with_friendly_errors' /Users/dominic/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.16.0/exe/bundle:22:in `<top (required)>' /Users/dominic/.rbenv/versions/2.2.2/bin/bundle:23:in `load' /Users/dominic/.rbenv/versions/2.2.2/bin/bundle:23:in `<main>' . 1 file inspected, no offenses detected 1 error occurred: An error occurred while Rails/Presence cop was inspecting /Users/dominic/tmp/a.rb:5:4. Errors are usually caused by RuboCop bugs. Please, report your problems to RuboCop's issue tracker. Mention the following information in the issue report: 0.52.1 (using Parser 2.4.0.2, running on ruby 2.2.2 x86_64-darwin16) Finished in 0.3389270000043325 seconds
$ rubocop -V 0.52.1 (using Parser 2.4.0.2, running on ruby 2.2.2 x86_64-darwin16)
The text was updated successfully, but these errors were encountered:
cc @wata727
Sorry, something went wrong.
[Fix rubocop#5383] Fix locally defined blank? & present? false positi…
758da47
…ves/errors
present?
27af3c7
No branches or pull requests
If a class has a method
blank?
and that method is called withif blank?
then the copRails/Presence
throws an exceptionExpected behavior
I expect the
Rails/Presence
cop not to throw an exception when parsing syntactically correct codeActual behavior
The
Rails/Presence
cop throws an exception when parsing a reference to a locally definedblank?
methodSteps to reproduce the problem
tmp/a.rb
)rubocop --debug tmp/a.rb
RuboCop version
The text was updated successfully, but these errors were encountered: