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
0 files inspected? #6722
Labels
Comments
koic
added a commit
to koic/rubocop
that referenced
this issue
Feb 4, 2019
Fixes rubocop#6722. This PR fixes an error for `Style/OneLineConditional` when `then` branch has no body. The following is an error case. ```ruby # example.rb if cond then else dont end ``` The following is a reproduction step. ```console % rubocop -v 0.63.1 % rubocop -a example.rb --only Style/OneLineConditional Inspecting 1 file 0 files inspected, no offenses detected undefined method `type' for nil:NilClass /Users/koic/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/style/one_line_conditional.rb:74:in `requires_parentheses?' /Users/koic/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/style/one_line_conditional.rb:70:in `expr_replacement' /Users/koic/.rbenv/versions/2.6.1/lib/ruby/gems/2.6.0/gems/rubocop-0.63.1/lib/rubocop/cop/style/one_line_conditional.rb:65:in `to_ternary' (snip) ``` This PR auto-corrected to the following code. ```ruby cond ? nil : dont ``` Actually the above code is the same behavior as `unless` modifier. But this PR aims auto-corrected to an equivalent code without causing an error.
8 tasks
Thanks for the feedback. I opened a PR #6727. |
Drenmi
added a commit
that referenced
this issue
Feb 4, 2019
[Fix #6722] Fix an error for `Style/OneLineConditional`
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Expected rubocop to parse and identify errors in the ruby file, as it does when I use no options or the -x option. Instead, when running "rubocop -a" I get the following output:
Reproduce by running rubocop on the following code:
RuboCop version: 0.63.1 (using Parser 2.6.0.0, running on ruby 2.5.3 x64-mingw32)
The text was updated successfully, but these errors were encountered: