Class: RuboCop::Cop::Homebrew::SimpleTypeAssertion Private
- Defined in:
- rubocops/simple_type_assertion.rb,
sorbet/rbi/dsl/rubo_cop/cop/homebrew/simple_type_assertion.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.
Keep branching, operators and multi-step computations outside Sorbet type assertions. Allow up to three calls and argument values, including inside deferred blocks. A nested call counts towards the limit once, even when passed as an argument. Parentheses and freezing a value do not add to the count.
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.
"Move this expression outside `T.%<method>s`."- RESTRICT_ON_SEND =
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.
[:let, :cast].freeze
- MAX_VALUE_PARTS =
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.
3
Instance Method Summary collapse
- #integer_literal?(node, **kwargs, &block) ⇒ T.untyped private
- #literal_or_reference?(node, **kwargs, &block) ⇒ T.untyped private
- #on_send(node) ⇒ void (also: #on_csend) private
- #static_expression?(node, **kwargs, &block) ⇒ T.untyped private
Instance Method Details
#integer_literal?(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/simple_type_assertion.rbi', line 10 def integer_literal?(node, **kwargs, &block); end |
#literal_or_reference?(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/simple_type_assertion.rbi', line 13 def literal_or_reference?(node, **kwargs, &block); end |
#on_send(node) ⇒ void Also known as: on_csend
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.
This method returns an undefined value.
46 47 48 49 50 51 52 53 |
# File 'rubocops/simple_type_assertion.rb', line 46 def on_send(node) return if node.receiver&.const_name != "T" value = node.first_argument return if !value || (simple_value?(value) && value_parts(value) <= MAX_VALUE_PARTS) add_offense(value, message: format(MSG, method: node.method_name)) end |
#static_expression?(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.
16 |
# File 'sorbet/rbi/dsl/rubo_cop/cop/homebrew/simple_type_assertion.rbi', line 16 def static_expression?(node, **kwargs, &block); end |