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

Fix a false positive for Lint/BooleanSymbol when used within %i[...] #8836

Merged
merged 1 commit into from Oct 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -9,6 +9,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