diff options
| author | Gautham Goli | 2017-10-25 16:05:29 +0530 |
|---|---|---|
| committer | Gautham Goli | 2017-10-26 15:35:14 +0530 |
| commit | 09326909afa83893fa92edfd47820e736f5bf334 (patch) | |
| tree | a57f13b6ae0effe85a3a8dbdceb745be04e83856 /Library | |
| parent | 0cec599b28c23fb6bade4202fd455d54c07dfd27 (diff) | |
| download | brew-09326909afa83893fa92edfd47820e736f5bf334.tar.bz2 | |
lines_cop: Fix detection of negated expression
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/rubocops/extend/formula_cop.rb | 6 | ||||
| -rw-r--r-- | Library/Homebrew/rubocops/lines_cop.rb | 4 |
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 |
