Skip to content

Commit 805e0d1

Browse files
committed
BUILD/MEDIUM: update linters, use local version
1 parent 4ad3136 commit 805e0d1

File tree

6 files changed

+74
-18
lines changed

6 files changed

+74
-18
lines changed

.github/workflows/lint.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,23 @@ on:
55
- master
66
jobs:
77
golangci-lint:
8-
name: runner / golangci-lint
8+
name: golangci-lint
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Check out code into the Go module directory
12-
uses: actions/checkout@v1
13-
- name: golangci-lint
14-
uses: reviewdog/action-golangci-lint@v1
12+
uses: actions/checkout@v2
13+
- name: Set up Go
14+
uses: actions/setup-go@v2
1515
with:
16-
github_token: ${{ secrets.github_token }}
16+
go-version: 1.19
17+
- uses: actions/cache@v2
18+
with:
19+
path: |
20+
~/.cache/go-build
21+
~/go/pkg/mod
22+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
23+
restore-keys: |
24+
${{ runner.os }}-go-
25+
- name: Lint
26+
run: |
27+
make lint

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ vendor/
33
cmd/dataplaneapi/*
44
.vscode/
55
.test/
6+
bin/golangci-lint

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ golangci-lint:
3434
paths:
3535
- build
3636
image:
37-
name: $CI_REGISTRY_GO/lint:1.50.0
37+
name: $CI_REGISTRY_GO/golang:1.19
3838
entrypoint: [""]
3939
tags:
4040
- go
4141
script:
42-
- golangci-lint run --timeout 5m --color always --max-issues-per-linter 0 --max-same-issues 0
42+
- make lint
4343
rules:
4444
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
4545
- if: $CI_PIPELINE_SOURCE == 'push'

.golangci.yml

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,58 @@ linters-settings:
44
golint:
55
min-confidence: 0
66
gocyclo:
7-
min-complexity: 25
7+
min-complexity: 42
88
maligned:
99
suggest-new: true
1010
dupl:
1111
threshold: 200
1212
goconst:
1313
min-len: 2
1414
min-occurrences: 2
15-
15+
revive:
16+
rules:
17+
- name: var-naming
18+
severity: warning
19+
disabled: true
1620
linters:
17-
enable:
18-
- golint
19-
- gocritic
20-
- stylecheck
21-
- goimports
22-
- gosec
23-
- unconvert
21+
enable-all: true
2422
disable:
25-
- maligned
26-
- prealloc
23+
- dupl
24+
- exhaustive
25+
- exhaustivestruct
26+
- funlen
27+
- gci
2728
- gochecknoglobals
29+
- gocognit
30+
- goconst
31+
- gocyclo
32+
- godot
33+
- goerr113
34+
- gomnd
35+
- lll
36+
- nestif
37+
- nlreturn
38+
- wrapcheck
39+
- wsl
40+
- nakedret
41+
- paralleltest
42+
- testpackage
43+
- varnamelen
44+
- nosnakecase
45+
- exhaustruct
46+
- nonamedreturns
47+
- forcetypeassert
48+
- golint #deprecated
49+
- varcheck #deprecated
50+
- ifshort #deprecated
51+
- structcheck #deprecated
52+
- maligned #deprecated
53+
- scopelint #deprecated
54+
- interfacer #deprecated
55+
- deadcode #deprecated
56+
- rowserrcheck #rowserrcheck is disabled because of generics
57+
- sqlclosecheck #rowserrcheck is disabled because of generics
58+
- wastedassign #rowserrcheck is disabled because of generics
2859

2960
issues:
3061
exclude-rules:

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,18 @@ GIT_MODIFIED=${GIT_MODIFIED1}${GIT_MODIFIED2}
99
SWAGGER_VERSION=${shell curl -s https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep SWAGGER_VERSION -m 1 | awk -F"=" '{print $$2}'}
1010
BUILD_DATE=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
1111
CGO_ENABLED?=0
12+
GOLANGCI_LINT_VERSION=1.50.1
1213

1314
all: update clean build
1415

1516
update:
1617
go mod tidy
1718

19+
.PHONY: lint
20+
lint:
21+
cd bin;GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION} sh lint-check.sh
22+
bin/golangci-lint run --timeout 5m --color always --max-issues-per-linter 0 --max-same-issues 0
23+
1824
clean:
1925
rm -rf ${DATAPLANEAPI_PATH}/build
2026

bin/lint-check.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
V=$(./golangci-lint --version)
3+
4+
case "$V" in
5+
*$GOLANGCI_LINT_VERSION*) echo "$V" ;;
6+
*) curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(pwd) "v$GOLANGCI_LINT_VERSION" ;;
7+
esac

0 commit comments

Comments
 (0)