Skip to content

Commit

Permalink
Merge branch 'main' into const-error
Browse files Browse the repository at this point in the history
  • Loading branch information
notJoon authored Oct 17, 2024
2 parents 97c02b7 + 6baa00a commit 6170f68
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 23 deletions.
21 changes: 7 additions & 14 deletions internal/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,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"]()
e.rules["const-error-declaration"] = allRuleConstructors["const-error-declaration"]()
// 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 @@ -374,7 +374,7 @@ type RepeatedRegexCompilationRule struct {

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

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

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

Expand Down

0 comments on commit 6170f68

Please sign in to comment.