8000 Style/AccessModifierDeclarations false positives · Issue #5953 · rubocop/rubocop · GitHub
[go: up one dir, main page]

Skip to content
Style/AccessModifierDeclarations false positives #5953
@dgollahon

Description

@dgollahon

I just upgraded to the latest rubocop and received some peculiar offenses from Style/AccessModifierDeclarations offenses. I use a number of different tools that generate methods automatically, including anima, for example. But sometimes I apply a different access modifier to the generated method(s). Style/AccessModifierDeclarations flags this as "inlined", when it is not anything I would consider inline.


Expected behavior

I expect the following example (and various similar cases) not to raise an offense with the default rubocop configuration.

class Foo
  include Anima.new(:foo) # Defines constructor which takes the single keyword argument :foo and generates a public reader.

  private :foo
end

If, for some reason, this is the intended behavior and I'm missing something here, I think the error message should be made clearer. I think this cop should ignore access modifier adjustments to methods it can't statically detect.

Actual behavior

test.rb:4:3: C: Style/AccessModifierDeclarations: private should not be inlined in method definitions.
  private :foo
  ^^^^^^^

Steps to reproduce the problem

Run rubocop with Style/AccessModifierDeclarations's style set to "group" (the default).

RuboCop version

$ rubocop -V
0.57.0 (using Parser 2.5.1.0, running on ruby 2.5.1 x86_64-darwin17)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementgood first issueEasy task, suitable for newcomers to the projecthigh priorityA ticket considered important by RuboCop's Core Team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0