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

Fix: register an offence when the last hash parameter has braces. #567

Merged
merged 1 commit into from
Oct 15, 2013

Conversation

dblock
Copy link
Contributor

@dblock dblock commented Oct 15, 2013

The following code will now register an offence, see discussion in https://github.com/bbatsov/rubocop/pull/551/files#r6921166.

where(1, { y: 2 })

However, when you have multiple hash parameters, it will not to avoid the ugly

where({ x: 1 }, y: 2)

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 15, 2013

👍

return unless arg && arg.type == :hash && arg.children.any?

has_braces = !arg.loc.begin.nil?
multiple_hashes = args.size > 1 && args.all? { |a| a.type == :hash }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Technically speaking all_hashes is a better name for that variable :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally, renamed.

bbatsov added a commit that referenced this pull request Oct 15, 2013
Fix: register an offence when the last hash parameter has braces.
@bbatsov bbatsov merged commit ea19746 into rubocop:master Oct 15, 2013
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.

2 participants