Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: better handle HOMEBREW_REPOSITORY. #12154

Merged
merged 1 commit into from
Sep 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 8 additions & 13 deletions Library/Homebrew/style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def check_style_impl(files, output_type,
display_cop_names: false,
reset_cache: false,
debug: false, verbose: false)
raise ArgumentError, "Invalid output type: #{output_type.inspect}" unless [:print, :json].include?(output_type)
raise ArgumentError, "Invalid output type: #{output_type.inspect}" if [:print, :json].exclude?(output_type)

shell_files, ruby_files =
Array(files).map(&method(:Pathname))
Expand Down Expand Up @@ -97,7 +97,7 @@ def run_rubocop(files, output_type,
--force-exclusion
]
args << if fix
"-A"
"--auto-correct-all"
else
"--parallel"
end
Expand Down Expand Up @@ -125,24 +125,19 @@ def run_rubocop(files, output_type,
args << "--only" << cops_to_include.join(",")
end

has_non_formula = files.any? do |file|
File.expand_path(file).start_with? HOMEBREW_LIBRARY_PATH
end

if files.any? && !has_non_formula
config = if files.first && File.exist?("#{files.first}/spec")
files&.map!(&:expand_path)
if files.blank? || files == [HOMEBREW_REPOSITORY]
files = [HOMEBREW_LIBRARY_PATH]
elsif files.none? { |f| f.to_s.start_with? HOMEBREW_LIBRARY_PATH }
config = if files.any? { |f| (f/"spec").exist? }
HOMEBREW_LIBRARY/".rubocop_rspec.yml"
else
HOMEBREW_LIBRARY/".rubocop.yml"
end
args << "--config" << config
end

if files.blank?
args << HOMEBREW_LIBRARY_PATH
else
args += files
end
args += files

cache_env = { "XDG_CACHE_HOME" => "#{HOMEBREW_CACHE}/style" }

Expand Down