Skip to content

Commit b5f0c23

Browse files
committed
1558 add linter
1 parent dd57f77 commit b5f0c23

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed

.golangci.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# This file was inspired by the golangci-lint one:
2+
# https://github.com/golangci/golangci-lint/blob/master/.golangci.yml
3+
run:
4+
# default concurrency is a available CPU number
5+
concurrency: 4
6+
7+
# timeout for analysis, e.g. 30s, 5m, default is 1m
8+
timeout: 5m
9+
linters-settings:
10+
govet:
11+
check-shadowing: true
12+
golint:
13+
min-confidence: 0
14+
gocyclo:
15+
min-complexity: 20
16+
gocognit:
17+
min-complexity: 100
18+
maligned:
19+
suggest-new: true
20+
dupl:
21+
threshold: 100
22+
goconst:
23+
min-len: 2
24+
min-occurrences: 2
25+
misspell:
26+
locale: UK
27+
lll:
28+
line-length: 140
29+
gofmt:
30+
simplify: false
31+
gocritic:
32+
enabled-tags:
33+
- diagnostic
34+
- experimental
35+
- opinionated
36+
- performance
37+
- style
38+
disabled-checks:
39+
- wrapperFunc
40+
- dupImport # https://github.com/go-critic/go-critic/issues/845
41+
- ifElseChain
42+
- octalLiteral
43+
- hugeParam
44+
# lines: 100
45+
# statements: 100
46+
47+
linters:
48+
# please, do not use `enable-all`: it's deprecated and will be removed soon.
49+
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
50+
disable-all: true
51+
enable:
52+
- depguard
53+
- dogsled
54+
- gochecknoinits
55+
- gocritic
56+
- gocyclo
57+
- gofmt
58+
- goimports
59+
- revive
60+
- gosec
61+
- govet
62+
- ineffassign
63+
- nakedret
64+
- unconvert
65+
- whitespace
66+
- gocognit
67+
- prealloc
68+
69+
issues:
70+
exclude-rules:
71+
- path: _test\.go
72+
linters:
73+
- gocyclo
74+
- errcheck
75+
- dupl
76+
- gosec
77+
- goconst
78+
- revive
79+
- gocritic
80+
- ineffassign
81+
- govet
82+
- path: main.go|handlers
83+
linters:
84+
- typecheck
85+
new: false
86+
87+
# golangci.com configuration
88+
# https://github.com/golangci/golangci/wiki/Configuration
89+
service:
90+
golangci-lint-version: 1.52.x # use the fixed version to not introduce new linters unexpectedly
91+
prepare:
92+
- echo "here I can run custom commands, but no preparation needed for this repo"

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ debug: generate-debug
2121
go build -tags 'debug' -o $(BINPATH)/dp-frontend-dataset-controller -ldflags "-X main.BuildTime=$(BUILD_TIME) -X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)"
2222
HUMAN_LOG=1 DEBUG=1 $(BINPATH)/dp-frontend-dataset-controller
2323

24+
.PHONY: lint
25+
lint:
26+
go install github.com/golangci/golangci-lint/cmd/[email protected]
27+
golangci-lint run ./...
28+
2429
.PHONY: run
2530
run:
2631
HUMAN_LOG=1 go run -tags 'production' -ldflags "-X main.BuildTime=$(BUILD_TIME) -X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)" -race $(LDFLAGS) main.go

ci/lint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
3+
platform: linux
4+
5+
image_resource:
6+
type: docker-image
7+
source:
8+
repository: golang
9+
tag: 1.20.4
10+
11+
inputs:
12+
- name: dp-frontend-dataset-controller
13+
14+
caches:
15+
- path: go/
16+
17+
run:
18+
path: dp-frontend-dataset-controller/ci/scripts/lint.sh

ci/scripts/lint.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash -eux
2+
3+
cwd=$(pwd)
4+
5+
pushd $cwd/dp-frontend-dataset-controller
6+
make lint
7+
popd

0 commit comments

Comments
 (0)