aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/dev-cmd/audit.rb
diff options
context:
space:
mode:
authorGautham Goli2017-04-23 04:09:13 +0530
committerGautham Goli2017-05-02 23:26:12 +0530
commitc3330c289d0cc774b8154a0cee0f52fbd4b867aa (patch)
tree80ed27ae97960cc9d99984675f2d7ea4b6c030d0 /Library/Homebrew/dev-cmd/audit.rb
parenta4568a8697e9ff4a3d8f62e37ee929e22f10d07d (diff)
downloadbrew-c3330c289d0cc774b8154a0cee0f52fbd4b867aa.tar.bz2
Add `--only-cops`,`--except-cops` options for brew audit
Also refactor audit cops into two "departments" - FormulaAudit - FormulaAuditStrict
Diffstat (limited to 'Library/Homebrew/dev-cmd/audit.rb')
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb22
1 files changed, 16 insertions, 6 deletions
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 2f4b37096..e96d4cf4c 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -27,6 +27,10 @@
#:
#: 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 `--except-cops` is passed, the mentioned cops' 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.
@@ -69,16 +73,22 @@ module Homebrew
files = ARGV.resolved_formulae.map(&:path)
end
+ 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!"
+ end
+
if strict
options = { fix: ARGV.flag?("--fix"), realpath: true }
- # Check style in a single batch run up front for performance
- style_results = check_style_json(files, options)
+ else
+ options = { fix: ARGV.flag?("--fix"), realpath: true, exclude: :FormulaAuditStrict }
end
- if !strict
- options = { fix: ARGV.flag?("--fix"), realpath: true, only: :Homebrew }
- style_results = check_style_json(files, options)
- 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)
ff.each do |f|
options = { new_formula: new_formula, strict: strict, online: online }