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

Change default args forStyle/SingleLineBlockParams #3601

Merged
merged 1 commit into from
Oct 18, 2016
Merged

Change default args forStyle/SingleLineBlockParams #3601

merged 1 commit into from
Oct 18, 2016

Conversation

jessieay
Copy link
Contributor

@jessieay jessieay commented Oct 12, 2016

Why:

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 13, 2016

I tend to agree with you on this one. But I do feel that a better solution would be to simply make the names configurable (and by default to change them to something like acc and elem maybe). The idea of the rule the cop enforces was that using common short names in short blocks keeps them understandable while preserving horizontal space. We can definitely do better, though.

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 13, 2016

And after I said this I saw the cop is already configurable and one can change the defaults.

@jessieay
Copy link
Contributor Author

@bbatsov Thanks for taking a look.

The reason I think this cop should not be enabled by default is that I find it unexpected for a style library to dictate variable names . Adding naming guidelines is more common, but actually saying "this variable should be a" rarely makes sense, in my opinion.

If you think we should continue to make this cop enabled by default, what do you think about changing the default args from a and e to accumulator and element so that Rubocop's default config is compatible with Reek?

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 14, 2016

If you think we should continue to make this cop enabled by default, what do you think about changing the default args from a and e to accumulator and element so that Rubocop's default config is compatible with Reek?

I'm fine with changing the defaults, but given the line length constraint I'd say "acc" and "elem" might be better names - still understandable and not that long.

Btw, there's a reason why RuboCop doesn't implement this particular check - it's really hard to figure out of something is a bad name - if you're dealing with points x and y are perfectly reasonable even though they are single character. That said, maybe we should add such a cop and see what feedback we'd get from our users.

@jessieay
Copy link
Contributor Author

Ok @bbatsov thanks for the feedback -- updated per your suggestion.

I think it would be better not to have requirements for variable names at all, but I think this is a good incremental improvement.

@bbatsov
Copy link
Collaborator

bbatsov commented Oct 18, 2016

The building is failing, because now there are offenses in RuboCop's own code.

@jessieay
Copy link
Contributor Author

@bbatsov thanks for letting me know! fixed

@jessieay jessieay changed the title Disable Style/SingleLineBlockParams by default Change default args forStyle/SingleLineBlockParams Oct 18, 2016
**Why**:
* This cop enforces block args of `a` and `e` by default
* This suggestion causes an "Uncommunicative Variable Name" error from
  Reek
* Source: https://github.com/troessner/reek/blob/master/docs/Uncommunicative-Variable-Name.md
* I tend to agree with Reek on this one. I like expressive variables.
* New default arg names: `acc` and `elem` per #3601 (comment)
@bbatsov bbatsov merged commit e027526 into rubocop:master Oct 18, 2016
@Drenmi Drenmi mentioned this pull request Oct 19, 2016
11 tasks
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