Skip to content

Commit b1bf236

Browse files
run nilaway through golangci-lint as a custom module (#928)
1 parent dfdc4a5 commit b1bf236

File tree

3 files changed

+36
-10
lines changed

3 files changed

+36
-10
lines changed

.custom-gcl.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
version: v2.4.0
2-
name: golangci-lint-kube-api-linter
1+
version: v2.5.0
2+
name: golangci-lint-custom
33
destination: ./bin
44
plugins:
55
- module: 'sigs.k8s.io/kube-api-linter'
66
version: v0.0.0-20250819121536-a575e84f4ce8
7+
- module: "go.uber.org/nilaway"
8+
import: "go.uber.org/nilaway/cmd/gclplugin"
9+
version: "v0.0.0-20250821055425-361559d802f0"

.golangci-nilaway.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
version: "2"
2+
run:
3+
issues-exit-code: 1
4+
output:
5+
formats:
6+
text:
7+
path: stdout
8+
linters:
9+
default: none
10+
enable:
11+
- nilaway
12+
settings:
13+
custom:
14+
nilaway:
15+
type: "module"
16+
description: Static analysis tool to detect potential nil panics in Go code.
17+
settings:
18+
include-pkgs: ""
19+
exclude-file-docstrings: ignore_autogenerated
20+
issues:
21+
max-issues-per-linter: 0
22+
max-same-issues: 0
23+
new: false

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ lint: ## Run lint against code.
131131
$(GOLANGCI_LINT) run -c .golangci.yml
132132

133133
.PHONY: lint
134-
lint-api: golangci-lint-kal ## Run lint against code.
135-
$(GOLANGCI_LINT_KAL) run -c .golangci-kal.yml
134+
lint-api: golangci-lint-custom ## Run lint against code.
135+
$(GOLANGCI_LINT_CUSTOM) run -c .golangci-kal.yml
136136

137137
.PHONY: nilcheck
138-
nilcheck: nilaway ## Run nil check against code.
139-
go list ./... | xargs -I {} -d '\n' nilaway -include-pkgs {} -exclude-file-docstrings "ignore_autogenerated" ./...
138+
nilcheck: golangci-lint-custom ## Run nil check against code.
139+
$(GOLANGCI_LINT_CUSTOM) run -c .golangci-nilaway.yml
140140

141141
.PHONY: vulncheck
142142
vulncheck: govulncheck ## Run vulnerability check against code.
@@ -358,7 +358,7 @@ GOVULNC ?= $(LOCALBIN)/govulncheck
358358
MOCKGEN ?= $(LOCALBIN)/mockgen
359359
GOWRAP ?= $(CACHE_BIN)/gowrap
360360
GOLANGCI_LINT ?= $(LOCALBIN)/golangci-lint
361-
GOLANGCI_LINT_KAL ?= $(CACHE_BIN)/golangci-lint-kube-api-linter
361+
GOLANGCI_LINT_CUSTOM ?= $(CACHE_BIN)/golangci-lint-custom
362362
S5CMD ?= $(CACHE_BIN)/s5cmd
363363

364364
## Tool Versions
@@ -458,9 +458,9 @@ golangci-lint: $(GOLANGCI_LINT)
458458
$(GOLANGCI_LINT): # Build golangci-lint from tools folder.
459459
GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION)
460460

461-
.phony: golangci-lint-kal
462-
golangci-lint-kal: $(GOLANGCI_LINT_KAL)
463-
$(GOLANGCI_LINT_KAL): $(GOLANGCI_LINT) # Build golangci-lint-kal from custom configuration.
461+
.phony: golangci-lint-custom
462+
golangci-lint-custom: $(GOLANGCI_LINT_CUSTOM)
463+
$(GOLANGCI_LINT_CUSTOM): $(GOLANGCI_LINT) # Build golangci-lint-custom from custom configuration.
464464
$(GOLANGCI_LINT) custom
465465

466466
.PHONY: nilaway

0 commit comments

Comments
 (0)