Class: Homebrew::TapAuditor Private
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.
Auditor for checking common violations in Taps.
Instance Attribute Summary collapse
- #cask_renames ⇒ Object readonly private
- #cask_tokens ⇒ Object readonly private
- #formula_aliases ⇒ Object readonly private
- #formula_names ⇒ Object readonly private
- #formula_renames ⇒ Object readonly private
- #name ⇒ Object readonly private
- #path ⇒ Object readonly private
- #problems ⇒ Object readonly private
- #tap_audit_exceptions ⇒ Object readonly private
- #tap_style_exceptions ⇒ Object readonly private
Instance Method Summary collapse
- #audit ⇒ void private
- #audit_aliases_renames_duplicates ⇒ void private
- #audit_json_files ⇒ void private
- #audit_tap_formula_lists ⇒ void private
- #initialize(tap, strict:) ⇒ void constructor private
- #problem(message) ⇒ void private
Constructor Details
#initialize(tap, strict:) ⇒ 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.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'tap_auditor.rb', line 11 def initialize(tap, strict:) Homebrew.with_no_api_env do tap.clear_cache if Homebrew::EnvConfig.automatically_set_no_install_from_api? @name = tap.name @path = tap.path @tap_audit_exceptions = tap.audit_exceptions @tap_style_exceptions = tap.style_exceptions @tap_synced_versions_formulae = tap.synced_versions_formulae @tap_disabled_new_usr_local_relocation_formulae = tap.disabled_new_usr_local_relocation_formulae @tap_autobump = tap.autobump @tap_official = tap.official? @problems = [] @cask_tokens = tap.cask_tokens.map do |cask_token| cask_token.split("/").last end @formula_aliases = tap.aliases.map do |formula_alias| formula_alias.split("/").last end @formula_renames = tap.formula_renames @cask_renames = tap.cask_renames @formula_names = tap.formula_names.map do |formula_name| formula_name.split("/").last end end end |
Instance Attribute Details
#cask_renames ⇒ Object (readonly)
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.
7 8 9 |
# File 'tap_auditor.rb', line 7 def cask_renames @cask_renames end |
#cask_tokens ⇒ Object (readonly)
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.
7 8 9 |
# File 'tap_auditor.rb', line 7 def cask_tokens @cask_tokens end |
#formula_aliases ⇒ Object (readonly)
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.
7 8 9 |
# File 'tap_auditor.rb', line 7 def formula_aliases @formula_aliases end |
#formula_names ⇒ Object (readonly)
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.
7 8 9 |
# File 'tap_auditor.rb', line 7 def formula_names @formula_names end |
#formula_renames ⇒ Object (readonly)
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.
7 8 9 |
# File 'tap_auditor.rb', line 7 def formula_renames @formula_renames end |
#name ⇒ Object (readonly)
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.
7 8 9 |
# File 'tap_auditor.rb', line 7 def name @name end |
#path ⇒ Object (readonly)
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.
7 8 9 |
# File 'tap_auditor.rb', line 7 def path @path end |
#problems ⇒ Object (readonly)
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.
7 8 9 |
# File 'tap_auditor.rb', line 7 def problems @problems end |
#tap_audit_exceptions ⇒ Object (readonly)
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.
7 8 9 |
# File 'tap_auditor.rb', line 7 def tap_audit_exceptions @tap_audit_exceptions end |
#tap_style_exceptions ⇒ Object (readonly)
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.
7 8 9 |
# File 'tap_auditor.rb', line 7 def tap_style_exceptions @tap_style_exceptions end |
Instance Method Details
#audit ⇒ 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.
39 40 41 42 43 |
# File 'tap_auditor.rb', line 39 def audit audit_json_files audit_tap_formula_lists audit_aliases_renames_duplicates end |
#audit_aliases_renames_duplicates ⇒ 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.
68 69 70 71 72 73 |
# File 'tap_auditor.rb', line 68 def audit_aliases_renames_duplicates duplicates = formula_aliases & formula_renames.keys return if duplicates.none? problem "The following should either be an alias or a rename, not both: #{duplicates.to_sentence}" end |
#audit_json_files ⇒ 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.
46 47 48 49 50 51 52 53 |
# File 'tap_auditor.rb', line 46 def audit_json_files json_patterns = Tap::HOMEBREW_TAP_JSON_FILES.map { |pattern| @path/pattern } Pathname.glob(json_patterns).each do |file| JSON.parse file.read rescue JSON::ParserError problem "#{file.to_s.delete_prefix("#{@path}/")} contains invalid JSON" end end |
#audit_tap_formula_lists ⇒ 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.
56 57 58 59 60 61 62 63 64 65 |
# File 'tap_auditor.rb', line 56 def audit_tap_formula_lists check_formula_list_directory "audit_exceptions", @tap_audit_exceptions check_formula_list_directory "style_exceptions", @tap_style_exceptions check_renames "formula_renames.json", @formula_renames, @formula_names, @formula_aliases check_renames "cask_renames.json", @cask_renames, @cask_tokens check_formula_list ".github/autobump.txt", @tap_autobump unless @tap_official check_formula_list "synced_versions_formulae", @tap_synced_versions_formulae.flatten check_formula_list "disabled_new_usr_local_relocation_formulae.json", @tap_disabled_new_usr_local_relocation_formulae end |
#problem(message) ⇒ 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.
76 77 78 |
# File 'tap_auditor.rb', line 76 def problem() @problems << ({ message:, location: nil, corrected: false }) end |