brew style: assume files under Library are no-formulae
This commit is contained in:
parent
3081390ff8
commit
c0b7aa00e4
@ -57,12 +57,24 @@ module Homebrew
|
|||||||
args << "--only" << cops_to_include.join(",")
|
args << "--only" << cops_to_include.join(",")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
has_non_formula = Array(files).any? do |file|
|
||||||
|
File.expand_path(file).start_with? HOMEBREW_LIBRARY_PATH
|
||||||
|
end
|
||||||
|
config_file = if files.nil? || has_non_formula
|
||||||
|
if ARGV.include?("--rspec")
|
||||||
|
HOMEBREW_LIBRARY_PATH/".rubocop-rspec.yml"
|
||||||
|
else
|
||||||
|
HOMEBREW_LIBRARY_PATH/".rubocop.yml"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
HOMEBREW_LIBRARY/".rubocop_audit.yml"
|
||||||
|
end
|
||||||
|
|
||||||
|
args << "--config" << config_file
|
||||||
|
|
||||||
if files.nil?
|
if files.nil?
|
||||||
config_file = ARGV.include?("--rspec") ? ".rubocop-rspec.yml" : ".rubocop.yml"
|
|
||||||
args << "--config" << HOMEBREW_LIBRARY_PATH/config_file
|
|
||||||
args << HOMEBREW_LIBRARY_PATH
|
args << HOMEBREW_LIBRARY_PATH
|
||||||
else
|
else
|
||||||
args << "--config" << HOMEBREW_LIBRARY/".rubocop_audit.yml"
|
|
||||||
args += files
|
args += files
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -31,4 +31,18 @@ describe "brew style" do
|
|||||||
.to include("Extra empty line detected at class body beginning.")
|
.to include("Extra empty line detected at class body beginning.")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "Homebrew::check_style_and_print" do
|
||||||
|
let(:dir) { mktmpdir }
|
||||||
|
|
||||||
|
it "returns false for conforming file with only audit-level violations" do
|
||||||
|
# This file is known to use non-rocket hashes and other things that trigger audit,
|
||||||
|
# but not regular, cop violations
|
||||||
|
target_file = HOMEBREW_LIBRARY_PATH/"utils.rb"
|
||||||
|
|
||||||
|
rubocop_result = Homebrew::Style.check_style_and_print([target_file])
|
||||||
|
|
||||||
|
expect(rubocop_result).to eq false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user