style: chdir before running rubocop
This commit is contained in:
parent
d7266570a5
commit
1de1be8937
@ -327,6 +327,11 @@ Style/Documentation:
|
|||||||
- "**/{Formula,Casks}/**/*.rb"
|
- "**/{Formula,Casks}/**/*.rb"
|
||||||
- "**/*.rbi"
|
- "**/*.rbi"
|
||||||
|
|
||||||
|
# This is impossible to fix if the line exceeds the maximum length.
|
||||||
|
Style/EmptyMethod:
|
||||||
|
Exclude:
|
||||||
|
- "**/*.rbi"
|
||||||
|
|
||||||
# This is quite a large change, so don't enforce this yet for formulae.
|
# This is quite a large change, so don't enforce this yet for formulae.
|
||||||
# We should consider doing so in the future, but be aware of the impact on third-party taps.
|
# We should consider doing so in the future, but be aware of the impact on third-party taps.
|
||||||
Style/FetchEnvVar:
|
Style/FetchEnvVar:
|
||||||
|
|||||||
@ -149,12 +149,17 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
files&.map!(&:expand_path)
|
files&.map!(&:expand_path)
|
||||||
|
base_dir = Dir.pwd
|
||||||
if files.blank? || files == [HOMEBREW_REPOSITORY]
|
if files.blank? || files == [HOMEBREW_REPOSITORY]
|
||||||
files = [HOMEBREW_LIBRARY_PATH]
|
files = [HOMEBREW_LIBRARY_PATH]
|
||||||
|
base_dir = HOMEBREW_LIBRARY_PATH
|
||||||
elsif files.any? { |f| f.to_s.start_with?(HOMEBREW_REPOSITORY/"docs") || (f.basename.to_s == "docs") }
|
elsif files.any? { |f| f.to_s.start_with?(HOMEBREW_REPOSITORY/"docs") || (f.basename.to_s == "docs") }
|
||||||
args << "--config" << (HOMEBREW_REPOSITORY/"docs/docs_rubocop_style.yml")
|
args << "--config" << (HOMEBREW_REPOSITORY/"docs/docs_rubocop_style.yml")
|
||||||
elsif files.none? { |f| f.to_s.start_with? HOMEBREW_LIBRARY_PATH }
|
elsif files.any? { |f| f.to_s.start_with? HOMEBREW_LIBRARY_PATH }
|
||||||
|
base_dir = HOMEBREW_LIBRARY_PATH
|
||||||
|
else
|
||||||
args << "--config" << (HOMEBREW_LIBRARY/".rubocop.yml")
|
args << "--config" << (HOMEBREW_LIBRARY/".rubocop.yml")
|
||||||
|
base_dir = HOMEBREW_LIBRARY if files.any? { |f| f.to_s.start_with? HOMEBREW_LIBRARY }
|
||||||
end
|
end
|
||||||
|
|
||||||
args += files
|
args += files
|
||||||
@ -174,14 +179,17 @@ module Homebrew
|
|||||||
|
|
||||||
args << "--color" if Tty.color?
|
args << "--color" if Tty.color?
|
||||||
|
|
||||||
system cache_env, *ruby_args, "--", RUBOCOP, *args
|
system cache_env, *ruby_args, "--", RUBOCOP, *args, chdir: base_dir
|
||||||
$CHILD_STATUS.success?
|
$CHILD_STATUS.success?
|
||||||
when :json
|
when :json
|
||||||
result = system_command ruby_args.shift,
|
result = system_command ruby_args.shift,
|
||||||
args: [*ruby_args, "--", RUBOCOP, "--format", "json", *args],
|
args: [*ruby_args, "--", RUBOCOP, "--format", "json", *args],
|
||||||
env: cache_env
|
env: cache_env,
|
||||||
|
chdir: base_dir
|
||||||
json = json_result!(result)
|
json = json_result!(result)
|
||||||
json["files"]
|
json["files"].each do |file|
|
||||||
|
file["path"] = File.absolute_path(file["path"], base_dir)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user