Skip to content

Commit c24d9d5

Browse files
committed
Re-enable linting via golangci-lint
Using a golangci-lint directive of the form: //nolint:staticcheck // reason why staticcheck has been disabled We can disable the use of the staticcheck linter completely at the blocks or lines where is is currently reporting the use of the deprecated ast.Package stuct. This approach is documented here: https://golangci-lint.run/usage/false-positives/#nolint-directive At present golangci-lint will ignore staticheck //lint:ignore style directives. This issues has been raised with the golangci-lint team. See: golangci/golangci-lint#2671 (comment) and here: golangci/golangci-lint#1658 (comment)
1 parent 35a8ec2 commit c24d9d5

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

gen/missing-fixer.go

+4
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ func readVugugenComments(pkgPath string) (map[string][]string, error) {
313313
// fileInPackage given pkg and "blah.go" will return the file whose base name is "blah.go"
314314
// (i.e. it ignores the directory part of the map key in pkg.Files)
315315
// Will return nil if not found.
316+
//
317+
//nolint:staticcheck // ast.Package is deprecated as of Go 1.23
316318
func fileInPackage(pkg *ast.Package, fileName string) *ast.File {
317319
for fpath, file := range pkg.Files {
318320
if filepath.Base(fpath) == fileName {
@@ -324,6 +326,8 @@ func fileInPackage(pkg *ast.Package, fileName string) *ast.File {
324326

325327
// findTypeDecl looks through the package for the given type and returns
326328
// the declaraction or nil if not found
329+
//
330+
//nolint:staticcheck // ast.Package is deprecated as of Go 1.23
327331
func findTypeDecl(fset *token.FileSet, pkg *ast.Package, typeName string) ast.Decl {
328332
for _, file := range pkg.Files {
329333
for _, decl := range file.Decls {

gen/parser-go-pkg.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ func goGuessPkgName(pkgPath string) (ret string) {
465465
goto checkMore
466466
}
467467
{
468-
var pkg *ast.Package
468+
var pkg *ast.Package //nolint:staticcheck // ast.Package is deprecated as of Go 1.23
469469
for _, pkg1 := range pkgs {
470470
pkg = pkg1
471471
}
@@ -507,8 +507,7 @@ func goPkgCheckNames(pkgPath string, names []string) (map[string]interface{}, er
507507
if len(pkgs) != 1 {
508508
return ret, fmt.Errorf("unexpected package count after parsing, expected 1 and got this: %#v", pkgs)
509509
}
510-
511-
var pkg *ast.Package
510+
var pkg *ast.Package //nolint:staticcheck // ast.Package is deprecated as of Go 1.23
512511
for _, pkg1 := range pkgs {
513512
pkg = pkg1
514513
}

magefiles/magefile.go

+5-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ package main
99

1010
import (
1111
"fmt"
12-
"log"
1312
"os"
1413
"path/filepath"
1514
"strings"
@@ -106,19 +105,14 @@ func PullLatestGolangCiLintDockerImage() error {
106105
return dockerPullImage(GoLangCiLintImageName)
107106
}
108107

109-
// Linting is current disabled, pending resolution of issue #320, See https://github.com/vugu/vugu/issues/302.
110108
// Lint the 'vugu' source code including the tests, and examples and any generated files. The linter used is a dockerized version of the 'golangci-lint' linter.
111109
// See: https://golangci-lint.run/ for more details of the linter
112110
func Lint() error {
113-
log.Printf("Linting is current disabled, pending resolution of issue #320, See https://github.com/vugu/vugu/issues/302.")
114-
return nil
115-
116-
// uncomment to renable the linter
117-
// mg.SerialDeps(
118-
// Build,
119-
// PullLatestGolangCiLintDockerImage,
120-
// )
121-
// return runGolangCiLint()
111+
mg.SerialDeps(
112+
Build,
113+
PullLatestGolangCiLintDockerImage,
114+
)
115+
return runGolangCiLint()
122116
}
123117

124118
// Builds and runs all of the Go unit tests for 'vugu', except the 'legacy-wasm-test-suite' tests using the standard Go compiler.

0 commit comments

Comments
 (0)