Class: RuboCop::Cop::Homebrew::Presence Private
- Extended by:
- AutoCorrector
- Includes:
- RangeHelp
- Defined in:
- rubocops/presence.rb,
sorbet/rbi/dsl/rubo_cop/cop/homebrew/presence.rbi
Overview
This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.
Checks code that can be written more easily using
Object#presence
defined by Active Support.
Examples
# bad
a.present? ? a : nil
# bad
!a.present? ? nil : a
# bad
a.blank? ? nil : a
# bad
!a.blank? ? a : nil
# good
a.presence
# bad
a.present? ? a : b
# bad
!a.present? ? b : a
# bad
a.blank? ? b : a
# bad
!a.blank? ? a : b
# good
a.presence || b
Constant Summary collapse
- MSG =
This constant is part of a private API. This constant may only be used in the Homebrew/brew repository. Third parties should avoid using this constant if possible, as it may be removed or changed without warning.
"Use `%<prefer>s` instead of `%<current>s`."
Instance Method Summary collapse
- #on_if(node) ⇒ Object private
- #redundant_negative_receiver_and_other(node, **kwargs, &block) ⇒ T.untyped private
- #redundant_receiver_and_other(node, **kwargs, &block) ⇒ T.untyped private
Instance Method Details
#on_if(node) ⇒ Object
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'rubocops/presence.rb', line 81 def on_if(node) return if ignore_if_node?(node) redundant_receiver_and_other(node) do |receiver, other| return if ignore_other_node?(other) || receiver.nil? register_offense(node, receiver, other) end redundant_negative_receiver_and_other(node) do |receiver, other| return if ignore_other_node?(other) || receiver.nil? register_offense(node, receiver, other) end end |
#redundant_negative_receiver_and_other(node, **kwargs, &block) ⇒ T.untyped
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
10 |
# File 'sorbet/rbi/dsl/rubo_cop/cop/homebrew/presence.rbi', line 10 def redundant_negative_receiver_and_other(node, **kwargs, &block); end |
#redundant_receiver_and_other(node, **kwargs, &block) ⇒ T.untyped
This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.
13 |
# File 'sorbet/rbi/dsl/rubo_cop/cop/homebrew/presence.rbi', line 13 def redundant_receiver_and_other(node, **kwargs, &block); end |