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

Incorrect conversion of nested modifiers with 'unless' #2894

Closed
jweir opened this issue Feb 26, 2016 · 1 comment
Closed

Incorrect conversion of nested modifiers with 'unless' #2894

jweir opened this issue Feb 26, 2016 · 1 comment

Comments

@jweir
Copy link
Contributor

jweir commented Feb 26, 2016

Rubocop version 0.37.2 converts the below (awful code)

class X
  def test
    if true
      unless @state == 'x'
        puts 'never!'
      end
    end
  end
end

into this incorrect bit of code

class X
  def test
    puts 'never!' if true && !@state == 'x'
  end
end

the problem is !@state == 'x' should be @state != 'x'

@jweir
Copy link
Contributor Author

jweir commented Feb 27, 2016

After working on this – I personally don't like the solution. It might be better to just not autocorrect these cases, which are hopefully very rare.

@jweir jweir changed the title Incorrect conversion of nested modifiers with 'unless; Incorrect conversion of nested modifiers with 'unless' Feb 29, 2016
@bbatsov bbatsov closed this as completed in 4d919eb Mar 2, 2016
bbatsov added a commit that referenced this issue Mar 2, 2016
  [Fix #2894] Auto-correct properly an unless with a comparison operator
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