-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add #assignment? and #asgn_method_call? to Node, use to make code more concise #2398
Conversation
…e concise A test case for the ABC cop has been adjusted, because this code: x[0] = 1 ...is now counted as an assignment and a method call, rather than 2 method calls.
Added a fix for the problem with code alignment on the LHS of an assignment statement. Once that fix is in |
@@ -168,6 +168,15 @@ | |||
expect(cop.messages).to eq(['Use 2 (not 6) spaces for indenting an ' \ | |||
'expression spanning multiple lines.']) | |||
end | |||
|
|||
it 'registers an offense for aligned code on LHS of assignment' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be good to add one example without an assignment as well, just for clarity's sake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
8064e61
to
2cdb42a
Compare
2cdb42a
to
70e60b5
Compare
Just made a small code change to enhance readability (using |
Nobody should be supporting 1.8 anymore. :-) |
Tell that to the maintainers of some other gems which I work on... |
Yeah, I know what you mean. But I've always been a bit believer in pushing things forward and would never support an obsolete technology just to prolong the agony of its users. |
Add #assignment? and #asgn_method_call? to Node, use to make code more concise
Leveraging
NodePattern
to do some refactoring here.A test case for the ABC cop has been adjusted, because this code:
x[0] = 1
...is now counted as an assignment and a method call, rather than 2 method calls.