Fix test failures
This commit is contained in:
parent
8c5e6e10a7
commit
86161e8c32
@ -617,6 +617,8 @@ module RuboCop
|
||||
|
||||
# Avoid hard-coding compilers
|
||||
find_every_method_call_by_name(body_node, :system).each do |method|
|
||||
next if @formula_name == "bazel" # TODO: Remove shim bypass in bazel.
|
||||
|
||||
param = parameters(method).first
|
||||
if (match = regex_match_group(param, %r{^(/usr/bin/)?(gcc|clang|cc|c[89]9)(\s|$)}))
|
||||
problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{match[2]}\""
|
||||
@ -626,6 +628,8 @@ module RuboCop
|
||||
end
|
||||
|
||||
find_instance_method_call(body_node, "ENV", :[]=) do |method|
|
||||
next if @formula_name == "bazel" # TODO: Remove shim bypass in bazel.
|
||||
|
||||
param = parameters(method)[1]
|
||||
if (match = regex_match_group(param, %r{^(/usr/bin/)?(gcc|clang|cc|c[89]9)(\s|$)}))
|
||||
problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{match[2]}\""
|
||||
|
||||
@ -255,14 +255,14 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
|
||||
RUBY
|
||||
end
|
||||
|
||||
it "reports an offense when a hard-coded `llvm-g++` is set as COMPILER_PATH" do
|
||||
it "reports an offense when a hard-coded `c++` is set as COMPILER_PATH" do
|
||||
expect_offense(<<~'RUBY')
|
||||
class Foo < Formula
|
||||
desc "foo"
|
||||
url 'https://brew.sh/foo-1.0.tgz'
|
||||
def install
|
||||
ENV["COMPILER_PATH"] = "/usr/bin/llvm-g++"
|
||||
^^^^^^^^^^^^^^^^^^^ Use "#{ENV.cxx}" instead of hard-coding "llvm-g++"
|
||||
ENV["COMPILER_PATH"] = "/usr/bin/c++"
|
||||
^^^^^^^^^^^^^^ Use "#{ENV.cxx}" instead of hard-coding "c++"
|
||||
end
|
||||
end
|
||||
RUBY
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user