audit: Don't run audit methods when --only-cops is passed

This commit is contained in:
Gautham Goli 2017-06-30 10:58:24 +05:30
parent 0077e4f20e
commit 8c167b23cc
2 changed files with 9 additions and 3 deletions

View File

@ -94,7 +94,11 @@ module Homebrew
RuboCop::Cop::Cop.registry.departments.include?(cop.to_sym) RuboCop::Cop::Cop.registry.departments.include?(cop.to_sym)
end end
args << "--only" << cops_to_include.join(",") unless cops_to_include.empty? if cops_to_include.empty?
odie "RuboCops #{options[:only_cops].join(",")} were not found"
end
args << "--only" << cops_to_include.join(",")
end end
if files.nil? if files.nil?

View File

@ -75,16 +75,18 @@ module Homebrew
only_cops = ARGV.value("only-cops").to_s.split(",") only_cops = ARGV.value("only-cops").to_s.split(",")
except_cops = ARGV.value("except-cops").to_s.split(",") except_cops = ARGV.value("except-cops").to_s.split(",")
if !only_cops.empty? && !except_cops.empty? if !only_cops.empty? && !except_cops.empty?
odie "--only-cops and --except-cops cannot be used simultaneously!" odie "--only-cops and --except-cops cannot be used simultaneously!"
elsif (!only_cops.empty? || !except_cops.empty?) && strict elsif (!only_cops.empty? || !except_cops.empty?) && (strict || ARGV.value("only"))
odie "--only-cops/--except-cops and --strict cannot be used simultaneously" odie "--only-cops/--except-cops and --strict/--only cannot be used simultaneously"
end end
options = { fix: ARGV.flag?("--fix"), realpath: true } options = { fix: ARGV.flag?("--fix"), realpath: true }
if !only_cops.empty? if !only_cops.empty?
options[:only_cops] = only_cops options[:only_cops] = only_cops
ARGV.push("--only=style")
elsif !except_cops.empty? elsif !except_cops.empty?
options[:except_cops] = except_cops options[:except_cops] = except_cops
elsif !strict elsif !strict