Skip to content

Commit 3d785f0

Browse files
ccoVeillecatenacyber
authored andcommitted
feat: improve diagnostic
An absolute URL is now provided in the diagnostic message. The Category field helps to classify the diagnostic message in the documentation. https://pkg.go.dev/golang.org/x/tools/go/analysis#Diagnostic The Readme file is not yet updated to add these html anchors.
1 parent 31fa922 commit 3d785f0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

analyzer/analyzer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ func New() *analysis.Analyzer {
5858
n := newPerfSprint()
5959
r := &analysis.Analyzer{
6060
Name: "perfsprint",
61+
URL: "https://github.com/catenacyber/perfsprint",
6162
Doc: "Checks that fmt.Sprintf can be replaced with a faster alternative.",
6263
Run: n.run,
6364
Requires: []*analysis.Analyzer{inspect.Analyzer},

analyzer/diagnostic.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ func newAnalysisDiagnostic(
1010
message string,
1111
suggestedFixes []analysis.SuggestedFix,
1212
) *analysis.Diagnostic {
13-
d := analysis.Diagnostic{
13+
if checker != "" {
14+
message = checker + ": " + message
15+
}
16+
17+
return &analysis.Diagnostic{
1418
Pos: analysisRange.Pos(),
1519
End: analysisRange.End(),
1620
SuggestedFixes: suggestedFixes,
21+
Message: message,
22+
Category: checker, // Possible hashtag available on the documentation
1723
}
18-
if checker != "" {
19-
d.Category = checker
20-
d.Message = checker + ": " + message
21-
} else {
22-
d.Message = message
23-
}
24-
return &d
2524
}

0 commit comments

Comments
 (0)