aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/rubocops/extend/formula_cop.rb6
-rw-r--r--Library/Homebrew/rubocops/lines_cop.rb4
2 files changed, 6 insertions, 4 deletions
diff --git a/Library/Homebrew/rubocops/extend/formula_cop.rb b/Library/Homebrew/rubocops/extend/formula_cop.rb
index 2e9a7657e..1e7160bbd 100644
--- a/Library/Homebrew/rubocops/extend/formula_cop.rb
+++ b/Library/Homebrew/rubocops/extend/formula_cop.rb
@@ -316,8 +316,10 @@ module RuboCop
end
# Check if negation is present in the given node
- def negated?(node)
- method_called?(node, :!)
+ def expression_negated?(node)
+ return false if node.parent.nil?
+ return false unless node.parent.method_name.equal?(:!)
+ offending_node(node.parent)
end
# Return all the caveats' string nodes in an array
diff --git a/Library/Homebrew/rubocops/lines_cop.rb b/Library/Homebrew/rubocops/lines_cop.rb
index c5f2e7585..e8aa6a53f 100644
--- a/Library/Homebrew/rubocops/lines_cop.rb
+++ b/Library/Homebrew/rubocops/lines_cop.rb
@@ -94,12 +94,12 @@ module RuboCop
end
find_instance_method_call(body_node, :build, :with?) do |method|
- next unless negated?(method.parent)
+ next unless expression_negated?(method)
problem "Don't negate 'build.with?': use 'build.without?'"
end
find_instance_method_call(body_node, :build, :without?) do |method|
- next unless negated?(method.parent)
+ next unless expression_negated?(method)
problem "Don't negate 'build.without?': use 'build.with?'"
end