add tests for vendored deps
This commit is contained in:
parent
063cbe7acd
commit
64a929184a
@ -135,14 +135,13 @@ module RuboCop
|
|||||||
problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[2].downcase}}\""
|
problem "\"\#\{prefix}#{match[1]}\" should be \"\#{#{match[2].downcase}}\""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
find_every_method_call_by_name(body_node, :depends_on).each do |m|
|
||||||
|
key, value = destructure_hash(parameters(m).first)
|
||||||
|
next if (key.nil? || value.nil?)
|
||||||
|
next unless match = regex_match_group(value, %r{(lua|perl|python|ruby)(\d*)})
|
||||||
|
problem "#{match[1]} modules should be vendored rather than use deprecated #{m.source}`"
|
||||||
|
end
|
||||||
|
|
||||||
# find_every_method_call_by_name(body_node, :depends_on) do |m|
|
|
||||||
# key, value = destructure_hash(paramters(m).first)
|
|
||||||
# next unless key.str_type?
|
|
||||||
# next unless match = regex_match_group(value, %r{(lua|perl|python|ruby)(\d*)})
|
|
||||||
# problem "#{match[1]} modules should be vendored rather than use deprecated #{m.source}`"
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# find_every_method_call_by_name(body_node, :system).each do |m|
|
# find_every_method_call_by_name(body_node, :system).each do |m|
|
||||||
# next unless match = regex_match_group(parameters(m).first, %r{(env|export)(\s+)?})
|
# next unless match = regex_match_group(parameters(m).first, %r{(env|export)(\s+)?})
|
||||||
# problem "Use ENV instead of invoking '#{match[1]}' to modify the environment"
|
# problem "Use ENV instead of invoking '#{match[1]}' to modify the environment"
|
||||||
@ -345,8 +344,8 @@ module RuboCop
|
|||||||
$(hash (pair $(str _) (array $(str _) ...)))}
|
$(hash (pair $(str _) (array $(str _) ...)))}
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
def_node_search :destructure_hash, <<-EOS.undent
|
def_node_matcher :destructure_hash, <<-EOS.undent
|
||||||
(hash (pair $_ $_))
|
(hash (pair $(str _) $(sym _)))
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
def_node_search :formula_path_strings, <<-EOS.undent
|
def_node_search :formula_path_strings, <<-EOS.undent
|
||||||
|
|||||||
@ -1051,6 +1051,28 @@ describe RuboCop::Cop::FormulaAudit::Miscellaneous do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "with dependecies which have to vendored" do
|
||||||
|
source = <<-EOS.undent
|
||||||
|
class Foo < Formula
|
||||||
|
desc "foo"
|
||||||
|
url 'http://example.com/foo-1.0.tgz'
|
||||||
|
depends_on "lpeg" => :lua51
|
||||||
|
end
|
||||||
|
EOS
|
||||||
|
|
||||||
|
expected_offenses = [{ message: "lua modules should be vendored rather than use deprecated depends_on \"lpeg\" => :lua51`",
|
||||||
|
severity: :convention,
|
||||||
|
line: 4,
|
||||||
|
column: 24,
|
||||||
|
source: source }]
|
||||||
|
|
||||||
|
inspect_source(cop, source)
|
||||||
|
|
||||||
|
expected_offenses.zip(cop.offenses).each do |expected, actual|
|
||||||
|
expect_offense(expected, actual)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
def expect_offense(expected, actual)
|
def expect_offense(expected, actual)
|
||||||
expect(actual.message).to eq(expected[:message])
|
expect(actual.message).to eq(expected[:message])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user