aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd/audit.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/dev-cmd/audit.rb')
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb26
1 files changed, 15 insertions, 11 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index e96d4cf4c..013c1355a 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -1,4 +1,4 @@
-#: * `audit` [`--strict`] [`--fix`] [`--online`] [`--new-formula`] [`--display-cop-names`] [`--display-filename`] [`--only=`<method>|`--except=`<method] [<formulae>]:
+#: * `audit` [`--strict`] [`--fix`] [`--online`] [`--new-formula`] [`--display-cop-names`] [`--display-filename`] [`--only=`<method>|`--except=`<method>] [`--only-cops=`[COP1,COP2..]|`--except-cops=`[COP1,COP2..]] [<formulae>]:
#: Check <formulae> for Homebrew coding style violations. This should be
#: run before submitting a new formula.
#:
@@ -27,9 +27,9 @@
#:
#: If `--except` is passed, the methods named `audit_<method>` will not be run.
#:
-#: If `--only-cops` is passed, only the mentioned cops' violations would be checked.
+#: If `--only-cops` is passed, only the given Rubocop cop(s)' violations would be checked.
#:
-#: If `--except-cops` is passed, the mentioned cops' checks would be skipped.
+#: If `--except-cops` is passed, the given Rubocop cop(s)' checks would be skipped.
#:
#: `audit` exits with a non-zero status if any errors are found. This is useful,
#: for instance, for implementing pre-commit hooks.
@@ -76,17 +76,21 @@ module Homebrew
only_cops = ARGV.value("only-cops").to_s.split(",")
except_cops = ARGV.value("except-cops").to_s.split(",")
if !only_cops.empty? && !except_cops.empty?
- odie "--only-cops and --except-cops cannot be used simulataneously!"
+ odie "--only-cops and --except-cops cannot be used simultaneously!"
+ elsif (!only_cops.empty? || !except_cops.empty?) && strict
+ odie "--only-cops/--except-cops and --strict cannot be used simultaneously"
end
- if strict
- options = { fix: ARGV.flag?("--fix"), realpath: true }
- else
- options = { fix: ARGV.flag?("--fix"), realpath: true, exclude: :FormulaAuditStrict }
+ options = { fix: ARGV.flag?("--fix"), realpath: true }
+
+ if !only_cops.empty?
+ options[:only_cops] = only_cops
+ elsif !except_cops.empty?
+ options[:except_cops] = except_cops
+ elsif !strict
+ options[:except_cops] = [:FormulaAuditStrict]
end
- options[:only] = only_cops unless only_cops.empty?
- options[:except] = except_cops unless except_cops.empty?
# Check style in a single batch run up front for performance
style_results = check_style_json(files, options)
@@ -1272,7 +1276,7 @@ class FormulaAuditor
only_audits = ARGV.value("only").to_s.split(",")
except_audits = ARGV.value("except").to_s.split(",")
if !only_audits.empty? && !except_audits.empty?
- odie "--only and --except cannot be used simulataneously!"
+ odie "--only and --except cannot be used simultaneously!"
end
methods.map(&:to_s).grep(/^audit_/).each do |audit_method_name|