Class: RuboCop::Cop::Cask::DeprecateDisableUnsignedReason Private
- Extended by:
- AutoCorrector
- Includes:
- CaskHelp
- Defined in:
- rubocops/cask/deprecate_disable_unsigned_reason.rb
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.
This cop checks for use of because: :unsigned
in deprecate!
/disable!
and replaces it with the preferred :fails_gatekeeper_check
reason.
Example # bad deprecate! date: "2024-01-01", because: :unsigned disable! because: :unsigned
# good deprecate! date: "2024-01-01", because: :fails_gatekeeper_check disable! because: :fails_gatekeeper_check
Constant Summary collapse
- STANZAS_TO_CHECK =
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.
[:deprecate!, :disable!].freeze
- MESSAGE =
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 `:fails_gatekeeper_check` instead of `:unsigned` for deprecate!/disable! reason."
Instance Method Summary collapse
Methods included from CaskHelp
#cask_tap, #inner_stanzas, #on_block, #on_cask, #on_system_methods
Instance Method Details
#on_cask_stanza_block(stanza_block) ⇒ void
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.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'rubocops/cask/deprecate_disable_unsigned_reason.rb', line 26 def on_cask_stanza_block(stanza_block) stanzas = stanza_block.stanzas.select { |s| STANZAS_TO_CHECK.include?(s.stanza_name) } stanzas.each do |stanza| stanza_node = T.cast(stanza.stanza_node, RuboCop::AST::SendNode) hash_node = stanza_node.last_argument next unless hash_node&.hash_type? # find `because: :unsigned` pairs T.cast(hash_node, RuboCop::AST::HashNode).each_pair do |key_node, value_node| next if !key_node.sym_type? || key_node.value != :because next if !value_node.sym_type? || value_node.value != :unsigned add_offense(value_node, message: MESSAGE) do |corrector| corrector.replace(value_node.source_range, ":fails_gatekeeper_check") end end end end |