aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorMike McQuaid2017-07-02 14:45:29 +0100
committerGitHub2017-07-02 14:45:29 +0100
commit2b3717a5a0452271bb7dcfcdfa2680714ac99c2a (patch)
treeffb54dbcf971a4fd9fea527c439ca286010e9445 /Library
parenteb110e94f002966ffb241e49ca6154fdae601362 (diff)
parente6938d920165e3be872366216d618ca01da83fbb (diff)
downloadbrew-2b3717a5a0452271bb7dcfcdfa2680714ac99c2a.tar.bz2
Merge pull request #2842 from GauthamGoli/audit_only_cops_option
audit: Don't run audit methods when `--only-cops` option is passed
Diffstat (limited to 'Library')
-rw-r--r--Library/.rubocop.yml3
-rw-r--r--Library/Homebrew/cmd/style.rb6
-rw-r--r--Library/Homebrew/dev-cmd/audit.rb6
-rw-r--r--Library/Homebrew/rubocops.rb1
4 files changed, 13 insertions, 3 deletions
diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml
index 703912781..dbff189ef 100644
--- a/Library/.rubocop.yml
+++ b/Library/.rubocop.yml
@@ -33,6 +33,9 @@ FormulaAuditStrict/ComponentsRedundancy:
FormulaAudit/Homepage:
Enabled: true
+FormulaAudit/LegacyPatches:
+ Enabled: true
+
# `system` is a special case and aligns on second argument
Layout/AlignParameters:
Enabled: false
diff --git a/Library/Homebrew/cmd/style.rb b/Library/Homebrew/cmd/style.rb
index c6201e371..51937c3e5 100644
--- a/Library/Homebrew/cmd/style.rb
+++ b/Library/Homebrew/cmd/style.rb
@@ -94,7 +94,11 @@ module Homebrew
RuboCop::Cop::Cop.registry.departments.include?(cop.to_sym)
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
if files.nil?
diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb
index 5b2edfcf6..443a45816 100644
--- a/Library/Homebrew/dev-cmd/audit.rb
+++ b/Library/Homebrew/dev-cmd/audit.rb
@@ -75,16 +75,18 @@ 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 simultaneously!"
- elsif (!only_cops.empty? || !except_cops.empty?) && strict
- odie "--only-cops/--except-cops and --strict cannot be used simultaneously"
+ elsif (!only_cops.empty? || !except_cops.empty?) && (strict || ARGV.value("only"))
+ odie "--only-cops/--except-cops and --strict/--only cannot be used simultaneously"
end
options = { fix: ARGV.flag?("--fix"), realpath: true }
if !only_cops.empty?
options[:only_cops] = only_cops
+ ARGV.push("--only=style")
elsif !except_cops.empty?
options[:except_cops] = except_cops
elsif !strict
diff --git a/Library/Homebrew/rubocops.rb b/Library/Homebrew/rubocops.rb
index 4710654fa..e27f91867 100644
--- a/Library/Homebrew/rubocops.rb
+++ b/Library/Homebrew/rubocops.rb
@@ -6,3 +6,4 @@ require_relative "./rubocops/homepage_cop"
require_relative "./rubocops/text_cop"
require_relative "./rubocops/caveats_cop"
require_relative "./rubocops/checksum_cop"
+require_relative "./rubocops/legacy_patches_cop"