Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion lib/rubocop/cop/type_toolkit/prefer_not_nil.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def requires_parentheses?(argument)
end
return true if argument.range_type? || argument.operator_keyword?
return true if argument.if_type? || argument.assignment?
return true if argument.any_block_type?

KEYWORD_EXPRESSION_TYPES.include?(argument.type)
end
Expand Down
5 changes: 4 additions & 1 deletion spec/rubocop/cop/type_toolkit/prefer_not_nil_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class PreferNotNilSpec < ::Minitest::Spec
^^^^^^^^^^^^^^^^^ #{MSG}
block_value = T.must(foo { bar })
^^^^^^^^^^^^^^^^^^^ #{MSG}
block_with_arguments = T.must(foo(arg) { |value| value })
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{MSG}
defined_value = T.must(defined?(foo))
^^^^^^^^^^^^^^^^^^^^^ #{MSG}
def example
Expand All @@ -98,7 +100,8 @@ def explicit_super
logical = (foo || bar).not_nil!
grouped = (foo || bar).not_nil!
assignment = (foo = bar).not_nil!
block_value = (foo { bar }).not_nil!
block_value = foo { bar }.not_nil!
block_with_arguments = foo(arg) { |value| value }.not_nil!
defined_value = (defined?(foo)).not_nil!
def example
(yield foo).not_nil!
Expand Down
Loading