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

Add #assignment? and #asgn_method_call? to Node, use to make code more concise #2398

Merged
merged 2 commits into from
Nov 6, 2015

Conversation

alexdowad
Copy link
Contributor

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.

…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.
@alexdowad
Copy link
Contributor Author

Added a fix for the problem with code alignment on the LHS of an assignment statement. Once that fix is in master, my other PR for Style/AlignHash can go ahead.

@@ -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
Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@alexdowad
Copy link
Contributor Author

Just made a small code change to enhance readability (using #singleton_class to get the... singleton class). I had forgotten that you don't support Ruby 1.8; that was why I avoided using this method before.

@bbatsov
Copy link
Collaborator

bbatsov commented Nov 6, 2015

I had forgotten that you don't support Ruby 1.8;

Nobody should be supporting 1.8 anymore. :-)

@alexdowad
Copy link
Contributor Author

Tell that to the maintainers of some other gems which I work on...

@bbatsov
Copy link
Collaborator

bbatsov commented Nov 6, 2015

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.

bbatsov added a commit that referenced this pull request Nov 6, 2015
Add #assignment? and #asgn_method_call? to Node, use to make code more concise
@bbatsov bbatsov merged commit cb5b037 into rubocop:master Nov 6, 2015
@alexdowad alexdowad deleted the asgn_matcher branch November 6, 2015 17:56
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

Successfully merging this pull request may close these issues.

None yet

2 participants