diff options
| author | Gautham Goli | 2017-08-15 00:36:37 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-08-15 00:36:37 +0530 |
| commit | 2f94d5f499bca6bbab238bb6536f05195b358159 (patch) | |
| tree | 1d13315409edb02a7327096410bb3f04e0aad6f4 /Library | |
| parent | 3fc6cc1a3a4b8f1b7ca42dc0a7dd7cf8fad91b18 (diff) | |
| download | brew-2f94d5f499bca6bbab238bb6536f05195b358159.tar.bz2 | |
add test for ARGV.include?
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/rubocops/lines_cop.rb | 12 | ||||
| -rw-r--r-- | Library/Homebrew/test/rubocops/lines_cop_spec.rb | 24 |
2 files changed, 30 insertions, 6 deletions
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb index 7ee1833a1..0ba3c6bc5 100644 --- a/Library/Homebrew/rubocops/lines_cop.rb +++ b/Library/Homebrew/rubocops/lines_cop.rb @@ -167,12 +167,12 @@ module RuboCop problem "Use `depends_on :fortran` instead of `ENV.fortran`" end - # find_instance_method_call(body_node, :ARGV, :include?) do |m| - # param = parameters(m).first - # next unless match = regex_match_group(param, %r{--(HEAD|devel)}) - # problem "Use \"if build.#{match[1].downcase}?\" instead" - # end - # + find_instance_method_call(body_node, "ARGV", :include?) do |m| + param = parameters(m).first + next unless match = regex_match_group(param, %r{--(HEAD|devel)}) + problem "Use \"if build.#{match[1].downcase}?\" instead" + end + # find_const(body_node, :MACOS_VERSION) do # problem "Use MacOS.version instead of MACOS_VERSION" # end diff --git a/Library/Homebrew/test/rubocops/lines_cop_spec.rb b/Library/Homebrew/test/rubocops/lines_cop_spec.rb index 1b23cca83..44f22df62 100644 --- a/Library/Homebrew/test/rubocops/lines_cop_spec.rb +++ b/Library/Homebrew/test/rubocops/lines_cop_spec.rb @@ -1165,6 +1165,30 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do end end + it "with ARGV.include? (--HEAD)" do + source = <<-EOS.undent + class Foo < Formula + desc "foo" + url 'http://example.com/foo-1.0.tgz' + test do + head = ARGV.include? "--HEAD" + end + end + EOS + + expected_offenses = [{ message: "Use \"if build.head?\" instead", + severity: :convention, + line: 5, + column: 26, + source: source }] + + inspect_source(cop, source) + + expected_offenses.zip(cop.offenses).each do |expected, actual| + expect_offense(expected, actual) + end + end + end def expect_offense(expected, actual) expect(actual.message).to eq(expected[:message]) |
