aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike McQuaid2017-10-24 16:03:13 +0100
committerMike McQuaid2017-10-24 16:03:13 +0100
commitd067b5f4344b31beef8cf0adb494c819a0e337bf (patch)
tree1224f82bb5161347426e6d088b99885bcf3ed4b7
parentcd61430bad2581ad7c92c4037b0c5deab84b3693 (diff)
downloadbrew-d067b5f4344b31beef8cf0adb494c819a0e337bf.tar.bz2
lines_cop: fix clang detection.
We only care about e.g. `gcc`/`llvm-gcc`/`clang` being at the beginning of a `system` call and not anywhere within the string.
-rw-r--r--Library/Homebrew/rubocops/lines_cop.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb
index 9354f41f6..2b6268532 100644
--- a/Library/Homebrew/rubocops/lines_cop.rb
+++ b/Library/Homebrew/rubocops/lines_cop.rb
@@ -176,7 +176,7 @@ module RuboCop
# Avoid hard-coding compilers
find_every_method_call_by_name(body_node, :system).each do |method|
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|llvm-gcc|clang)\s?})
problem "Use \"\#{ENV.cc}\" instead of hard-coding \"#{match[2]}\""
elsif match = regex_match_group(param, %r{(/usr/bin/)?((g|llvm-g|clang)\+\+)\s?})
problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{match[2]}\""
@@ -185,9 +185,9 @@ module RuboCop
find_instance_method_call(body_node, "ENV", :[]=) do |method|
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|llvm-gcc|clang)\s?})
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|llvm-g|clang)\+\+)\s?})
problem "Use \"\#{ENV.cxx}\" instead of hard-coding \"#{match[2]}\""
end
end