rubocops/lines: update hard-coded compiler check
1. `llvm-g{cc,++}` has been gone for a long time. We don't need to check
for this anymore.
2. Also check for calling the compiler as `cc`, `c89`, `c99`, or `c++`.
This commit is contained in:
parent
462c69d3d5
commit
8c5e6e10a7
@ -618,18 +618,18 @@ module RuboCop
|
|||||||
# Avoid hard-coding compilers
|
# Avoid hard-coding compilers
|
||||||
find_every_method_call_by_name(body_node, :system).each do |method|
|
find_every_method_call_by_name(body_node, :system).each do |method|
|
||||||
param = parameters(method).first
|
param = parameters(method).first
|
||||||
if (match = regex_match_group(param, %r{^(/usr/bin/)?(gcc|llvm-gcc|clang)(\s|$)}))
|
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]}\""
|
problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{match[2]}\""
|
||||||
elsif (match = regex_match_group(param, %r{^(/usr/bin/)?((g|llvm-g|clang)\+\+)(\s|$)}))
|
elsif (match = regex_match_group(param, %r{^(/usr/bin/)?((g|clang|c)\+\+)(\s|$)}))
|
||||||
problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{match[2]}\""
|
problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{match[2]}\""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
find_instance_method_call(body_node, "ENV", :[]=) do |method|
|
find_instance_method_call(body_node, "ENV", :[]=) do |method|
|
||||||
param = parameters(method)[1]
|
param = parameters(method)[1]
|
||||||
if (match = regex_match_group(param, %r{^(/usr/bin/)?(gcc|llvm-gcc|clang)(\s|$)}))
|
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]}\""
|
problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{match[2]}\""
|
||||||
elsif (match = regex_match_group(param, %r{^(/usr/bin/)?((g|llvm-g|clang)\+\+)(\s|$)}))
|
elsif (match = regex_match_group(param, %r{^(/usr/bin/)?((g|clang|c)\+\+)(\s|$)}))
|
||||||
problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{match[2]}\""
|
problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{match[2]}\""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user