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

Layout/ClassStructure cop should allow grouping macros by their visibility #5465

Closed
gPrado opened this issue Jan 15, 2018 · 0 comments · Fixed by #5468
Closed

Layout/ClassStructure cop should allow grouping macros by their visibility #5465

gPrado opened this issue Jan 15, 2018 · 0 comments · Fixed by #5468

Comments

@gPrado
Copy link
Contributor

gPrado commented Jan 15, 2018

Expected behavior

There should be a way to configure different visibility levels for macros to avoid false positives with the ordering of protected/private macros.

Actual behavior

Currently, there is no way to make such configuration.

Steps to reproduce the problem

Given the following configuration:

Layout/ClassStructure:
  Categories:
    - attribute:
      - attr_accessor
      - attr_writer
      - attr_reader
  ExpectedOrder:
    - attribute
    - initializer

And the following class definition:

class Person
  attr_accessor :name

  def initialize(name)
    @name = name
  end

  private

  attr_accessor :age
end

Rubocop gives the following output:

person.rb:10:3: C: Layout/ClassStructure: attribute is supposed to appear before initializer.
  attr_accessor :age
  ^^^^^^^^^^^^^^^^^^

RuboCop version

$ rubocop -V
0.52.1 (using Parser 2.4.0.2, running on ruby 2.3.0 x86_64-darwin16)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants