lines_cop: Fix detection of negated expression
This commit is contained in:
		
							parent
							
								
									0cec599b28
								
							
						
					
					
						commit
						09326909af
					
				@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user