Class: RuboCop::Cop::Cask::InstallSteps Private
- Includes:
- CaskHelp, InstallStepsHelper
- Defined in:
- rubocops/cask/install_steps.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 declarative install step usage.
Constant Summary collapse
- INSTALL_STEP_PAIRS =
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.
T.let( { preflight: :preflight_steps, postflight: :postflight_steps, uninstall_preflight: :uninstall_preflight_steps, uninstall_postflight: :uninstall_postflight_steps, }.freeze, T::Hash[Symbol, Symbol], )
Constants included from InstallStepsHelper
InstallStepsHelper::ALLOWED_STEP_ARGUMENT_NODE_TYPES, InstallStepsHelper::ALLOWED_STEP_METHODS, InstallStepsHelper::SIMPLE_STEP_CONVERSION_MSG, InstallStepsHelper::STEP_BLOCK_MSG
Instance Method Summary collapse
- #on_cask(cask_block) ⇒ void private
Methods included from InstallStepsHelper
#install_step_block_offense_node, #install_steps_block_source, #simple_install_step_lines
Methods included from CaskHelp
#cask_tap, #inner_stanzas, #on_block, #on_cask_stanza_block, #on_system_methods
Instance Method Details
#on_cask(cask_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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'rubocops/cask/install_steps.rb', line 25 def on_cask(cask_block) stanzas = cask_block.stanzas INSTALL_STEP_PAIRS.each do |flight_block, steps_block| next unless (flight_stanza = stanzas.find { |stanza| stanza.stanza_name == flight_block }) next unless (steps_stanza = stanzas.find { |stanza| stanza.stanza_name == steps_block }) add_offense(steps_stanza.source_range, message: "`#{flight_stanza.stanza_name}` and `#{steps_block}` cannot both be used.") end stanzas.each do |stanza| next unless INSTALL_STEP_PAIRS.value?(stanza.stanza_name) next unless stanza.method_node.block_type? next unless (offense_node = install_step_block_offense_node(T.cast(stanza.method_node, RuboCop::AST::BlockNode))) add_offense(offense_node, message: STEP_BLOCK_MSG) end end |