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

Style/ConstantName gives a false positive for SCREAMING_SNAKE_CASE with accents #5016

Closed
timrogers opened this issue Nov 8, 2017 · 0 comments

Comments

@timrogers
Copy link

Rubocop::Cop::Style::ConstantName enforces that constant names must be written using SCREAMING_SNAKE_CASE, by comparing them to its regex, SNAKE_CASE.

Capital letters can have accents, but the regular expression only permits unaccented letters A-Z. We should also allow capital letters with accents.


Expected behavior

MATÍAS = "matías"

should be permitted by the cop, just as:

MATIAS = "matías"

is permitted.

Actual behavior

Rubocop detects an offence.

Steps to reproduce the problem

Define a constant using what looks like SCREAMING_SNAKE_CASE, but including capital letterswith accents.

RuboCop version

$ rubocop -V
0.51.0 (using Parser 2.4.0.0, running on ruby 2.4.2 x86_64-darwin16)
timrogers pushed a commit to timrogers/rubocop that referenced this issue Dec 5, 2017
`Rubocop::Cop::Style::ConstantName` enforces that constant names
must be written using SCREAMING_SNAKE_CASE, by comparing them to
its regex, `SNAKE_CASE`.

Capital letters can have accents, but the regular expression only
permits unaccented letters A-Z.

This modifies the regular expression to also permit capital
letters with accents using [POSIX character classes][], and adds a
spec confirming this behaviour.

Fixes rubocop#5016.

[POSIX character classes]: https://en.wikibooks.org/wiki/Regular_Expressions/POSIX_Basic_Regular_Expressions#Character_classes
bbatsov pushed a commit that referenced this issue Dec 5, 2017
`Rubocop::Cop::Style::ConstantName` enforces that constant names
must be written using SCREAMING_SNAKE_CASE, by comparing them to
its regex, `SNAKE_CASE`.

Capital letters can have accents, but the regular expression only
permits unaccented letters A-Z.

This modifies the regular expression to also permit capital
letters with accents using [POSIX character classes][], and adds a
spec confirming this behaviour.

Fixes #5016.

[POSIX character classes]: https://en.wikibooks.org/wiki/Regular_Expressions/POSIX_Basic_Regular_Expressions#Character_classes
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

1 participant