Skip to content

Commit d8999f3

Browse files
committed
go linter
1 parent 7004ec0 commit d8999f3

File tree

3 files changed

+127
-2
lines changed

3 files changed

+127
-2
lines changed

.github/workflows/code-health.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
workflow_dispatch:
99

1010
jobs:
11-
code-health:
11+
code-health: # required PR check
1212
needs: [build, lint, shellcheck]
1313
runs-on: ubuntu-latest
1414
permissions: {}
@@ -38,7 +38,7 @@ jobs:
3838
- name: golangci-lint
3939
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8
4040
with:
41-
version: v1.62.2 # Also update GOLANGCI_VERSION variable in GNUmakefile when updating this version
41+
version: v1.63.4 # Also update GOLANGCI_VERSION variable in GNUmakefile when updating this version
4242
- name: actionlint
4343
run: |
4444
make tools

.golangci.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
linters-settings:
2+
gocritic:
3+
enabled-tags:
4+
- diagnostic
5+
- experimental
6+
- opinionated
7+
- performance
8+
- style
9+
govet:
10+
enable-all: true
11+
12+
revive:
13+
# see https://github.com/mgechev/revive#available-rules for details.
14+
ignore-generated-header: true
15+
severity: warning
16+
rules:
17+
- name: blank-imports
18+
- name: context-as-argument
19+
- name: context-keys-type
20+
- name: dot-imports
21+
- name: error-return
22+
- name: error-strings
23+
- name: error-naming
24+
- name: errorf
25+
- name: exported
26+
- name: indent-error-flow
27+
- name: if-return
28+
- name: increment-decrement
29+
- name: var-naming
30+
- name: var-declaration
31+
- name: package-comments
32+
- name: range
33+
- name: receiver-naming
34+
- name: time-naming
35+
- name: unexported-return
36+
- name: indent-error-flow
37+
- name: errorf
38+
- name: empty-block
39+
- name: superfluous-else
40+
- name: struct-tag
41+
# Too many unusued parameters, skipping this check for now
42+
#- name: unused-parameter
43+
- name: unreachable-code
44+
- name: redefines-builtin-id
45+
misspell:
46+
locale: US
47+
ignore-words:
48+
- cancelled
49+
lll:
50+
# Default is 120. '\t' is counted as 1 character.
51+
# set our project to 500, as we are adding open api field description in the schema.
52+
# also, for anyone using vscode, use the following configs:
53+
# "rewrap.wrappingColumn": 500 ... requires the rewrap plugin
54+
# "editor.rulers": [500]
55+
line-length: 500
56+
nestif:
57+
# minimal complexity of if statements to report, 5 by default
58+
min-complexity: 7
59+
mnd:
60+
checks:
61+
- case
62+
- operation
63+
- return
64+
funlen:
65+
lines: 360
66+
statements: 120
67+
linters:
68+
disable-all: true
69+
enable:
70+
- dogsled
71+
- errcheck
72+
- funlen
73+
- gocritic
74+
- gofmt
75+
- goimports
76+
- revive
77+
- mnd
78+
- goprintffuncname
79+
- gosec
80+
- gosimple
81+
- govet
82+
- ineffassign
83+
- lll
84+
- misspell
85+
- nakedret
86+
- nolintlint
87+
- rowserrcheck
88+
- copyloopvar
89+
- staticcheck
90+
- stylecheck
91+
- typecheck
92+
- unconvert
93+
- unused
94+
- whitespace
95+
- thelper
96+
- testifylint
97+
- exhaustive
98+
- makezero
99+
- noctx
100+
- tenv
101+
- testpackage
102+
run:
103+
timeout: 10m
104+
tests: true
105+
build-tags:
106+
- integration
107+
modules-download-mode: readonly

GNUmakefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CLI_SOURCE_FILES?=./cmd/plugin
2+
CLI_BINARY_NAME?=binary
3+
CLI_DESTINATION=./bin/$(CLI_BINARY_NAME)
4+
5+
GOLANGCI_VERSION=v1.63.4 # Also update golangci-lint GH action in code-health.yml when updating this version
6+
7+
.PHONY: build
8+
build:
9+
@echo "==> Building plugin binary: $(CLI_BINARY_NAME)"
10+
go build -o $(CLI_DESTINATION) $(CLI_SOURCE_FILES)
11+
12+
.PHONY: tools
13+
tools: ## Install dev tools
14+
@echo "==> Installing dependencies..."
15+
go telemetry off # disable sending telemetry data, more info: https://go.dev/doc/telemetry
16+
go install github.com/rhysd/actionlint/cmd/actionlint@latest
17+
go install golang.org/x/tools/go/analysis/passes/fieldalignment/cmd/fieldalignment@latest
18+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin $(GOLANGCI_VERSION)

0 commit comments

Comments
 (0)