You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running Style/OneLineConditional on code that contains a conditional with a keyword such as retry, raise, or break in one of its branches with auto-correct enabled doesn't cause Rubocop to crash.
Actual behavior
Running Style/OneLineConditional on code that contains a conditional with a keyword such as retry, raise, or break in one of its branches with auto-correct enabled causes Rubocop to crash.
Steps to reproduce the problem
This is a problem regardless of whether the keyword occurs in the if or else branch.
[21:16:34] ~/Documents ➜ cat foo.rb
if true then retry else 7 end
[21:17:24] ~/Documents ➜ rubocop -a --only Style/OneLineConditional
Inspecting 2 files
0 files inspected, no offenses detected
undefined method `prefix_not?' for s(:retry):RuboCop::AST::Node
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/style/one_line_conditional.rb:90:in `keyword_with_changed_precedence?'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/style/one_line_conditional.rb:78:in `requires_parentheses?'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/style/one_line_conditional.rb:70:in `expr_replacement'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/style/one_line_conditional.rb:65:in `to_ternary'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/style/one_line_conditional.rb:50:in `replacement'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/style/one_line_conditional.rb:39:in `block in autocorrect'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/corrector.rb:64:in `block (2 levels) in rewrite'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/parser-2.5.3.0/lib/parser/source/tree_rewriter.rb:220:in `transaction'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/corrector.rb:63:in `block in rewrite'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/corrector.rb:61:in `each'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/corrector.rb:61:in `rewrite'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/team.rb:128:in `autocorrect_all_cops'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/team.rb:72:in `autocorrect'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/team.rb:100:in `block in offenses'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/team.rb:117:in `investigate'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/team.rb:96:in `offenses'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/team.rb:44:in `inspect_file'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:280:in `inspect_file'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:227:in `block in do_inspection_loop'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:259:in `block in iterate_until_no_changes'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:252:in `loop'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:252:in `iterate_until_no_changes'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:223:in `do_inspection_loop'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:126:in `block in file_offenses'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:144:in `file_offense_cache'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:124:in `file_offenses'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:112:in `process_file'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:89:in `block in each_inspected_file'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:86:in `each'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:86:in `reduce'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:86:in `each_inspected_file'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:76:in `inspect_files'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/runner.rb:48:in `run'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cli.rb:174:in `execute_runner'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cli.rb:75:in `execute_runners'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cli.rb:47:in `run'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/exe/rubocop:13:in `block in <top (required)>'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/2.6.0/benchmark.rb:308:in `realtime'
/Users/pat/.rbenv/versions/2.6.0/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/exe/rubocop:12:in `<top (required)>'
/Users/pat/.rbenv/versions/2.6.0/bin/rubocop:23:in `load'
/Users/pat/.rbenv/versions/2.6.0/bin/rubocop:23:in `<main>'
The text was updated successfully, but these errors were encountered:
patbl
changed the title
Style/OneLineConditional auto-correct crashes when conditional body contains retry keyword
Style/OneLineConditional auto-correct crashes when conditional body contains certain keywords
Feb 10, 2019
Expected behavior
Running
Style/OneLineConditional
on code that contains a conditional with a keyword such asretry
,raise
, orbreak
in one of its branches with auto-correct enabled doesn't cause Rubocop to crash.Actual behavior
Running
Style/OneLineConditional
on code that contains a conditional with a keyword such asretry
,raise
, orbreak
in one of its branches with auto-correct enabled causes Rubocop to crash.Steps to reproduce the problem
This is a problem regardless of whether the keyword occurs in the
if
orelse
branch.RuboCop version
The text was updated successfully, but these errors were encountered: