diff options
| author | Gautham Goli | 2017-05-03 11:33:00 +0530 | 
|---|---|---|
| committer | Gautham Goli | 2017-05-03 14:49:23 +0530 | 
| commit | fed668b330e151bde493e004d7c6ca57df4e19ff (patch) | |
| tree | 5add603841e2d073c3fe2aaef677705a72d6c4e1 /Library/Homebrew/dev-cmd | |
| parent | c3330c289d0cc774b8154a0cee0f52fbd4b867aa (diff) | |
| download | brew-fed668b330e151bde493e004d7c6ca57df4e19ff.tar.bz2 | |
Add `--only-cops`,`--except-cops` options for brew style and simplify cop names
Diffstat (limited to 'Library/Homebrew/dev-cmd')
| -rw-r--r-- | Library/Homebrew/dev-cmd/audit.rb | 26 | 
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|  | 
