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(var.nil?) gets wrongfully converted to not var.nil? which can lead to invalid ruby code #459

Open
onvbqalc opened this issue Jan 17, 2024 · 0 comments

Comments

@onvbqalc
Copy link

  • Ruby version: 3.1.2
  • Rubyfmt git sha: e00d2ab89fd4b0b85a7897fac393c1ad987136de
==> rubyfmt: stable 0.10.0 (bottled), HEAD
Ruby autoformatter
https://github.com/fables-tales/rubyfmt
/opt/homebrew/Cellar/rubyfmt/0.10.0 (8 files, 15.4MB) *
  Poured from bottle using the formulae.brew.sh API on 2024-01-07 at 04:41:02
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/r/rubyfmt.rb

Input file

class MyClass
  def my_method
    a.nil? || not(b.nil?) || c.nil?
  end
end

Rubyfmt's output

# First format - no output but brackets () are removed
# leaving conditional as: a.nil? || not b.nil? || c.nil?
#
# Second format:
Rubyfmt detected a syntax error in the ruby code being executed

This breaks because

Code should have been left as-is on the first format - instead, it got converted to invalid ruby code:

a.nil? || not b.nil? || c.nil?

(is not valid ruby)

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