Skip to content

Commit e5f7ae1

Browse files
committed
go/analysis: add Analyser.URL and Diagnostic.URI fields
These fields allow the analyzer to provide links to its online documentation. Also: - set URI field for all x/tools Analyzers. - include these URIs in the gopls docs. Fixes golang/go#57906 Change-Id: Iec0a34386d834edfae4e9161a18a1d14a7a43b74 Reviewed-on: https://go-review.googlesource.com/c/tools/+/476615 Reviewed-by: Robert Findley <[email protected]> Run-TryBot: Alan Donovan <[email protected]> TryBot-Result: Gopher Robot <[email protected]> gopls-CI: kokoro <[email protected]>
1 parent b6dbcf8 commit e5f7ae1

File tree

50 files changed

+97
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+97
-2
lines changed

go/analysis/analysis.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ type Analyzer struct {
2424
// (no capital or period, max ~60 letters).
2525
Doc string
2626

27+
// URL holds an optional link to a web page with additional
28+
// documentation for this analyzer.
29+
URL string
30+
2731
// Flags defines any flags accepted by the analyzer.
2832
// The manner in which these flags are exposed to the user
2933
// depends on the driver which runs the analyzer.

go/analysis/diagnostic.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ type Diagnostic struct {
2020
Category string // optional
2121
Message string
2222

23+
// URL is the optional location of a web page that provides
24+
// additional documentation for this diagnostic.
25+
//
26+
// If URL is empty but a Category is specified, then the
27+
// Analysis driver should treat the URL as "#"+Category.
28+
//
29+
// The URL may be relative. If so, the base URL is that of the
30+
// Analyzer that produced the diagnostic;
31+
// see https://pkg.go.dev/net/url#URL.ResolveReference.
32+
URL string
33+
2334
// SuggestedFixes contains suggested fixes for a diagnostic which can be used to perform
2435
// edits to a file that address the diagnostic.
2536
// TODO(matloob): Should multiple SuggestedFixes be allowed for a diagnostic?

go/analysis/passes/asmdecl/asmdecl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const Doc = "report mismatches between assembly files and Go declarations"
2727
var Analyzer = &analysis.Analyzer{
2828
Name: "asmdecl",
2929
Doc: Doc,
30+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/asmdecl",
3031
Run: run,
3132
}
3233

go/analysis/passes/assign/assign.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ usually a mistake.`
3030
var Analyzer = &analysis.Analyzer{
3131
Name: "assign",
3232
Doc: Doc,
33+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/assign",
3334
Requires: []*analysis.Analyzer{inspect.Analyzer},
3435
Run: run,
3536
}

go/analysis/passes/atomic/atomic.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ which are not atomic.`
2828
var Analyzer = &analysis.Analyzer{
2929
Name: "atomic",
3030
Doc: Doc,
31+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/atomic",
3132
Requires: []*analysis.Analyzer{inspect.Analyzer},
3233
RunDespiteErrors: true,
3334
Run: run,

go/analysis/passes/atomicalign/atomicalign.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const Doc = "check for non-64-bits-aligned arguments to sync/atomic functions"
2525
var Analyzer = &analysis.Analyzer{
2626
Name: "atomicalign",
2727
Doc: Doc,
28+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/atomicalign",
2829
Requires: []*analysis.Analyzer{inspect.Analyzer},
2930
Run: run,
3031
}

go/analysis/passes/bools/bools.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const Doc = "check for common mistakes involving boolean operators"
2222
var Analyzer = &analysis.Analyzer{
2323
Name: "bools",
2424
Doc: Doc,
25+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/bools",
2526
Requires: []*analysis.Analyzer{inspect.Analyzer},
2627
Run: run,
2728
}

go/analysis/passes/buildssa/buildssa.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
var Analyzer = &analysis.Analyzer{
2323
Name: "buildssa",
2424
Doc: "build SSA-form IR for later passes",
25+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/buildssa",
2526
Run: run,
2627
ResultType: reflect.TypeOf(new(SSA)),
2728
}

go/analysis/passes/buildtag/buildtag.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const Doc = "check //go:build and // +build directives"
2525
var Analyzer = &analysis.Analyzer{
2626
Name: "buildtag",
2727
Doc: Doc,
28+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/buildtag",
2829
Run: runBuildTag,
2930
}
3031

go/analysis/passes/cgocall/cgocall.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ or slice to C, either directly, or via a pointer, array, or struct.`
3535
var Analyzer = &analysis.Analyzer{
3636
Name: "cgocall",
3737
Doc: Doc,
38+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/cgocall",
3839
RunDespiteErrors: true,
3940
Run: run,
4041
}

go/analysis/passes/composite/composite.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ should be replaced by:
3737
var Analyzer = &analysis.Analyzer{
3838
Name: "composites",
3939
Doc: Doc,
40+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/composites",
4041
Requires: []*analysis.Analyzer{inspect.Analyzer},
4142
RunDespiteErrors: true,
4243
Run: run,

go/analysis/passes/copylock/copylock.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ values should be referred to through a pointer.`
2929
var Analyzer = &analysis.Analyzer{
3030
Name: "copylocks",
3131
Doc: Doc,
32+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/copylocks",
3233
Requires: []*analysis.Analyzer{inspect.Analyzer},
3334
RunDespiteErrors: true,
3435
Run: run,

go/analysis/passes/ctrlflow/ctrlflow.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
var Analyzer = &analysis.Analyzer{
2525
Name: "ctrlflow",
2626
Doc: "build a control-flow graph",
27+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/ctrlflow",
2728
Run: run,
2829
ResultType: reflect.TypeOf(new(CFGs)),
2930
FactTypes: []analysis.Fact{new(noReturn)},

go/analysis/passes/deepequalerrors/deepequalerrors.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ errors is discouraged.`
2828
var Analyzer = &analysis.Analyzer{
2929
Name: "deepequalerrors",
3030
Doc: Doc,
31+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/deepequalerrors",
3132
Requires: []*analysis.Analyzer{inspect.Analyzer},
3233
Run: run,
3334
}

go/analysis/passes/directive/directive.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ buildtag analyzer.
3636
var Analyzer = &analysis.Analyzer{
3737
Name: "directive",
3838
Doc: Doc,
39+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/directive",
3940
Run: runDirective,
4041
}
4142

go/analysis/passes/errorsas/errorsas.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ of the second argument is not a pointer to a type implementing error.`
2525
var Analyzer = &analysis.Analyzer{
2626
Name: "errorsas",
2727
Doc: Doc,
28+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/errorsas",
2829
Requires: []*analysis.Analyzer{inspect.Analyzer},
2930
Run: run,
3031
}

go/analysis/passes/fieldalignment/fieldalignment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ known as "false sharing" that slows down both goroutines.
5151
var Analyzer = &analysis.Analyzer{
5252
Name: "fieldalignment",
5353
Doc: Doc,
54+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/fieldalignment",
5455
Requires: []*analysis.Analyzer{inspect.Analyzer},
5556
Run: run,
5657
}

go/analysis/passes/findcall/findcall.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ of a particular name.`
2626
var Analyzer = &analysis.Analyzer{
2727
Name: "findcall",
2828
Doc: Doc,
29+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/findcall",
2930
Run: run,
3031
RunDespiteErrors: true,
3132
FactTypes: []analysis.Fact{new(foundFact)},

go/analysis/passes/framepointer/framepointer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const Doc = "report assembly that clobbers the frame pointer before saving it"
2020
var Analyzer = &analysis.Analyzer{
2121
Name: "framepointer",
2222
Doc: Doc,
23+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/framepointer",
2324
Run: run,
2425
}
2526

go/analysis/passes/httpresponse/httpresponse.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ diagnostic for such mistakes.`
3535
var Analyzer = &analysis.Analyzer{
3636
Name: "httpresponse",
3737
Doc: Doc,
38+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/httpresponse",
3839
Requires: []*analysis.Analyzer{inspect.Analyzer},
3940
Run: run,
4041
}

go/analysis/passes/ifaceassert/ifaceassert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ io.Reader, so this assertion cannot succeed.
3434
var Analyzer = &analysis.Analyzer{
3535
Name: "ifaceassert",
3636
Doc: Doc,
37+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/ifaceassert",
3738
Requires: []*analysis.Analyzer{inspect.Analyzer},
3839
Run: run,
3940
}

go/analysis/passes/inspect/inspect.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
var Analyzer = &analysis.Analyzer{
3939
Name: "inspect",
4040
Doc: "optimize AST traversal for later passes",
41+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/inspect",
4142
Run: run,
4243
RunDespiteErrors: true,
4344
ResultType: reflect.TypeOf(new(inspector.Inspector)),

go/analysis/passes/loopclosure/loopclosure.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ See: https://golang.org/doc/go_faq.html#closures_and_goroutines`
7878
var Analyzer = &analysis.Analyzer{
7979
Name: "loopclosure",
8080
Doc: Doc,
81+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/loopclosure",
8182
Requires: []*analysis.Analyzer{inspect.Analyzer},
8283
Run: run,
8384
}

go/analysis/passes/lostcancel/lostcancel.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ until its parent context is cancelled.
2828
var Analyzer = &analysis.Analyzer{
2929
Name: "lostcancel",
3030
Doc: Doc,
31+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/lostcancel",
3132
Run: run,
3233
Requires: []*analysis.Analyzer{
3334
inspect.Analyzer,

go/analysis/passes/nilfunc/nilfunc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ A useless comparison is one like f == nil as opposed to f() == nil.`
2424
var Analyzer = &analysis.Analyzer{
2525
Name: "nilfunc",
2626
Doc: Doc,
27+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilfunc",
2728
Requires: []*analysis.Analyzer{inspect.Analyzer},
2829
Run: run,
2930
}

go/analysis/passes/nilness/nilness.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ and:
5757
var Analyzer = &analysis.Analyzer{
5858
Name: "nilness",
5959
Doc: Doc,
60+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/nilness",
6061
Run: run,
6162
Requires: []*analysis.Analyzer{buildssa.Analyzer},
6263
}

go/analysis/passes/pkgfact/pkgfact.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import (
3838
var Analyzer = &analysis.Analyzer{
3939
Name: "pkgfact",
4040
Doc: "gather name/value pairs from constant declarations",
41+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/pkgfact",
4142
Run: run,
4243
FactTypes: []analysis.Fact{new(pairsFact)},
4344
ResultType: reflect.TypeOf(map[string]string{}),

go/analysis/passes/printf/printf.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ func init() {
3535
var Analyzer = &analysis.Analyzer{
3636
Name: "printf",
3737
Doc: Doc,
38+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/printf",
3839
Requires: []*analysis.Analyzer{inspect.Analyzer},
3940
Run: run,
4041
ResultType: reflect.TypeOf((*Result)(nil)),

go/analysis/passes/reflectvaluecompare/reflectvaluecompare.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Likely what is intended is:
3939
var Analyzer = &analysis.Analyzer{
4040
Name: "reflectvaluecompare",
4141
Doc: Doc,
42+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/reflectvaluecompare",
4243
Requires: []*analysis.Analyzer{inspect.Analyzer},
4344
Run: run,
4445
}

go/analysis/passes/shadow/shadow.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ For example:
4646
var Analyzer = &analysis.Analyzer{
4747
Name: "shadow",
4848
Doc: Doc,
49+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/shadow",
4950
Requires: []*analysis.Analyzer{inspect.Analyzer},
5051
Run: run,
5152
}

go/analysis/passes/shift/shift.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const Doc = "check for shifts that equal or exceed the width of the integer"
2929
var Analyzer = &analysis.Analyzer{
3030
Name: "shift",
3131
Doc: Doc,
32+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/shift",
3233
Requires: []*analysis.Analyzer{inspect.Analyzer},
3334
Run: run,
3435
}

go/analysis/passes/sigchanyzer/sigchanyzer.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ where c is an unbuffered channel, which can be at risk of missing the signal.`
2727
var Analyzer = &analysis.Analyzer{
2828
Name: "sigchanyzer",
2929
Doc: Doc,
30+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/sigchanyzer",
3031
Requires: []*analysis.Analyzer{inspect.Analyzer},
3132
Run: run,
3233
}

go/analysis/passes/sortslice/analyzer.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@ the interface{} value passed to sort.Slice is actually a slice.`
2727
var Analyzer = &analysis.Analyzer{
2828
Name: "sortslice",
2929
Doc: Doc,
30+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/sortslice",
3031
Requires: []*analysis.Analyzer{inspect.Analyzer},
3132
Run: run,
3233
}
3334

3435
func run(pass *analysis.Pass) (interface{}, error) {
36+
// TODO(adonovan): opt: first check for import "sort".
3537
inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
3638

3739
nodeFilter := []ast.Node{

go/analysis/passes/stdmethods/stdmethods.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Checked method names include:
4040
var Analyzer = &analysis.Analyzer{
4141
Name: "stdmethods",
4242
Doc: Doc,
43+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/stdmethods",
4344
Requires: []*analysis.Analyzer{inspect.Analyzer},
4445
Run: run,
4546
}

go/analysis/passes/stringintconv/string.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ string representation of the value in the desired base.
3434
var Analyzer = &analysis.Analyzer{
3535
Name: "stringintconv",
3636
Doc: Doc,
37+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/stringintconv",
3738
Requires: []*analysis.Analyzer{inspect.Analyzer},
3839
Run: run,
3940
}

go/analysis/passes/structtag/structtag.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Also report certain struct tags (json, xml) used with unexported fields.`
2828
var Analyzer = &analysis.Analyzer{
2929
Name: "structtag",
3030
Doc: Doc,
31+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/structtag",
3132
Requires: []*analysis.Analyzer{inspect.Analyzer},
3233
RunDespiteErrors: true,
3334
Run: run,

go/analysis/passes/testinggoroutine/testinggoroutine.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ func TestFoo(t *testing.T) {
3131
var Analyzer = &analysis.Analyzer{
3232
Name: "testinggoroutine",
3333
Doc: Doc,
34+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/testinggoroutine",
3435
Requires: []*analysis.Analyzer{inspect.Analyzer},
3536
Run: run,
3637
}

go/analysis/passes/tests/tests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ for the conventions that are enforced for Tests, Benchmarks, and Examples.`
3333
var Analyzer = &analysis.Analyzer{
3434
Name: "tests",
3535
Doc: Doc,
36+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/tests",
3637
Run: run,
3738
}
3839

go/analysis/passes/timeformat/timeformat.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ standards, and so it is more likely that 2006-01-02 (yyyy-mm-dd) was intended.
3232
var Analyzer = &analysis.Analyzer{
3333
Name: "timeformat",
3434
Doc: Doc,
35+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/timeformat",
3536
Requires: []*analysis.Analyzer{inspect.Analyzer},
3637
Run: run,
3738
}

go/analysis/passes/unmarshal/unmarshal.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ in which the argument type is not a pointer or an interface.`
2525
var Analyzer = &analysis.Analyzer{
2626
Name: "unmarshal",
2727
Doc: Doc,
28+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unmarshal",
2829
Requires: []*analysis.Analyzer{inspect.Analyzer},
2930
Run: run,
3031
}

go/analysis/passes/unreachable/unreachable.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ infinite loop, or similar constructs.`
2626
var Analyzer = &analysis.Analyzer{
2727
Name: "unreachable",
2828
Doc: Doc,
29+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unreachable",
2930
Requires: []*analysis.Analyzer{inspect.Analyzer},
3031
RunDespiteErrors: true,
3132
Run: run,

go/analysis/passes/unsafeptr/unsafeptr.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ invisible to stack copying and to the garbage collector.`
2828
var Analyzer = &analysis.Analyzer{
2929
Name: "unsafeptr",
3030
Doc: Doc,
31+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unsafeptr",
3132
Requires: []*analysis.Analyzer{inspect.Analyzer},
3233
Run: run,
3334
}

go/analysis/passes/unusedresult/unusedresult.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ The set of functions may be controlled using flags.`
3535
var Analyzer = &analysis.Analyzer{
3636
Name: "unusedresult",
3737
Doc: Doc,
38+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unusedresult",
3839
Requires: []*analysis.Analyzer{inspect.Analyzer},
3940
Run: run,
4041
}

go/analysis/passes/unusedwrite/unusedwrite.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Another example is about non-pointer receiver:
4545
var Analyzer = &analysis.Analyzer{
4646
Name: "unusedwrite",
4747
Doc: Doc,
48+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/unusedwrite",
4849
Requires: []*analysis.Analyzer{buildssa.Analyzer},
4950
Run: run,
5051
}

go/analysis/passes/usesgenerics/usesgenerics.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
var Analyzer = &analysis.Analyzer{
1919
Name: "usesgenerics",
2020
Doc: Doc,
21+
URL: "https://pkg.go.dev/golang.org/x/tools/go/analysis/passes/usesgenerics",
2122
Requires: []*analysis.Analyzer{inspect.Analyzer},
2223
Run: run,
2324
ResultType: reflect.TypeOf((*Result)(nil)),

gopls/doc/generate.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,7 @@ func loadAnalyzers(m map[string]*source.Analyzer) []*source.AnalyzerJSON {
516516
json = append(json, &source.AnalyzerJSON{
517517
Name: a.Analyzer.Name,
518518
Doc: a.Analyzer.Doc,
519+
URL: a.Analyzer.URL,
519520
Default: a.Enabled,
520521
})
521522
}

gopls/internal/lsp/cache/analysis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ func toGobDiagnostic(posToLocation func(start, end token.Pos) (protocol.Location
12321232
// Severity for analysis diagnostics is dynamic, based on user
12331233
// configuration per analyzer.
12341234
// Code and CodeHref are unset for Analysis diagnostics,
1235-
// TODO(rfindley): set Code fields if/when golang/go#57906 is accepted.
1235+
// TODO(rfindley): derive Code fields from diag.URL.
12361236
Source: diag.Category,
12371237
Message: diag.Message,
12381238
SuggestedFixes: fixes,

0 commit comments

Comments
 (0)