You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've noticed an issue with the Rails/FindBy cop where it incorrectly leaves a redundant newline when autocorrecting an invocation of take or first. This occurs when these methods are called on a separate line with a leading dot. This issue results in a syntax error if there's another method call following it, as illustrated below.
User.where(id: x).take.nil?
Expected behavior
After autocorrection, the code should appear as follows, without any additional newlines:
User.find_by(id: x).nil?
Actual behavior
However, the autocorrection currently results in an unnecessary newline, causing a syntax error:
User.find_by(id: x).nil?
Steps to reproduce the problem
Save the initial code snippet into a file named example.rb.
Execute bundle exec rubocop --only Rails/FindBy -a example.rb.
I've noticed an issue with the
Rails/FindBy
cop where it incorrectly leaves a redundant newline when autocorrecting an invocation oftake
orfirst
. This occurs when these methods are called on a separate line with a leading dot. This issue results in a syntax error if there's another method call following it, as illustrated below.Expected behavior
After autocorrection, the code should appear as follows, without any additional newlines:
Actual behavior
However, the autocorrection currently results in an unnecessary newline, causing a syntax error:
Steps to reproduce the problem
example.rb
.bundle exec rubocop --only Rails/FindBy -a example.rb
.RuboCop version
The text was updated successfully, but these errors were encountered: