Class: RuboCop::Cop::Cask::InstallSteps Private
- Extended by:
- AutoCorrector
- 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], )
- LEGACY_FLIGHT_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.
"Casks in official Homebrew taps must use `%<steps>s` instead of `%<flight>s`."- KEYCHAIN_HASHES_SOURCE =
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.
'hashes = stdout.lines.grep(/^SHA-256 hash:/) { |l| l.split(":").second.strip }'- KEYCHAIN_DELETE_SOURCE =
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( <<~RUBY.gsub(/\s+/, " ").strip.freeze, String, )
- CERTIFICATE_EXISTS_GUARD_SOURCE =
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.
"next unless cert.exist?"- CERTIFICATE_FINGERPRINT_SOURCE =
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( <<~RUBY.gsub(/\s+/, " ").strip.freeze, String, )
- CERTIFICATE_HASH_SOURCE =
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.
'hash = stdout.lines.first.split("=").second.delete(":").strip'- CERTIFICATE_HASH_DELETE_SOURCE =
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( <<~RUBY.gsub(/\s+/, " ").strip.freeze, String, )
Constants included from InstallStepsHelper
InstallStepsHelper::ALLOWED_STEP_ARGUMENT_NODE_TYPES, InstallStepsHelper::ALLOWED_STEP_METHODS, InstallStepsHelper::BREW_RUBY_STEP_MSG, InstallStepsHelper::CASK_ALLOWED_STEP_METHODS, InstallStepsHelper::COMMAND_STEP_METHODS, InstallStepsHelper::COMPATIBILITY_STEP_KEYWORD_REPLACEMENTS, InstallStepsHelper::COMPATIBILITY_STEP_METHODS, InstallStepsHelper::COMPATIBILITY_STEP_METHOD_REPLACEMENTS, InstallStepsHelper::CONFIG_WRITE_STEP_METHODS, InstallStepsHelper::FILE_PREPARATION_STEP_METHODS, InstallStepsHelper::FORMULA_ACTION_STEP_METHODS, InstallStepsHelper::KEYCHAIN_STEP_METHODS, InstallStepsHelper::LEGACY_STEP_KEYWORD_MSG, InstallStepsHelper::LEGACY_STEP_METHOD_MSG, InstallStepsHelper::LINK_STEP_METHODS, InstallStepsHelper::MACHO_STEP_METHODS, InstallStepsHelper::NOTICE_STEP_METHODS, InstallStepsHelper::OFFICIAL_HOMEBREW_TAP_PATH_REGEX, InstallStepsHelper::PERMISSION_STEP_METHODS, InstallStepsHelper::REBUILD_ACTION_STEP_LINES, InstallStepsHelper::REBUILD_ACTION_STEP_METHODS, InstallStepsHelper::SERVICE_DATA_STEP_METHODS, InstallStepsHelper::SIMPLE_STEP_CONVERSION_MSG, InstallStepsHelper::STEP_BLOCK_MSG, InstallStepsHelper::STEP_SCOPE_METHODS
Instance Method Summary collapse
- #on_cask(cask_block) ⇒ void private
Methods included from InstallStepsHelper
#add_compatibility_step_offenses, #append_install_step_lines, #brew_ruby_step_node, #direct_install_step_nodes, #install_step_block_offense_node, #install_steps_block_source, #normalised_install_step_source, #official_homebrew_tap?, #simple_install_step_lines, #step_block_msg
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.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'rubocops/cask/install_steps.rb', line 58 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 }) steps_stanza = stanzas.find { |stanza| stanza.stanza_name == steps_block } converted_flight = autocorrect_flight_block?(flight_stanza, steps_block) if steps_stanza.nil? # odeprecated: remove the official-tap scope in the next major or minor release. next unless official_homebrew_tap?(processed_source.file_path) next if converted_flight add_offense(flight_stanza.method_node, message: format(LEGACY_FLIGHT_MSG, steps: steps_block, flight: flight_block)) end stanzas.each do |stanza| next unless INSTALL_STEP_PAIRS.value?(stanza.stanza_name) next unless stanza.method_node.block_type? block_node = T.cast(stanza.method_node, RuboCop::AST::BlockNode) add_compatibility_step_offenses(block_node, allowed_methods: CASK_ALLOWED_STEP_METHODS) if (offense_node = brew_ruby_step_node(block_node)) add_offense(offense_node, message: BREW_RUBY_STEP_MSG) next end next unless (offense_node = install_step_block_offense_node( block_node, allowed_methods: CASK_ALLOWED_STEP_METHODS, )) add_offense(offense_node, message: step_block_msg(CASK_ALLOWED_STEP_METHODS)) end end |