Skip to content

Commit a7f64fe

Browse files
authored
Revert to nogo instead of golangci-lint (#197)
* Revert to nogo instead of golangci-lint Integration is simpler, and it now works with bzlmod. * Fix warnings flagged by nogo * Fix warnings flagged by nogo
1 parent 558b7d7 commit a7f64fe

File tree

10 files changed

+67
-63
lines changed

10 files changed

+67
-63
lines changed

.github/workflows/lint.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.golangci.yaml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
{
2-
"go.lintTool": "golangci-lint",
32
"go.toolsEnvVars": {
43
"GOOS": "js",
54
"GOARCH": "wasm"

BUILD.bazel

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ load("@gazelle//:def.bzl", "gazelle")
22
load("@npm//:defs.bzl", "npm_link_all_packages")
33
load("@rules_pkg//:pkg.bzl", "pkg_zip")
44
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files")
5+
load("@rules_go//go:def.bzl", "TOOLS_NOGO", "nogo")
56

67
# Force Gazelle to choose the correct target when there are multiple go_library
78
# targets in a single package.
@@ -21,6 +22,16 @@ gazelle(
2122
name = "gazelle",
2223
command = "fix",
2324
)
25+
nogo(
26+
name = "chrome_ssh_agent_nogo",
27+
config = ":nogo-config.json",
28+
visibility = ["//visibility:public"],
29+
deps = TOOLS_NOGO + [
30+
# Prohibit build tags (e.g., //go:build ... ) within tests, as these may
31+
# cause tests to silently be skipped unless we are extremely careful.
32+
"//nogo/testbuildtags",
33+
],
34+
)
2435

2536
exports_files([
2637
"go.mod",

MODULE.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ go_sdk.download(
1919
# Use semver-coerced to handle versions where patches are left off (e.g., 1.19).
2020
version = "1.21.5", # renovate: datasource=golang-version depName=golang versioning=semver-coerced
2121
)
22+
go_sdk.nogo(
23+
nogo = "//:chrome_ssh_agent_nogo",
24+
includes = [
25+
"//:__subpackages__",
26+
],
27+
)
2228
use_repo(go_sdk, "go_sdk")
2329

2430
# Pull in Go dependencies

go.work

Lines changed: 0 additions & 3 deletions
This file was deleted.

go/testutil/unzip.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ func UnzipTemp(path string) (string, CleanupFunc, error) {
6363
}
6464

6565
if f.Mode().IsDir() {
66-
if err := os.MkdirAll(filePath, os.ModePerm); err != nil {
67-
return fmt.Errorf("Failed to create destination directory %s: %w", filepath.Dir(filePath), err)
66+
if merr := os.MkdirAll(filePath, os.ModePerm); merr != nil {
67+
return fmt.Errorf("Failed to create destination directory %s: %w", filepath.Dir(filePath), merr)
6868
}
6969
return nil
7070
}
7171

72-
if err := os.MkdirAll(filepath.Dir(filePath), os.ModePerm); err != nil {
73-
return fmt.Errorf("Failed to create destination directory %s: %w", filepath.Dir(filePath), err)
72+
if merr := os.MkdirAll(filepath.Dir(filePath), os.ModePerm); merr != nil {
73+
return fmt.Errorf("Failed to create destination directory %s: %w", filepath.Dir(filePath), merr)
7474
}
7575

7676
dstFile, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())

nogo-config.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"composites": {
3+
"exclude_files": {
4+
"external/.*": "Ignore for third-party code"
5+
}
6+
},
7+
"copylocks": {
8+
"exclude_files": {
9+
"external/.*": "Ignore for third-party code"
10+
}
11+
},
12+
"nilness": {
13+
"exclude_files": {
14+
"external/.*": "Ignore for third-party code"
15+
}
16+
},
17+
"shadow": {
18+
"exclude_files": {
19+
"external/.*": "Ignore for third-party code"
20+
}
21+
},
22+
"stdmethods": {
23+
"exclude_files": {
24+
"external/.*": "Ignore for third-party code"
25+
}
26+
},
27+
"structtag": {
28+
"exclude_files": {
29+
"external/.*": "Ignore for third-party code"
30+
}
31+
},
32+
"unreachable": {
33+
"exclude_files": {
34+
"external/.*": "Ignore for third-party code"
35+
}
36+
},
37+
"unsafeptr": {
38+
"exclude_files": {
39+
"external/org_golang_x_sys/unix/.*": "Ignore for code not used on Javascript platforms"
40+
}
41+
}
42+
}

nogo/testbuildtags/testbuildtags.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
// being executed.
2121
//
2222

23-
// TODO: Find a way to re-enable this static analyzer. See
24-
//
25-
// https://github.com/google/chrome-ssh-agent/issues/163
26-
//
2723
//nolint:godox
2824
package testbuildtags
2925

test/e2e/e2e.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ func TestWebApp(t *testing.T) {
133133
t.Fatalf("failed to start Selenium service: %v", err)
134134
}
135135
defer func() {
136-
if err := service.Stop(); err != nil {
137-
t.Errorf("failed to stop Selenium service: %v", err)
136+
if serr := service.Stop(); serr != nil {
137+
t.Errorf("failed to stop Selenium service: %v", serr)
138138
}
139139
}()
140140

@@ -170,8 +170,8 @@ func TestWebApp(t *testing.T) {
170170
t.Fatalf("Failed to start webdriver: %v", err)
171171
}
172172
defer func() {
173-
if err := wd.Quit(); err != nil {
174-
t.Errorf("failed to quit webdriver: %v", err)
173+
if qerr := wd.Quit(); qerr != nil {
174+
t.Errorf("failed to quit webdriver: %v", qerr)
175175
}
176176
}()
177177
defer dumpSeleniumLogs(t, wd)

0 commit comments

Comments
 (0)