mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Avoid one-letter names if possible
This commit is contained in:
		
							parent
							
								
									20935ae381
								
							
						
					
					
						commit
						0f893971dc
					
				
					 5 changed files with 18 additions and 18 deletions
				
			
		| 
						 | 
					@ -5,11 +5,11 @@ module Ameba::Formatter
 | 
				
			||||||
      output << "Disabled rules using inline directives: \n\n"
 | 
					      output << "Disabled rules using inline directives: \n\n"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      sources.each do |source|
 | 
					      sources.each do |source|
 | 
				
			||||||
        source.issues.select(&.disabled?).each do |e|
 | 
					        source.issues.select(&.disabled?).each do |issue|
 | 
				
			||||||
          next unless loc = e.location
 | 
					          next unless loc = issue.location
 | 
				
			||||||
 | 
					
 | 
				
			||||||
          output << "#{source.path}:#{loc.line_number}".colorize(:cyan)
 | 
					          output << "#{source.path}:#{loc.line_number}".colorize(:cyan)
 | 
				
			||||||
          output << " #{e.rule.name}\n"
 | 
					          output << " #{issue.rule.name}\n"
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,16 +3,16 @@ module Ameba::Formatter
 | 
				
			||||||
    @mutex = Mutex.new
 | 
					    @mutex = Mutex.new
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def source_finished(source : Source)
 | 
					    def source_finished(source : Source)
 | 
				
			||||||
      source.issues.each do |e|
 | 
					      source.issues.each do |issue|
 | 
				
			||||||
        next if e.disabled?
 | 
					        next if issue.disabled?
 | 
				
			||||||
        next if e.correctable? && config[:autocorrect]?
 | 
					        next if issue.correctable? && config[:autocorrect]?
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        next unless loc = e.location
 | 
					        next unless loc = issue.location
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        @mutex.synchronize do
 | 
					        @mutex.synchronize do
 | 
				
			||||||
          output.printf "%s:%d:%d: %s: [%s] %s\n",
 | 
					          output.printf "%s:%d:%d: %s: [%s] %s\n",
 | 
				
			||||||
            source.path, loc.line_number, loc.column_number, e.rule.severity.symbol,
 | 
					            source.path, loc.line_number, loc.column_number, issue.rule.severity.symbol,
 | 
				
			||||||
            e.rule.name, e.message.gsub('\n', " ")
 | 
					            issue.rule.name, issue.message.gsub('\n', " ")
 | 
				
			||||||
        end
 | 
					        end
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,8 +26,8 @@ module Ameba::Rule::Lint
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test(source, node : Crystal::StringInterpolation)
 | 
					    def test(source, node : Crystal::StringInterpolation)
 | 
				
			||||||
      node.expressions
 | 
					      node.expressions
 | 
				
			||||||
        .select { |e| !e.is_a?(Crystal::StringLiteral) && literal?(e) }
 | 
					        .select { |exp| !exp.is_a?(Crystal::StringLiteral) && literal?(exp) }
 | 
				
			||||||
        .each { |n| issue_for n, MSG }
 | 
					        .each { |exp| issue_for exp, MSG }
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,12 +36,12 @@ module Ameba::Rule::Lint
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private def string_coercion_nodes(node)
 | 
					    private def string_coercion_nodes(node)
 | 
				
			||||||
      node.expressions.select do |e|
 | 
					      node.expressions.select do |exp|
 | 
				
			||||||
        e.is_a?(Crystal::Call) &&
 | 
					        exp.is_a?(Crystal::Call) &&
 | 
				
			||||||
          e.name == "to_s" &&
 | 
					          exp.name == "to_s" &&
 | 
				
			||||||
          e.args.size.zero? &&
 | 
					          exp.args.size.zero? &&
 | 
				
			||||||
          e.named_args.nil? &&
 | 
					          exp.named_args.nil? &&
 | 
				
			||||||
          e.obj
 | 
					          exp.obj
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ module Ameba::Rule::Style
 | 
				
			||||||
      when Crystal::BinaryOp
 | 
					      when Crystal::BinaryOp
 | 
				
			||||||
        negated_condition?(node.left) || negated_condition?(node.right)
 | 
					        negated_condition?(node.left) || negated_condition?(node.right)
 | 
				
			||||||
      when Crystal::Expressions
 | 
					      when Crystal::Expressions
 | 
				
			||||||
        node.expressions.any? { |e| negated_condition?(e) }
 | 
					        node.expressions.any? { |exp| negated_condition?(exp) }
 | 
				
			||||||
      when Crystal::Not
 | 
					      when Crystal::Not
 | 
				
			||||||
        true
 | 
					        true
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue