diff options
| author | Gautham Goli | 2017-08-15 00:05:50 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-08-15 00:27:09 +0530 |
| commit | cfc423e1839442f605072db14aac42f6f5fa6174 (patch) | |
| tree | 8ac198886cfc56e3da87cb5ab365c5cd15ab7ba0 /Library/Homebrew/rubocops | |
| parent | d2a7314f538f919e9b09e4b27c1f86b7d3d2eda2 (diff) | |
| download | brew-cfc423e1839442f605072db14aac42f6f5fa6174.tar.bz2 | |
add tests for dependencies
Diffstat (limited to 'Library/Homebrew/rubocops')
| -rw-r--r-- | Library/Homebrew/rubocops/lines_cop.rb | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb index e20fa9f8b..0c465f9f5 100644 --- a/Library/Homebrew/rubocops/lines_cop.rb +++ b/Library/Homebrew/rubocops/lines_cop.rb @@ -148,13 +148,15 @@ module RuboCop problem "Use ENV instead of invoking '#{match[1]}' to modify the environment" end - # find_every_method_call_by_name(body_node, :depends_on).each do |m| - # next unless modifier?(m) - # dep, option = hash_dep(m) - # next if dep.nil? || option.nil? - # problem "Dependency #{string_content(dep)} should not use option #{string_content(option)}" - # end - # + find_every_method_call_by_name(body_node, :depends_on).each do |m| + next if modifier?(m.parent) + param = parameters(m).first + dep, option = hash_dep(param) + next if dep.nil? || option.nil? + offending_node(param) + problem "Dependency #{string_content(dep)} should not use option #{string_content(option)}" + end + # find_instance_method_call(body_node, :version, :==) do |m| # next unless parameters_passed?(m, "HEAD") # problem "Use 'build.head?' instead of inspecting 'version'" @@ -328,6 +330,7 @@ module RuboCop end def modifier?(node) + return false unless node.if_type? node.modifier_form? end @@ -340,9 +343,9 @@ module RuboCop EOS # Match depends_on with hash as argument - def_node_search :hash_dep, <<-EOS.undent - {$(hash (pair $(str _) $(str _))) - $(hash (pair $(str _) (array $(str _) ...)))} + def_node_matcher :hash_dep, <<-EOS.undent + {(hash (pair $(str _) $(str _))) + (hash (pair $(str _) (array $(str _) ...)))} EOS def_node_matcher :destructure_hash, <<-EOS.undent |
