mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
audit: limit non-failure cask output
This commit is contained in:
parent
516903530a
commit
2b8d19e0bd
10
.github/workflows/tests.yml
vendored
10
.github/workflows/tests.yml
vendored
@ -77,7 +77,7 @@ jobs:
|
|||||||
run: brew style --display-cop-names homebrew/core
|
run: brew style --display-cop-names homebrew/core
|
||||||
|
|
||||||
- name: Run brew audit --skip-style on all taps
|
- name: Run brew audit --skip-style on all taps
|
||||||
run: brew audit --skip-style
|
run: brew audit --skip-style --display-failures-only
|
||||||
|
|
||||||
- name: Set up all Homebrew taps
|
- name: Set up all Homebrew taps
|
||||||
run: |
|
run: |
|
||||||
@ -277,10 +277,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Run brew audit --skip-style on Cask taps
|
- name: Run brew audit --skip-style on Cask taps
|
||||||
run: |
|
run: |
|
||||||
brew audit --skip-style --tap=homebrew/cask
|
brew audit --skip-style --display-failures-only --tap=homebrew/cask
|
||||||
brew audit --skip-style --tap=homebrew/cask-drivers
|
brew audit --skip-style --display-failures-only --tap=homebrew/cask-drivers
|
||||||
brew audit --skip-style --tap=homebrew/cask-fonts
|
brew audit --skip-style --display-failures-only --tap=homebrew/cask-fonts
|
||||||
brew audit --skip-style --tap=homebrew/cask-versions
|
brew audit --skip-style --display-failures-only --tap=homebrew/cask-versions
|
||||||
|
|
||||||
- name: Install brew tests dependencies
|
- name: Install brew tests dependencies
|
||||||
run: |
|
run: |
|
||||||
|
@ -126,8 +126,10 @@ module Cask
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { returns(String) }
|
sig { params(include_passed: T::Boolean).returns(String) }
|
||||||
def summary
|
def summary(include_passed: false)
|
||||||
|
return if success? && !include_passed
|
||||||
|
|
||||||
summary = ["audit for #{cask}: #{result}"]
|
summary = ["audit for #{cask}: #{result}"]
|
||||||
|
|
||||||
errors.each do |error|
|
errors.each do |error|
|
||||||
|
@ -18,7 +18,9 @@ module Cask
|
|||||||
audit_token_conflicts: nil,
|
audit_token_conflicts: nil,
|
||||||
quarantine: nil,
|
quarantine: nil,
|
||||||
any_named_args: nil,
|
any_named_args: nil,
|
||||||
language: nil
|
language: nil,
|
||||||
|
display_passes: nil,
|
||||||
|
display_failures_only: nil
|
||||||
)
|
)
|
||||||
new(
|
new(
|
||||||
cask,
|
cask,
|
||||||
@ -31,6 +33,8 @@ module Cask
|
|||||||
quarantine: quarantine,
|
quarantine: quarantine,
|
||||||
any_named_args: any_named_args,
|
any_named_args: any_named_args,
|
||||||
language: language,
|
language: language,
|
||||||
|
display_passes: display_passes,
|
||||||
|
display_failures_only: display_failures_only,
|
||||||
).audit
|
).audit
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -46,7 +50,9 @@ module Cask
|
|||||||
audit_new_cask: nil,
|
audit_new_cask: nil,
|
||||||
quarantine: nil,
|
quarantine: nil,
|
||||||
any_named_args: nil,
|
any_named_args: nil,
|
||||||
language: nil
|
language: nil,
|
||||||
|
display_passes: nil,
|
||||||
|
display_failures_only: nil
|
||||||
)
|
)
|
||||||
@cask = cask
|
@cask = cask
|
||||||
@audit_download = audit_download
|
@audit_download = audit_download
|
||||||
@ -58,6 +64,8 @@ module Cask
|
|||||||
@audit_token_conflicts = audit_token_conflicts
|
@audit_token_conflicts = audit_token_conflicts
|
||||||
@any_named_args = any_named_args
|
@any_named_args = any_named_args
|
||||||
@language = language
|
@language = language
|
||||||
|
@display_passes = display_passes
|
||||||
|
@display_failures_only = display_failures_only
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit
|
def audit
|
||||||
@ -67,13 +75,18 @@ module Cask
|
|||||||
if !language && language_blocks
|
if !language && language_blocks
|
||||||
language_blocks.each_key do |l|
|
language_blocks.each_key do |l|
|
||||||
audit = audit_languages(l)
|
audit = audit_languages(l)
|
||||||
puts audit.summary if output_summary?(audit)
|
summary = audit.summary(include_passed: output_passed?)
|
||||||
|
if summary.present? && output_summary?(audit)
|
||||||
|
ohai "Auditing language: #{l.map { |lang| "'#{lang}'" }.to_sentence}" if output_summary?
|
||||||
|
puts summary
|
||||||
|
end
|
||||||
warnings += audit.warnings
|
warnings += audit.warnings
|
||||||
errors += audit.errors
|
errors += audit.errors
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
audit = audit_cask_instance(cask)
|
audit = audit_cask_instance(cask)
|
||||||
puts audit.summary if output_summary?(audit)
|
summary = audit.summary(include_passed: output_passed?)
|
||||||
|
puts summary if summary.present? && output_summary?(audit)
|
||||||
warnings += audit.warnings
|
warnings += audit.warnings
|
||||||
errors += audit.errors
|
errors += audit.errors
|
||||||
end
|
end
|
||||||
@ -84,6 +97,7 @@ module Cask
|
|||||||
private
|
private
|
||||||
|
|
||||||
def output_summary?(audit = nil)
|
def output_summary?(audit = nil)
|
||||||
|
return false if @display_failures_only.present?
|
||||||
return true if @any_named_args.present?
|
return true if @any_named_args.present?
|
||||||
return true if @audit_strict.present?
|
return true if @audit_strict.present?
|
||||||
return false if audit.blank?
|
return false if audit.blank?
|
||||||
@ -91,9 +105,14 @@ module Cask
|
|||||||
audit.errors?
|
audit.errors?
|
||||||
end
|
end
|
||||||
|
|
||||||
def audit_languages(languages)
|
def output_passed?
|
||||||
ohai "Auditing language: #{languages.map { |lang| "'#{lang}'" }.to_sentence}" if output_summary?
|
return false if @display_failures_only.present?
|
||||||
|
return true if @display_passes.present?
|
||||||
|
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
def audit_languages(languages)
|
||||||
original_config = cask.config
|
original_config = cask.config
|
||||||
localized_config = original_config.merge(Config.new(explicit: { languages: languages }))
|
localized_config = original_config.merge(Config.new(explicit: { languages: languages }))
|
||||||
cask.config = localized_config
|
cask.config = localized_config
|
||||||
|
@ -27,6 +27,8 @@ module Cask
|
|||||||
description: "Run various additional style checks to determine if a new cask is eligible " \
|
description: "Run various additional style checks to determine if a new cask is eligible " \
|
||||||
"for Homebrew. This should be used when creating new casks and implies " \
|
"for Homebrew. This should be used when creating new casks and implies " \
|
||||||
"`--strict` and `--online`"
|
"`--strict` and `--online`"
|
||||||
|
switch "--display-failures-only",
|
||||||
|
description: "Only display casks that fail the audit. This is the default for formulae."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -53,6 +55,8 @@ module Cask
|
|||||||
quarantine: args.quarantine?,
|
quarantine: args.quarantine?,
|
||||||
any_named_args: any_named_args,
|
any_named_args: any_named_args,
|
||||||
language: args.language,
|
language: args.language,
|
||||||
|
display_passes: args.verbose? || args.named.count == 1,
|
||||||
|
display_failures_only: args.display_failures_only?,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.class.print_annotations(results)
|
self.class.print_annotations(results)
|
||||||
@ -73,7 +77,9 @@ module Cask
|
|||||||
token_conflicts: nil,
|
token_conflicts: nil,
|
||||||
quarantine: nil,
|
quarantine: nil,
|
||||||
any_named_args: nil,
|
any_named_args: nil,
|
||||||
language: nil
|
language: nil,
|
||||||
|
display_passes: nil,
|
||||||
|
display_failures_only: nil
|
||||||
)
|
)
|
||||||
options = {
|
options = {
|
||||||
audit_download: download,
|
audit_download: download,
|
||||||
@ -85,6 +91,8 @@ module Cask
|
|||||||
quarantine: quarantine,
|
quarantine: quarantine,
|
||||||
language: language,
|
language: language,
|
||||||
any_named_args: any_named_args,
|
any_named_args: any_named_args,
|
||||||
|
display_passes: display_passes,
|
||||||
|
display_failures_only: display_failures_only,
|
||||||
}.compact
|
}.compact
|
||||||
|
|
||||||
options[:quarantine] = true if options[:quarantine].nil?
|
options[:quarantine] = true if options[:quarantine].nil?
|
||||||
|
@ -56,6 +56,8 @@ module Homebrew
|
|||||||
switch "--display-filename",
|
switch "--display-filename",
|
||||||
description: "Prefix every line of output with the file or formula name being audited, to "\
|
description: "Prefix every line of output with the file or formula name being audited, to "\
|
||||||
"make output easy to grep."
|
"make output easy to grep."
|
||||||
|
switch "--display-failures-only",
|
||||||
|
description: "Only display casks that fail the audit. This is the default for formulae."
|
||||||
switch "--skip-style",
|
switch "--skip-style",
|
||||||
description: "Skip running non-RuboCop style checks. Useful if you plan on running "\
|
description: "Skip running non-RuboCop style checks. Useful if you plan on running "\
|
||||||
"`brew style` separately. Enabled by default unless a formula is specified by name."
|
"`brew style` separately. Enabled by default unless a formula is specified by name."
|
||||||
@ -222,6 +224,8 @@ module Homebrew
|
|||||||
quarantine: nil,
|
quarantine: nil,
|
||||||
any_named_args: !no_named_args,
|
any_named_args: !no_named_args,
|
||||||
language: nil,
|
language: nil,
|
||||||
|
display_passes: args.verbose? || args.named.count == 1,
|
||||||
|
display_failures_only: args.display_failures_only?,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -324,6 +324,7 @@ _brew_audit() {
|
|||||||
--cask
|
--cask
|
||||||
--debug
|
--debug
|
||||||
--display-cop-names
|
--display-cop-names
|
||||||
|
--display-failures-only
|
||||||
--display-filename
|
--display-filename
|
||||||
--except
|
--except
|
||||||
--except-cops
|
--except-cops
|
||||||
|
@ -325,6 +325,7 @@ __fish_brew_complete_arg 'audit' -l audit-debug -d 'Enable debugging and profili
|
|||||||
__fish_brew_complete_arg 'audit' -l cask -d 'Treat all named arguments as casks'
|
__fish_brew_complete_arg 'audit' -l cask -d 'Treat all named arguments as casks'
|
||||||
__fish_brew_complete_arg 'audit' -l debug -d 'Display any debugging information'
|
__fish_brew_complete_arg 'audit' -l debug -d 'Display any debugging information'
|
||||||
__fish_brew_complete_arg 'audit' -l display-cop-names -d 'Include the RuboCop cop name for each violation in the output'
|
__fish_brew_complete_arg 'audit' -l display-cop-names -d 'Include the RuboCop cop name for each violation in the output'
|
||||||
|
__fish_brew_complete_arg 'audit' -l display-failures-only -d 'Only display casks that fail the audit. This is the default for formulae'
|
||||||
__fish_brew_complete_arg 'audit' -l display-filename -d 'Prefix every line of output with the file or formula name being audited, to make output easy to grep'
|
__fish_brew_complete_arg 'audit' -l display-filename -d 'Prefix every line of output with the file or formula name being audited, to make output easy to grep'
|
||||||
__fish_brew_complete_arg 'audit' -l except -d 'Specify a comma-separated method list to skip running the methods named `audit_`method'
|
__fish_brew_complete_arg 'audit' -l except -d 'Specify a comma-separated method list to skip running the methods named `audit_`method'
|
||||||
__fish_brew_complete_arg 'audit' -l except-cops -d 'Specify a comma-separated cops list to skip checking for violations of the listed RuboCop cops'
|
__fish_brew_complete_arg 'audit' -l except-cops -d 'Specify a comma-separated cops list to skip checking for violations of the listed RuboCop cops'
|
||||||
|
@ -406,6 +406,7 @@ _brew_audit() {
|
|||||||
'--audit-debug[Enable debugging and profiling of audit methods]' \
|
'--audit-debug[Enable debugging and profiling of audit methods]' \
|
||||||
'--debug[Display any debugging information]' \
|
'--debug[Display any debugging information]' \
|
||||||
'(--skip-style --only-cops --except-cops)--display-cop-names[Include the RuboCop cop name for each violation in the output]' \
|
'(--skip-style --only-cops --except-cops)--display-cop-names[Include the RuboCop cop name for each violation in the output]' \
|
||||||
|
'--display-failures-only[Only display casks that fail the audit. This is the default for formulae]' \
|
||||||
'--display-filename[Prefix every line of output with the file or formula name being audited, to make output easy to grep]' \
|
'--display-filename[Prefix every line of output with the file or formula name being audited, to make output easy to grep]' \
|
||||||
'(--only)--except[Specify a comma-separated method list to skip running the methods named `audit_`method]' \
|
'(--only)--except[Specify a comma-separated method list to skip running the methods named `audit_`method]' \
|
||||||
'(--only-cops --strict --only-cops --only --display-cop-names)--except-cops[Specify a comma-separated cops list to skip checking for violations of the listed RuboCop cops]' \
|
'(--only-cops --strict --only-cops --only --display-cop-names)--except-cops[Specify a comma-separated cops list to skip checking for violations of the listed RuboCop cops]' \
|
||||||
|
@ -780,6 +780,8 @@ non-zero status if any errors are found.
|
|||||||
Include the RuboCop cop name for each violation in the output.
|
Include the RuboCop cop name for each violation in the output.
|
||||||
* `--display-filename`:
|
* `--display-filename`:
|
||||||
Prefix every line of output with the file or formula name being audited, to make output easy to grep.
|
Prefix every line of output with the file or formula name being audited, to make output easy to grep.
|
||||||
|
* `--display-failures-only`:
|
||||||
|
Only display casks that fail the audit. This is the default for formulae.
|
||||||
* `--skip-style`:
|
* `--skip-style`:
|
||||||
Skip running non-RuboCop style checks. Useful if you plan on running `brew style` separately. Enabled by default unless a formula is specified by name.
|
Skip running non-RuboCop style checks. Useful if you plan on running `brew style` separately. Enabled by default unless a formula is specified by name.
|
||||||
* `-D`, `--audit-debug`:
|
* `-D`, `--audit-debug`:
|
||||||
|
@ -1062,6 +1062,10 @@ Include the RuboCop cop name for each violation in the output\.
|
|||||||
Prefix every line of output with the file or formula name being audited, to make output easy to grep\.
|
Prefix every line of output with the file or formula name being audited, to make output easy to grep\.
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-\-display\-failures\-only\fR
|
||||||
|
Only display casks that fail the audit\. This is the default for formulae\.
|
||||||
|
.
|
||||||
|
.TP
|
||||||
\fB\-\-skip\-style\fR
|
\fB\-\-skip\-style\fR
|
||||||
Skip running non\-RuboCop style checks\. Useful if you plan on running \fBbrew style\fR separately\. Enabled by default unless a formula is specified by name\.
|
Skip running non\-RuboCop style checks\. Useful if you plan on running \fBbrew style\fR separately\. Enabled by default unless a formula is specified by name\.
|
||||||
.
|
.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user