mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Don’t allocate the array on every call
This commit is contained in:
		
							parent
							
								
									5e58a60ade
								
							
						
					
					
						commit
						fd4b2f309c
					
				
					 1 changed files with 3 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -25,10 +25,11 @@ module Ameba::Rule::Lint
 | 
			
		|||
      description "Disallows comparison to booleans"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    MSG = "Comparison to a boolean is pointless"
 | 
			
		||||
    MSG      = "Comparison to a boolean is pointless"
 | 
			
		||||
    OP_NAMES = %w(== != ===)
 | 
			
		||||
 | 
			
		||||
    def test(source, node : Crystal::Call)
 | 
			
		||||
      comparison = %w(== != ===).includes?(node.name)
 | 
			
		||||
      comparison = node.name.in?(OP_NAMES)
 | 
			
		||||
      to_boolean = node.args.first?.try &.is_a?(Crystal::BoolLiteral) ||
 | 
			
		||||
                   node.obj.is_a?(Crystal::BoolLiteral)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue