Skip to content

Commit 32024eb

Browse files
refactor: add Severity type, move severity constants
1 parent 95016f2 commit 32024eb

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

lint/config.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
package lint
22

3-
// Rule Severity Constants
4-
const (
5-
SeverityWarn = "warn"
6-
SeverityError = "error"
7-
)
8-
93
// Config represent linter config
104
type Config struct {
115
Formatter string `yaml:"formatter"`
@@ -15,7 +9,7 @@ type Config struct {
159
// RuleConfig represent config for a rule
1610
type RuleConfig struct {
1711
Enabled bool `yaml:"enabled"`
18-
Severity string `yaml:"severity"`
12+
Severity Severity `yaml:"severity"`
1913
Argument interface{} `yaml:"argument"`
2014

2115
// Optional flags

lint/constants.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package lint
2+
3+
// Rule Severity Constants
4+
const (
5+
SeverityWarn Severity = "warn"
6+
SeverityError Severity = "error"
7+
)
8+
9+
type Severity string
10+
11+
func (s Severity) String() string {
12+
switch s {
13+
case SeverityError:
14+
return "Error"
15+
case SeverityWarn:
16+
return "Warning"
17+
default:
18+
return "Severity(" + string(s) + ")"
19+
}
20+
}

lint/result.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type Result struct {
1111
// RuleResult holds result of a linter rule
1212
type RuleResult struct {
1313
Name string
14-
Severity string
14+
Severity Severity
1515
Message string
1616
}
1717

0 commit comments

Comments
 (0)