mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Merge pull request #311 from crystal-ameba/Sija/add-severity-color
Add `Severity#color`
This commit is contained in:
		
						commit
						20935ae381
					
				
					 2 changed files with 16 additions and 1 deletions
				
			
		|  | @ -49,7 +49,7 @@ module Ameba::Formatter | |||
|             issue.rule.severity.symbol, | ||||
|             issue.rule.name, | ||||
|             issue.message, | ||||
|           }).colorize(:red) | ||||
|           }).colorize(issue.rule.severity.color) | ||||
| 
 | ||||
|           if show_affected_code && (code = affected_code(issue)) | ||||
|             output << code.colorize(:default) | ||||
|  |  | |||
|  | @ -1,3 +1,5 @@ | |||
| require "colorize" | ||||
| 
 | ||||
| module Ameba | ||||
|   enum Severity | ||||
|     Error | ||||
|  | @ -17,6 +19,19 @@ module Ameba | |||
|       end | ||||
|     end | ||||
| 
 | ||||
|     # Returns a color uniquely indicating severity. | ||||
|     # | ||||
|     # ``` | ||||
|     # Severity::Warning.color # => Colorize::ColorANSI::Red | ||||
|     # ``` | ||||
|     def color : Colorize::Color | ||||
|       case self | ||||
|       in Error      then Colorize::ColorANSI::Red | ||||
|       in Warning    then Colorize::ColorANSI::Red | ||||
|       in Convention then Colorize::ColorANSI::Blue | ||||
|       end | ||||
|     end | ||||
| 
 | ||||
|     # Creates Severity by the name. | ||||
|     # | ||||
|     # ``` | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue