Skip to content

Commit

Permalink
[Fix rubocop#8919] Require RuboCop AST to 1.0.1 or higher
Browse files Browse the repository at this point in the history
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
  • Loading branch information
koic committed Oct 23, 2020
1 parent 46cca67 commit ecf4316
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@
### Changes

* [#8920](https://github.com/rubocop-hq/rubocop/pull/8920): Remove Capybara's `save_screenshot` from `Lint/Debugger`. ([@ybiquitous][])
* [#8919](https://github.com/rubocop-hq/rubocop/issues/8919): Require RuboCop AST to 1.0.1 or higher. ([@koic][])

### Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion rubocop.gemspec
Expand Up @@ -38,7 +38,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('rainbow', '>= 2.2.2', '< 4.0')
s.add_runtime_dependency('regexp_parser', '>= 1.8')
s.add_runtime_dependency('rexml')
s.add_runtime_dependency('rubocop-ast', '>= 0.6.0')
s.add_runtime_dependency('rubocop-ast', '>= 1.0.1')
s.add_runtime_dependency('ruby-progressbar', '~> 1.7')
s.add_runtime_dependency('unicode-display_width', '>= 1.4.0', '< 2.0')

Expand Down
36 changes: 36 additions & 0 deletions spec/rubocop/cop/layout/indentation_consistency_spec.rb
Expand Up @@ -527,6 +527,42 @@ def meow_at_4am?
end
RUBY
end

it 'accepts different indentation in different visibility sections when using `Struct.new`' do
expect_no_offenses(<<~RUBY)
Foo = Struct.new(:foo) do
def meow
puts('Meow!')
end
protected
def can_we_be_friends?(another_cat)
# some logic
end
def related_to?(another_cat)
# some logic
end
private
# Here we go back an indentation level again. This is a
# violation of the indented_internal_methods style,
# but it's not for this cop to report.
# Layout/IndentationWidth will handle it.
def meow_at_3am?
rand < 0.8
end
# As long as the indentation of this method is
# consistent with that of the last one, we're fine.
def meow_at_4am?
rand < 0.8
end
end
RUBY
end
end

context 'with normal style configured' do
Expand Down

0 comments on commit ecf4316

Please sign in to comment.