Skip to content

Commit

Permalink
Fix a false positive for Lint/BooleanSymbol when used within %i[...]
Browse files Browse the repository at this point in the history
  • Loading branch information
fatkodima authored and bbatsov committed Oct 4, 2020
1 parent 9e8a53d commit 4f101b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@
### Bug fixes

* [#8810](https://github.com/rubocop-hq/rubocop/pull/8810): Fix multiple offense detection for `Style/RaiseArgs`. ([@pbernays][])
* [#8151](https://github.com/rubocop-hq/rubocop/issues/8151): Fix a false positive for `Lint/BooleanSymbol` when used within `%i[...]`. ([@fatkodima][])
* [#8809](https://github.com/rubocop-hq/rubocop/pull/8809): Fix multiple offense detection for `Style/For`. ([@pbernays][])
* [#8801](https://github.com/rubocop-hq/rubocop/issues/8801): Fix `Layout/SpaceAroundEqualsInParameterDefault` only registered once in a line. ([@rdunlop][])
* [#8514](https://github.com/rubocop-hq/rubocop/issues/8514): Correct multiple `Style/MethodDefParentheses` per file. ([@rdunlop][])
Expand Down
3 changes: 3 additions & 0 deletions lib/rubocop/cop/lint/boolean_symbol.rb
Expand Up @@ -32,6 +32,9 @@ class BooleanSymbol < Base
def on_sym(node)
return unless boolean_symbol?(node)

parent = node.parent
return if parent&.array_type? && parent&.percent_literal?(:symbol)

add_offense(node, message: format(MSG, boolean: node.value)) do |corrector|
autocorrect(corrector, node)
end
Expand Down
6 changes: 6 additions & 0 deletions spec/rubocop/cop/lint/boolean_symbol_spec.rb
Expand Up @@ -76,4 +76,10 @@
false
RUBY
end

it 'does not register an offense when used inside percent-literal symbol array' do
expect_no_offenses(<<~RUBY)
%i[foo false]
RUBY
end
end

0 comments on commit 4f101b6

Please sign in to comment.