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

not(foo) auto-corrected to notfoo #2768

Closed
mikestok opened this issue Feb 3, 2016 · 1 comment
Closed

not(foo) auto-corrected to notfoo #2768

mikestok opened this issue Feb 3, 2016 · 1 comment

Comments

@mikestok
Copy link

mikestok commented Feb 3, 2016

Using rubocop 0.36.0 and b9205cb (ruby 2.3.0 and no .rubocop.yml) not(foo) is incorrectly autocorrected:

✔ ~/tmp/rubobug
12:32 $ cat bug.rb
#!/usr/bin/env ruby

def foo
  false
end

puts "banana" if true && not(foo)
✔ ~/tmp/rubobug
12:32 $ bundle exec rubocop --auto-correct bug.rb
Inspecting 1 file
W

Offenses:

bug.rb:7:18: W: Literal true appeared in a condition.
puts "banana" if true && notfoo
                 ^^^^
bug.rb:7:26: C: [Corrected] Use ! instead of not.
puts "banana" if true && not(foo)
                         ^^^
bug.rb:7:26: C: [Corrected] Space after keyword not is missing.
puts "banana" if true && not(foo)
                         ^^^
bug.rb:7:29: C: [Corrected] Do not use parentheses for method calls with no arguments.
puts "banana" if true && not(foo)
                            ^

1 file inspected, 4 offenses detected, 3 offenses corrected
✘-1 ~/tmp/rubobug
12:32 $ cat bug.rb
#!/usr/bin/env ruby

def foo
  false
end

puts "banana" if true && notfoo
@lumeet
Copy link
Contributor

lumeet commented Feb 3, 2016

There are at least three bugs shown in this report. :) My PR fixes two of them. but Style/Not should still either accept not(foo) or actually auto-correct it instead of just saying so. I'll try to find some time to fix that one tomorrow, unless someone else is quick to do it before.

@bbatsov bbatsov closed this as completed in 88d9ef1 Feb 3, 2016
bbatsov added a commit that referenced this issue Feb 3, 2016
[Fix #2768] Allow parentheses after keyword not
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

2 participants