Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: default rules severity adjustments #95

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 7 additions & 13 deletions internal/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,13 @@ func (e *Engine) applyRules(rules map[string]tt.ConfigRule) {
}

func (e *Engine) registerDefaultRules() {
e.rules["golangci-lint"] = allRuleConstructors["golangci-lint"]()
e.rules["deprecated-function"] = allRuleConstructors["deprecated-function"]()
e.rules["early-return-opportunity"] = allRuleConstructors["early-return-opportunity"]()
e.rules["simplify-slice-range"] = allRuleConstructors["simplify-slice-range"]()
e.rules["unnecessary-type-conversion"] = allRuleConstructors["unnecessary-type-conversion"]()
e.rules["loop-allocation"] = allRuleConstructors["loop-allocation"]()
e.rules["emit-format"] = allRuleConstructors["emit-format"]()
e.rules["cycle-detection"] = allRuleConstructors["cycle-detection"]()
e.rules["unused-package"] = allRuleConstructors["unused-package"]()
e.rules["repeated-regex-compilation"] = allRuleConstructors["repeated-regex-compilation"]()
e.rules["useless-break"] = allRuleConstructors["useless-break"]()
e.rules["defer-issues"] = allRuleConstructors["defer-issues"]()
e.rules["gno-mod-tidy"] = allRuleConstructors["gno-mod-tidy"]()
// iterate over allRuleConstructors and add them to the rules map if severity is not off
for key, newRuleCstr := range allRuleConstructors {
newRule := newRuleCstr()
if newRule.Severity() != tt.SeverityOff {
e.rules[key] = newRule
}
}
}

func (e *Engine) findRule(name string) LintRule {
Expand Down
18 changes: 9 additions & 9 deletions internal/rule_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type GolangciLintRule struct {

func NewGolangciLintRule() LintRule {
return &GolangciLintRule{
severity: tt.SeverityError,
severity: tt.SeverityWarning,
}
}

Expand Down Expand Up @@ -111,7 +111,7 @@ type UnnecessaryConversionRule struct {

func NewUnnecessaryConversionRule() LintRule {
return &UnnecessaryConversionRule{
severity: tt.SeverityError,
severity: tt.SeverityWarning,
}
}

Expand All @@ -137,7 +137,7 @@ type LoopAllocationRule struct {

func NewLoopAllocationRule() LintRule {
return &LoopAllocationRule{
severity: tt.SeverityError,
severity: tt.SeverityWarning,
}
}

Expand All @@ -163,7 +163,7 @@ type DetectCycleRule struct {

func NewDetectCycleRule() LintRule {
return &DetectCycleRule{
severity: tt.SeverityError,
severity: tt.SeverityError, // TODO
}
}

Expand All @@ -189,7 +189,7 @@ type EmitFormatRule struct {

func NewEmitFormatRule() LintRule {
return &EmitFormatRule{
severity: tt.SeverityError,
severity: tt.SeverityInfo,
}
}

Expand Down Expand Up @@ -267,7 +267,7 @@ type EarlyReturnOpportunityRule struct {

func NewEarlyReturnOpportunityRule() LintRule {
return &EarlyReturnOpportunityRule{
severity: tt.SeverityError,
severity: tt.SeverityInfo,
}
}

Expand All @@ -293,7 +293,7 @@ type DeferRule struct {

func NewDeferRule() LintRule {
return &DeferRule{
severity: tt.SeverityError,
severity: tt.SeverityWarning,
}
}

Expand Down Expand Up @@ -348,7 +348,7 @@ type RepeatedRegexCompilationRule struct {

func NewRepeatedRegexCompilationRule() LintRule {
return &RepeatedRegexCompilationRule{
severity: tt.SeverityError,
severity: tt.SeverityWarning,
}
}

Expand Down Expand Up @@ -407,7 +407,7 @@ type GnoSpecificRule struct {

func NewGnoSpecificRule() LintRule {
return &GnoSpecificRule{
severity: tt.SeverityError,
severity: tt.SeverityWarning,
}
}

Expand Down
Loading