Skip to content
Snippets Groups Projects
Commit 2f94d5f4 authored by Gautham Goli's avatar Gautham Goli
Browse files

add test for ARGV.include?

parent 3fc6cc1a
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment