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

Style/TernaryParentheses claims to correct, but does not #3687

Closed
donv opened this issue Oct 31, 2016 · 0 comments
Closed

Style/TernaryParentheses claims to correct, but does not #3687

donv opened this issue Oct 31, 2016 · 0 comments

Comments

@donv
Copy link

donv commented Oct 31, 2016

Given a file with the following code:

class MyClass
  attr_accessor :start_at, :end_at
  def my_method
    (end_at == start_at) ? 1 : 2
  end
end

Running Rubocop with --auto-correct gives the following output:

Inspecting 1 file
C

Offenses:

ternary_parentheses.rb:4:5: C: [Corrected] Style/TernaryParentheses: Omit parentheses for ternary conditions.
    (end_at == start_at) ? 1 : 2
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected, 1 offense corrected

Expected behavior

The parentheses should be removed.

Actual behavior

The parentheses are still present.

RuboCop version

Using master at 9ad80ca

$ rubocop -V
0.45.0 (using Parser 2.3.1.4, running on jruby 2.3.1 java)
Ana06 added a commit to Ana06/rubocop that referenced this issue Nov 16, 2016
Style/TernaryParentheses cop claims to correct uncorrected offenses
(safe assignment or unsafe autocorrection).
Ana06 added a commit to Ana06/rubocop that referenced this issue Nov 20, 2016
Add tests for the TernaryParentheses cop to cover the case that was
failing in rubocop#3687.
It has already been fixed but there were no tests for this case.
bbatsov pushed a commit that referenced this issue Nov 20, 2016
Add tests for the TernaryParentheses cop to cover the case that was
failing in #3687.
It has already been fixed but there were no tests for this case.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant