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

Allow Style/WordArray not just to be disabled but have alternate EnforcedStyle #1543

Closed
lloeki opened this issue Dec 30, 2014 · 6 comments
Closed

Comments

@lloeki
Copy link
Contributor

lloeki commented Dec 30, 2014

Style/WordArray can only be Enabled: false, have MinSize set or WordRegex defined.

If one wants to enforce word array percent syntax not to be used, even hacking into MinSize (setting it to a huge value) or WordRegex (setting it to something clever that will never match) doesn't work.

Having an EnforcedStyle with values of array or percent, defaulting to the latter, would be quite useful.

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 30, 2014

Yes, this makes sense. Same can be done about other similar cops.

On Tuesday, December 30, 2014, Loic Nageleisen notifications@github.com
wrote:

Style/WordArray can only be Enabled: false, have MinSize set or WordRegex
defined.

If one wants to enforce word array percent syntax not to be used, the
only solution is to hack into MinSize (setting it to a huge value) or
WordRegex (setting it to something clever that will never match).

Having an EnforcedStyle with values of array or percent, defaulting to
the latter, would be quite useful.


Reply to this email directly or view it on GitHub
#1543.

@alexdowad
Copy link
Contributor

So once we have array and percent styles, what should happen with the MinSize parameter? Do we keep it? (Presumably it would only apply when the percent style is selected?)

@jonas054
Copy link
Collaborator

Another way to go would be to let the cop enforce array literals when there are MinSize words or fewer. Today it allows either syntax in those cases.

@alexdowad
Copy link
Contributor

@jonas054 And presumably we error out if both EnforcedStyle: array and MinSize > 0?

@jonas054
Copy link
Collaborator

Sorry. I wasn't very clear. What I meant was, that if we're just more strict and always require array literals or require %w or %W, depending on the MinSizesetting, then we don't need to add EnforcedStyle. Setting MinSize: 1000000 will have the same effect as EnforcedStyle: array.

@bbatsov
Copy link
Collaborator

bbatsov commented Dec 24, 2015

Another way to go would be to let the cop enforce array literals when there are MinSize words or fewer. Today it allows either syntax in those cases.

Seems to me we should go with the simplest possible option - just add one more style. If people want to use only [] we'll ignore the MinSize.

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

No branches or pull requests

4 participants