diff options
| author | Gautham Goli | 2017-08-14 02:14:20 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-08-14 02:14:20 +0530 |
| commit | e14fedd1b35480ea3707689db044140d18662b9c (patch) | |
| tree | 7f50c9888792b9d2cbd00e137d489004e47e08d1 /Library/Homebrew/rubocops | |
| parent | ec2b0df10e62152529386cf2a696f9aaece405ea (diff) | |
| download | brew-e14fedd1b35480ea3707689db044140d18662b9c.tar.bz2 | |
Add test for negated build.with?
Diffstat (limited to 'Library/Homebrew/rubocops')
| -rw-r--r-- | Library/Homebrew/rubocops/extend/formula_cop.rb | 8 | ||||
| -rw-r--r-- | Library/Homebrew/rubocops/lines_cop.rb | 11 |
2 files changed, 12 insertions, 7 deletions
diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb index cb404046c..94952d1f5 100644 --- a/Library/Homebrew/rubocops/extend/formula_cop.rb +++ b/Library/Homebrew/rubocops/extend/formula_cop.rb @@ -252,11 +252,15 @@ module RuboCop end # Check if method_name is called among the direct children nodes in the given node + # Check if the node itself is the method def method_called?(node, method_name) + if node.send_type? && node.method_name == method_name + offending_node(node) + return true + end node.each_child_node(:send) do |call_node| next unless call_node.method_name == method_name - @offensive_node = call_node - @offense_source_range = call_node.source_range + offending_node(call_node) return true end false diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb index 2b146b79e..4c82b42cf 100644 --- a/Library/Homebrew/rubocops/lines_cop.rb +++ b/Library/Homebrew/rubocops/lines_cop.rb @@ -287,11 +287,11 @@ module RuboCop problem "Use if #{correct} instead of unless #{m.source}" end - # find_instance_method_call(body_node, :build, :with?) do |m| - # next unless negation?(m) - # problem "Don't negate 'build.with?': use 'build.without?'" - # end - # + find_instance_method_call(body_node, :build, :with?) do |m| + next unless method_called?(m.parent, :!) + problem "Don't negate 'build.with?': use 'build.without?'" + end + # find_instance_method_call(body_node, :build, :without?) do |m| # next unless negation?(m) # problem "Don't negate 'build.without?': use 'build.with?'" @@ -324,6 +324,7 @@ module RuboCop end def unless_modifier?(node) + return false unless node.if_type? node.modifier_form? && node.unless? end |
