Skip to content

Commit

Permalink
internal/fetch,godoc: handle lint exceptions
Browse files Browse the repository at this point in the history
This CL addresses the errors found by staticcheck when we upgraded
to Go 1.23. All were deprecation warnings, and they were silenced
by "ignore" directives until we could deal with them.

In all cases, ignore the lint message was the right choice.
The CL adds justifications.

Change-Id: I09d4bb96cb9913f8e35189ed3a4af9deaa092447
Reviewed-on: https://go-review.googlesource.com/c/pkgsite/+/610801
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
kokoro-CI: kokoro <noreply+kokoro@google.com>
  • Loading branch information
jba committed Sep 5, 2024
1 parent 6b577b4 commit e0bd492
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 7 deletions.
9 changes: 8 additions & 1 deletion internal/fetch/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,14 @@ func (g *goPackagesModuleGetter) Search(ctx context.Context, query string, limit
continue
}
if f.Doc != nil {
//lint:ignore SA1019 TODO(jba) create a doc.Package
//lint:ignore SA1019 doc.Synopsis is correct here.
// The lint message warns that doc.Synopsis is deprecated in favor
// of Package.Synopsis.
// Package.Synopsis would display links on separate lines if the
// Package were initialized with a package's code and if the synopsis
// contained links.
// We don't have the code and we wouldn't want the extra lines if we did,
// so doc.Synopsis is a better choice.
result.Synopsis = doc.Synopsis(f.Doc.Text())
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/godoc/codec/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ const initialBody = `
// Code generated by the codec package. DO NOT EDIT.
//lint:file-ignore SA1019 TODO(jba): fix
//lint:file-ignore SA1019 go/doc uses *ast.Object, so we must preserve it.
package «.Package»
Expand Down
2 changes: 1 addition & 1 deletion internal/godoc/codec/testdata/map.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/godoc/codec/testdata/slice.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/godoc/codec/testdata/struct.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions internal/godoc/dochtml/internal/render/render_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import (
"strings"
)

//lint:file-ignore SA1019 We only need the syntax tree.
// ast.NewPackage is deprecated in favor of go/types, but we don't want or need full
// type information here, just the syntax tree. We are only rendering documentation.

var pkgTime, fsetTime = mustLoadPackage("time")

func mustLoadPackage(path string) (*doc.Package, *token.FileSet) {
Expand Down
2 changes: 1 addition & 1 deletion internal/godoc/encode_ast.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/godoc/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func printNode(w io.Writer, root ast.Node) error {
idx := len(seen)
seen[x] = idx
pr("%s#%d", ts, idx)
//lint:ignore SA1019 TODO(jba) remove ast.Object
//lint:ignore SA1019 go/doc uses *ast.Object, so we must preserve it.
if obj, ok := x.(*ast.Object); ok {
pr(" %s %s %v\n", obj.Name, obj.Kind, obj.Data)
prValue(obj.Decl, depth+1)
Expand Down

0 comments on commit e0bd492

Please sign in to comment.