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
Closed

Comments

@avrusanov
Copy link
Contributor

@avrusanov 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:

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

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

@marcandre marcandre commented Jun 10, 2020

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

@avrusanov
Copy link
Contributor Author

@avrusanov avrusanov commented Jun 10, 2020

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

@marcandre
Copy link
Contributor

@marcandre marcandre commented Jun 10, 2020

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

@avrusanov
Copy link
Contributor Author

@avrusanov 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
@bbatsov bbatsov closed this in 018a042 Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.