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

Problem with Naming/MethodName: EnforcedStyle: camelCase and '_' or 'i' variables #8132

Closed
avrusanov opened this issue Jun 10, 2020 · 4 comments

Comments

@avrusanov
Copy link
Contributor

avrusanov commented Jun 10, 2020

Hello!

We use:
rubocop -V
0.85.0 (using Parser 2.7.1.3, rubocop-ast 0.0.3, running on ruby 2.4.5 x86_64-darwin18)

We have problem with cop
Naming/MethodName:
EnforcedStyle: camelCase

and '_' or 'i' variables.

We have offences like that:

C: Naming/VariableName: Use camelCase for variable names. (https://rubystyle.guide#snake-case-symbols-methods-vars)
    readM.select { |_, opt| opt[:name] == dTypeName }.first
                    ^

For fixing that line needs to be changed:
https://github.com/rubocop-hq/rubocop/blob/971769a0a01c55d9b23a29ae8d5b3ab45f637152/lib/rubocop/cop/mixin/configurable_naming.rb#L12

From

        camelCase:  /^@{0,2}_?[a-z][\da-zA-Z]+[!?=]?$/

To:

        camelCase:  /^@{0,2}_?([a-z]|[a-z][\da-zA-Z]+)?[!?=]?$/

I can create pull request if acceptable

@marcandre
Copy link
Contributor

Good catch. A pull request would be great. Best use a no-capture (?: ... ) I think.

@avrusanov
Copy link
Contributor Author

/^@{0,2}_?(?:[a-z]|[a-z][\da-zA-Z]+)?[!?=]?$/ - OK?

@marcandre
Copy link
Contributor

[a-z]|[a-z][\da-zA-Z]+ => [a-z][\da-zA-Z]*, simpler and equivalent, right?

@avrusanov
Copy link
Contributor Author

avrusanov commented Jun 11, 2020

Yes. /^@{0,2}(?:_|_?[a-z][\da-zA-Z]*)[!?=]?$/ is acceptable?

avrusanov pushed a commit to avrusanov/rubocop that referenced this issue Jun 11, 2020
avrusanov pushed a commit to avrusanov/rubocop that referenced this issue Jun 12, 2020
avrusanov pushed a commit to avrusanov/rubocop that referenced this issue Jun 12, 2020
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

2 participants