Skip to content

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

@avrusanov

Description

@avrusanov

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

Activity

marcandre

marcandre commented on Jun 10, 2020

@marcandre
Contributor

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

avrusanov

avrusanov commented on Jun 10, 2020

@avrusanov
ContributorAuthor

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

marcandre

marcandre commented on Jun 10, 2020

@marcandre
Contributor

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

avrusanov

avrusanov commented on Jun 11, 2020

@avrusanov
ContributorAuthor

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

added 3 commits that reference this issue on Jun 11, 2020
bffba51
bfc1f15
4f87275
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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