mirror of
				https://gitea.invidious.io/iv-org/shard-ameba.git
				synced 2024-08-15 00:53:29 +00:00 
			
		
		
		
	Merge pull request #310 from crystal-ameba/Sija/refactor-rule-default-group-severity
This commit is contained in:
		
						commit
						f89e7c2d3c
					
				
					 4 changed files with 14 additions and 5 deletions
				
			
		|  | @ -255,9 +255,8 @@ class Ameba::Config | ||||||
|       {% end %} |       {% end %} | ||||||
| 
 | 
 | ||||||
|       {% if properties["severity".id] == nil %} |       {% if properties["severity".id] == nil %} | ||||||
|         {% default = @type.name.starts_with?("Ameba::Rule::Lint") ? "Ameba::Severity::Warning".id : "Ameba::Severity::Convention".id %} |  | ||||||
|         @[YAML::Field(key: "Severity", converter: Ameba::SeverityYamlConverter)] |         @[YAML::Field(key: "Severity", converter: Ameba::SeverityYamlConverter)] | ||||||
|         property severity = {{ default }} |         property severity = {{ @type }}.default_severity | ||||||
|       {% end %} |       {% end %} | ||||||
| 
 | 
 | ||||||
|       {% if properties["excluded".id] == nil %} |       {% if properties["excluded".id] == nil %} | ||||||
|  | @ -267,6 +266,16 @@ class Ameba::Config | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     macro included |     macro included | ||||||
|  |       GROUP_SEVERITY = { | ||||||
|  |         Lint:        Ameba::Severity::Warning, | ||||||
|  |         Metrics:     Ameba::Severity::Warning, | ||||||
|  |         Performance: Ameba::Severity::Warning, | ||||||
|  |       } | ||||||
|  | 
 | ||||||
|  |       class_getter default_severity : Ameba::Severity do | ||||||
|  |         GROUP_SEVERITY[group_name]? || Ameba::Severity::Convention | ||||||
|  |       end | ||||||
|  | 
 | ||||||
|       macro inherited |       macro inherited | ||||||
|         include YAML::Serializable |         include YAML::Serializable | ||||||
|         include YAML::Serializable::Strict |         include YAML::Serializable::Strict | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ module Ameba::Rule::Layout | ||||||
|   # ``` |   # ``` | ||||||
|   class TrailingWhitespace < Base |   class TrailingWhitespace < Base | ||||||
|     properties do |     properties do | ||||||
|       description "Disallows trailing whitespaces" |       description "Disallows trailing whitespace" | ||||||
|     end |     end | ||||||
| 
 | 
 | ||||||
|     MSG = "Trailing whitespace detected" |     MSG = "Trailing whitespace detected" | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ module Ameba::Rule::Lint | ||||||
|   # A rule that disallows redundant `with_index` calls. |   # A rule that disallows redundant `with_index` calls. | ||||||
|   # |   # | ||||||
|   # For example, this is considered invalid: |   # For example, this is considered invalid: | ||||||
|  |   # | ||||||
|   # ``` |   # ``` | ||||||
|   # collection.each.with_index do |e| |   # collection.each.with_index do |e| | ||||||
|   #   # ... |   #   # ... | ||||||
|  |  | ||||||
|  | @ -88,8 +88,7 @@ module Ameba | ||||||
|       @formatter.started @sources |       @formatter.started @sources | ||||||
| 
 | 
 | ||||||
|       channels = @sources.map { Channel(Exception?).new } |       channels = @sources.map { Channel(Exception?).new } | ||||||
|       @sources.each_with_index do |source, idx| |       @sources.zip(channels).each do |source, channel| | ||||||
|         channel = channels[idx] |  | ||||||
|         spawn do |         spawn do | ||||||
|           run_source(source) |           run_source(source) | ||||||
|         rescue e |         rescue e | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue