Skip to content

Naming/AccessorMethodName could be more tunable #13150

@akimd

Description

@akimd

Hi!

Is your feature request related to a problem? Please describe.

We have a method named get_min!. It has a bang because it's not just an accessor: it has side-effects (and does return a result).

I think that Naming/AccessorMethodName should not fire in this case (names ending with a bang).

We also have other get_foo methods, where we use get_ as a hint that they are costly. They are not just as cheap as accessors. It would be nice if Naming/AccessorMethodName had some AllowedMethods or AllowedNames support for such cases.

Describe alternatives you've considered

Of course we can use # rubocop:disable, but:

  • for get_min!, it does not look like a genuine accessor, IMHO it should not fire at all
  • for other the cases, it's just nicer to avoid cluttering the source with magic comments, but it's also less precise (it is project-wise), so I can see reason to reject this.

Thanks!

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