From 3b9a8cb8c1b3a662cf1c279a05be5eefb5d03590 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 14 Apr 2020 11:59:41 +0100 Subject: [PATCH] rubocops/lines: fix rule. This stops stuff like `clang=1` from being matched incorrectly. --- Library/Homebrew/rubocops/lines.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/rubocops/lines.rb b/Library/Homebrew/rubocops/lines.rb index dc17ec2ef1..5ed08a2e03 100644 --- a/Library/Homebrew/rubocops/lines.rb +++ b/Library/Homebrew/rubocops/lines.rb @@ -240,18 +240,18 @@ 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"]?}) + 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 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