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

undefined method `prefix_not? in Style/OneLineConditional #7728

Closed
tas50 opened this issue Feb 19, 2020 · 0 comments · Fixed by #7729
Closed

undefined method `prefix_not? in Style/OneLineConditional #7728

tas50 opened this issue Feb 19, 2020 · 0 comments · Fixed by #7729
Labels

Comments

@tas50
Copy link
Contributor

tas50 commented Feb 19, 2020

Expected behavior

When autocorrecting in Style/OneLineConditional you should not receive any errors

Actual behavior

Autocorrect fails with:

undefined method `prefix_not?' for s(:self):RuboCop::AST::Node
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/style/one_line_conditional.rb:94:in `keyword_with_changed_precedence?'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/style/one_line_conditional.rb:82:in `requires_parentheses?'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/style/one_line_conditional.rb:74:in `expr_replacement'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/style/one_line_conditional.rb:67:in `to_ternary'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/style/one_line_conditional.rb:60:in `replacement'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/style/one_line_conditional.rb:39:in `block in autocorrect'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/cop.rb:36:in `call'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/corrector.rb:63:in `block (2 levels) in rewrite'
/usr/local/lib/ruby/gems/2.6.0/gems/parser-2.7.0.2/lib/parser/source/tree_rewriter.rb:220:in `transaction'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/corrector.rb:62:in `block in rewrite'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/corrector.rb:60:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/corrector.rb:60:in `rewrite'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/team.rb:136:in `autocorrect_all_cops'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/team.rb:72:in `autocorrect'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/team.rb:108:in `block in offenses'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/team.rb:125:in `investigate'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/team.rb:104:in `offenses'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cop/team.rb:44:in `inspect_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:296:in `inspect_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:244:in `block in do_inspection_loop'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:276:in `block in iterate_until_no_changes'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:269:in `loop'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:269:in `iterate_until_no_changes'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:240:in `do_inspection_loop'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:119:in `block in file_offenses'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:143:in `file_offense_cache'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:117:in `file_offenses'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:108:in `process_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:87:in `block in each_inspected_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:86:in `each'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:86:in `reduce'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:86:in `each_inspected_file'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:73:in `inspect_files'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/runner.rb:39:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cli/command/execute_runner.rb:21:in `execute_runner'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cli/command/execute_runner.rb:13:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cli/command.rb:10:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cli/environment.rb:17:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cli.rb:65:in `run_command'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cli.rb:72:in `execute_runners'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/lib/rubocop/cli.rb:41:in `run'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/exe/rubocop:13:in `block in <top (required)>'
/usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
/usr/local/lib/ruby/gems/2.6.0/gems/rubocop-0.80.0/exe/rubocop:12:in `<top (required)>'

Steps to reproduce the problem

Autocorrect this rather funky code:

res.site (if self.is_a?(Chef::Resource::NoosferoSite) then self else self.site end)

RuboCop version

Include the output of rubocop -V or bundle exec rubocop -V if using Bundler. Here's an example:

0.80.0
@koic koic added the bug label Feb 19, 2020
koic added a commit to koic/rubocop that referenced this issue Feb 19, 2020
Fixes rubocop#7728.

This PR fixes an error for `Style/OneLineConditional`
when one of the branches contains a self keyword.
koic added a commit to koic/rubocop that referenced this issue Feb 19, 2020
Fixes rubocop#7728.

This PR fixes an error for `Style/OneLineConditional`
when one of the branches contains a self keyword.
koic added a commit to koic/rubocop that referenced this issue Feb 23, 2020
Fixes rubocop#7728.

This PR fixes an error for `Style/OneLineConditional`
when one of the branches contains a self keyword.
koic added a commit to koic/rubocop that referenced this issue Mar 2, 2020
Fixes rubocop#7728.

This PR fixes an error for `Style/OneLineConditional`
when one of the branches contains a self keyword.
koic added a commit to koic/rubocop that referenced this issue Mar 8, 2020
Fixes rubocop#7728.

This PR fixes an error for `Style/OneLineConditional`
when one of the branches contains a self keyword.
koic added a commit to koic/rubocop that referenced this issue Mar 21, 2020
Fixes rubocop#7728.

This PR fixes an error for `Style/OneLineConditional`
when one of the branches contains a self keyword.
koic added a commit to koic/rubocop that referenced this issue Mar 25, 2020
Fixes rubocop#7728.

This PR fixes an error for `Style/OneLineConditional`
when one of the branches contains a self keyword.
koic added a commit that referenced this issue Mar 27, 2020
…nditional

[Fix #7728] Fix an error for `Style/OneLineConditional`
Neodelf pushed a commit to Neodelf/rubocop that referenced this issue Apr 28, 2020
Fixes rubocop#7728.

This PR fixes an error for `Style/OneLineConditional`
when one of the branches contains a self keyword.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants