diff options
| author | Mike McQuaid | 2017-10-26 15:28:40 +0100 |
|---|---|---|
| committer | GitHub | 2017-10-26 15:28:40 +0100 |
| commit | 40b212322ce4b248fce05a376c041499e78570d8 (patch) | |
| tree | cd8d9f644b15bb654194f91253a147321d9aadd3 /Library | |
| parent | 4d02b96c679edaf8e16dcec1a69ef9fceaee9eb8 (diff) | |
| parent | 09326909afa83893fa92edfd47820e736f5bf334 (diff) | |
| download | brew-40b212322ce4b248fce05a376c041499e78570d8.tar.bz2 | |
Merge pull request #3366 from GauthamGoli/lines-cop-false-positives-fix
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 |
