@@ -108,21 +108,7 @@ func NewRevive(cfg *config.ReviveSettings) *goanalysis.Linter {
108
108
}
109
109
110
110
for i := range results {
111
- issues = append (issues , goanalysis .NewIssue (& result.Issue {
112
- Severity : string (results [i ].Severity ),
113
- Text : fmt .Sprintf ("%s: %s" , results [i ].RuleName , results [i ].Failure .Failure ),
114
- Pos : token.Position {
115
- Filename : results [i ].Position .Start .Filename ,
116
- Line : results [i ].Position .Start .Line ,
117
- Offset : results [i ].Position .Start .Offset ,
118
- Column : results [i ].Position .Start .Column ,
119
- },
120
- LineRange : & result.Range {
121
- From : results [i ].Position .Start .Line ,
122
- To : results [i ].Position .End .Line ,
123
- },
124
- FromLinter : reviveName ,
125
- }, pass ))
111
+ issues = append (issues , reviveToIssue (pass , & results [i ]))
126
112
}
127
113
128
114
return nil , nil
@@ -132,6 +118,29 @@ func NewRevive(cfg *config.ReviveSettings) *goanalysis.Linter {
132
118
}).WithLoadMode (goanalysis .LoadModeSyntax )
133
119
}
134
120
121
+ func reviveToIssue (pass * analysis.Pass , object * jsonObject ) goanalysis.Issue {
122
+ lineRangeTo := object .Position .End .Line
123
+ if object .RuleName == (& rule.ExportedRule {}).Name () {
124
+ lineRangeTo = object .Position .Start .Line
125
+ }
126
+
127
+ return goanalysis .NewIssue (& result.Issue {
128
+ Severity : string (object .Severity ),
129
+ Text : fmt .Sprintf ("%s: %s" , object .RuleName , object .Failure .Failure ),
130
+ Pos : token.Position {
131
+ Filename : object .Position .Start .Filename ,
132
+ Line : object .Position .Start .Line ,
133
+ Offset : object .Position .Start .Offset ,
134
+ Column : object .Position .Start .Column ,
135
+ },
136
+ LineRange : & result.Range {
137
+ From : object .Position .Start .Line ,
138
+ To : lineRangeTo ,
139
+ },
140
+ FromLinter : reviveName ,
141
+ }, pass )
142
+ }
143
+
135
144
// This function mimics the GetConfig function of revive.
136
145
// This allow to get default values and right types.
137
146
// https://github.com/golangci/golangci-lint/issues/1745
0 commit comments