mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Refactor ExplainFormatter a bit
				
					
				
			This commit is contained in:
		
							parent
							
								
									c9538220c6
								
							
						
					
					
						commit
						1718945523
					
				
					 1 changed files with 3 additions and 8 deletions
				
			
		| 
						 | 
					@ -4,8 +4,6 @@ module Ameba::Formatter
 | 
				
			||||||
  # A formatter that shows the detailed explanation of the issue at
 | 
					  # A formatter that shows the detailed explanation of the issue at
 | 
				
			||||||
  # a specific location.
 | 
					  # a specific location.
 | 
				
			||||||
  class ExplainFormatter
 | 
					  class ExplainFormatter
 | 
				
			||||||
    HEADING_MARKER = "## "
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    include Util
 | 
					    include Util
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    getter output : IO::FileDescriptor | IO::Memory
 | 
					    getter output : IO::FileDescriptor | IO::Memory
 | 
				
			||||||
| 
						 | 
					@ -64,10 +62,7 @@ module Ameba::Formatter
 | 
				
			||||||
        rule.name.colorize(:magenta),
 | 
					        rule.name.colorize(:magenta),
 | 
				
			||||||
        rule.severity.to_s.colorize(rule.severity.color),
 | 
					        rule.severity.to_s.colorize(rule.severity.color),
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					      output_paragraph rule.description
 | 
				
			||||||
      if rule.responds_to?(:description)
 | 
					 | 
				
			||||||
        output_paragraph rule.description
 | 
					 | 
				
			||||||
      end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      rule_doc = colorize_code_fences(rule.class.parsed_doc)
 | 
					      rule_doc = colorize_code_fences(rule.class.parsed_doc)
 | 
				
			||||||
      return unless rule_doc
 | 
					      return unless rule_doc
 | 
				
			||||||
| 
						 | 
					@ -84,7 +79,7 @@ module Ameba::Formatter
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private def output_title(title)
 | 
					    private def output_title(title)
 | 
				
			||||||
      output << HEADING_MARKER.colorize(:yellow)
 | 
					      output << "### ".colorize(:yellow)
 | 
				
			||||||
      output << title.upcase.colorize(:yellow)
 | 
					      output << title.upcase.colorize(:yellow)
 | 
				
			||||||
      output << "\n\n"
 | 
					      output << "\n\n"
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					@ -95,7 +90,7 @@ module Ameba::Formatter
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    private def output_paragraph(paragraph : Array)
 | 
					    private def output_paragraph(paragraph : Array)
 | 
				
			||||||
      paragraph.each do |line|
 | 
					      paragraph.each do |line|
 | 
				
			||||||
        output << ' ' << line << '\n'
 | 
					        output << "    " << line << '\n'
 | 
				
			||||||
      end
 | 
					      end
 | 
				
			||||||
      output << '\n'
 | 
					      output << '\n'
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue