@@ -10,6 +10,7 @@ import (
1010 "sync"
1111
1212 "github.com/BurntSushi/toml"
13+ hcversion "github.com/hashicorp/go-version"
1314 reviveConfig "github.com/mgechev/revive/config"
1415 "github.com/mgechev/revive/lint"
1516 "github.com/mgechev/revive/rule"
@@ -89,6 +90,11 @@ func newWrapper(settings *config.ReviveSettings) (*wrapper, error) {
8990 return nil , err
9091 }
9192
93+ conf .GoVersion , err = hcversion .NewVersion (settings .Go )
94+ if err != nil {
95+ return nil , err
96+ }
97+
9298 formatter , err := reviveConfig .GetFormatter ("json" )
9399 if err != nil {
94100 return nil , err
@@ -183,7 +189,10 @@ func toIssue(pass *analysis.Pass, object *jsonObject) goanalysis.Issue {
183189func getConfig (cfg * config.ReviveSettings ) (* lint.Config , error ) {
184190 conf := defaultConfig ()
185191
186- if ! reflect .DeepEqual (cfg , & config.ReviveSettings {}) {
192+ // Since the Go version is dynamic, this value must be neutralized in order to compare with a "zero value" of the configuration structure.
193+ zero := & config.ReviveSettings {Go : cfg .Go }
194+
195+ if ! reflect .DeepEqual (cfg , zero ) {
187196 rawRoot := createConfigMap (cfg )
188197 buf := bytes .NewBuffer (nil )
189198
@@ -275,7 +284,7 @@ func safeTomlSlice(r []any) []any {
275284}
276285
277286// This element is not exported by revive, so we need copy the code.
278- // Extracted from https://github.com/mgechev/revive/blob/v1.3.7 /config/config.go#L15
287+ // Extracted from https://github.com/mgechev/revive/blob/v1.3.9 /config/config.go#L15
279288var defaultRules = []lint.Rule {
280289 & rule.VarDeclarationsRule {},
281290 & rule.PackageCommentsRule {},
@@ -358,6 +367,7 @@ var allRules = append([]lint.Rule{
358367 & rule.EnforceRepeatedArgTypeStyleRule {},
359368 & rule.EnforceSliceStyleRule {},
360369 & rule.MaxControlNestingRule {},
370+ & rule.CommentsDensityRule {},
361371}, defaultRules ... )
362372
363373const defaultConfidence = 0.8
0 commit comments