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

False positive for Layout/IndentationConsistency with EnforcedStyle: indented_internal_methods #8919

Closed
kamipo opened this issue Oct 22, 2020 · 2 comments · Fixed by #8928
Closed
Labels

Comments

@kamipo
Copy link

kamipo commented Oct 22, 2020

Looks like there is a regression for Layout/IndentationConsistency with EnforcedStyle: indented_internal_methods against Struct block in RuboCop 1.0.0.

Steps to reproduce the problem

# .rubocop.yml
AllCops:
  DisabledByDefault: true

Layout/IndentationConsistency:
  Enabled: true
  EnforcedStyle: indented_internal_methods
# foo.rb
Foo = Struct.new(:foo) do
  private
    def private_foo
      foo
    end
end
% rubocop foo.rb
Inspecting 1 file
C

Offenses:

foo.rb:3:5: C: Layout/IndentationConsistency: Inconsistent indentation detected.
    def private_foo ...
    ^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected, 1 offense auto-correctable

Expected behavior

No offences.

Actual behavior

% rubocop foo.rb
Inspecting 1 file
C

Offenses:

foo.rb:3:5: C: Layout/IndentationConsistency: Inconsistent indentation detected.
    def private_foo ...
    ^^^^^^^^^^^^^^^

1 file inspected, 1 offense detected, 1 offense auto-correctable

RuboCop version

1.0.0 (using Parser 2.7.2.0, rubocop-ast 0.8.0, running on ruby 2.7.1 x86_64-darwin17)

@koic koic added the bug label Oct 22, 2020
koic added a commit to koic/rubocop-ast that referenced this issue Oct 22, 2020
This PR supports struct constructor for `SendNode#macro?`.

Like class constructor, struct constructor will be recognized as a
macro and will be awakened in the following `private` modifier:

```ruby
Foo = Struct.new(:foo) do
  private
    def private_foo
      foo
    end
end
```

With this change, this PR aims to resolve the following issue.
rubocop/rubocop#8919
koic added a commit to koic/rubocop-ast that referenced this issue Oct 22, 2020
This PR makes `SendNode#macro?` aware of struct constructor.

Like class constructor, struct constructor will be recognized as a
macro and will be awakened in the following `private` modifier:

```ruby
Foo = Struct.new(:foo) do
  private
    def private_foo
      foo
    end
end
```

With this change, this PR aims to resolve the following issue.
rubocop/rubocop#8919
koic added a commit to koic/rubocop-ast that referenced this issue Oct 23, 2020
This PR makes `SendNode#macro?` and `RuboCop::AST::Node#class_constructor?`
aware of struct constructor and `RuboCop::AST::Node#struct_constructor?`
is deprecated.

Like class constructor, struct constructor will be recognized as a
macro and will be awakened in the following `private` modifier:

```ruby
Foo = Struct.new(:foo) do
  private
    def private_foo
      foo
    end
end
```

With this change, this PR aims to resolve the following issue.
rubocop/rubocop#8919
marcandre pushed a commit to rubocop/rubocop-ast that referenced this issue Oct 23, 2020
This PR makes `SendNode#macro?` and `RuboCop::AST::Node#class_constructor?`
aware of struct constructor and `RuboCop::AST::Node#struct_constructor?`
is deprecated.

Like class constructor, struct constructor will be recognized as a
macro and will be awakened in the following `private` modifier:

```ruby
Foo = Struct.new(:foo) do
  private
    def private_foo
      foo
    end
end
```

With this change, this PR aims to resolve the following issue.
rubocop/rubocop#8919
koic added a commit to koic/rubocop that referenced this issue Oct 23, 2020
Fixes rubocop#8919 and follow rubocop/rubocop-ast#141.

This PR requires rubocop-ast 1.0.1 to awaken of struct constructor.
And it will also add a reproduction test for rubocop#8919
@koic
Copy link
Member

koic commented Oct 23, 2020

@kamipo This issue has been resolved by rubocop/rubocop-ast#141 and RuboCop AST 1.0.1 has been released. Can you update rubocop-ast to 1.0.1? Thank you.

@kamipo
Copy link
Author

kamipo commented Oct 23, 2020

Thank you for the quick fix! I've confirmed that is fixed in rails/rails#40436.

koic added a commit that referenced this issue Oct 23, 2020
[Fix #8919] Require RuboCop AST to 1.0.1 or higher
koic added a commit to koic/rubocop-rails_config that referenced this issue Oct 25, 2020
Follow rails/rails#40436.

This PR enables `Layout/SpaceAroundOperators` cop.
rails/rails#40436 setting requires
RuboCop 1.0 and RuboCop AST 1.0.1 or higher.
rubocop/rubocop#8919

Therefore this PR will be dropping versions that is lack for that requires.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants