Skip to content

Commit 2ecdbae

Browse files
chore: cleanup local golangci (#386)
* chore: cleanup local golangci * remove different golangci-config * add merge group step to push step * upgrade golangci to 1.56 * update golangci action * try skip cache golangci/golangci-lint-action#863 * try single golangci-lint * don't set only new issues in config * Update checks.yaml Co-authored-by: Dave Mihalcik <[email protected]> * log context * point to commit * only new issues on pr or merge group --------- Co-authored-by: Dave Mihalcik <[email protected]>
1 parent 1fe129f commit 2ecdbae

File tree

3 files changed

+16
-151
lines changed

3 files changed

+16
-151
lines changed

.github/workflows/checks.yaml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,27 +50,14 @@ jobs:
5050
- run: make go.work
5151
- run: go mod download
5252
- run: go mod verify
53-
- name: golangci-lint on PR
54-
if: github.event_name == 'pull_request'
55-
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc
53+
- name: golangci-lint
54+
#uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804
55+
uses: strantalis/golangci-lint-action@f4e979f5b36068d69d340547f66c991dca8b70ef
5656
with:
57-
version: v1.55
58-
working-directory: ${{ matrix.directory }}
59-
only-new-issues: true
60-
- name: golangci-lint on merge_group
61-
if: github.event_name == 'merge_group'
62-
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc
63-
with:
64-
version: v1.55
65-
working-directory: ${{ matrix.directory }}
66-
args: -c ${{ github.workspace }}/.golangci-ratchet.yaml
67-
- name: golangci-lint on push
68-
if: github.event_name == 'push'
69-
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc
70-
continue-on-error: true
71-
with:
72-
version: v1.55
57+
version: v1.56
7358
working-directory: ${{ matrix.directory }}
59+
skip-cache: true
60+
only-new-issues: ${{ (github.event_name == 'pull_request' || github.event_name == 'merge_group') }}
7461
- name: Install softHSM
7562
if: matrix.directory == '.'
7663
run: |-

.golangci-ratchet.yaml

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

.golangci.yaml

Lines changed: 10 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,6 @@ run:
77
- ".*\\.pb\\.gw.go"
88

99
linters-settings:
10-
ireturn:
11-
allow:
12-
- auth
13-
- error
14-
- Row
15-
- Rows
16-
- Leveler
17-
- Writer
18-
- Logger
19-
- Handler
20-
cyclop:
21-
# The maximal code complexity to report.
22-
# Default: 10
23-
max-complexity: 30
24-
# The maximal average package complexity.
25-
# If it's higher than 0.0 (float) the check is enabled
26-
# Default: 0.0
27-
package-average: 10.0
28-
2910
errcheck:
3011
# Report about not checking of errors in type assertions: `a := b.(MyStruct)`.
3112
# Such cases aren't reported by default.
@@ -39,21 +20,6 @@ linters-settings:
3920
- switch
4021
- map
4122

42-
funlen:
43-
# Checks the number of lines in a function.
44-
# If lower than 0, disable the check.
45-
# Default: 60
46-
lines: 100
47-
# Checks the number of statements in a function.
48-
# If lower than 0, disable the check.
49-
# Default: 40
50-
statements: 50
51-
52-
gocognit:
53-
# Minimal code complexity to report.
54-
# Default: 30 (but we recommend 10-20)
55-
min-complexity: 20
56-
5723
gocritic:
5824
# Settings passed to gocritic.
5925
# The settings key is the name of a supported gocritic checker.
@@ -83,7 +49,6 @@ linters-settings:
8349
- prometheus.ExponentialBuckets
8450
- prometheus.ExponentialBucketsRange
8551
- prometheus.LinearBuckets
86-
- wg.Add
8752

8853
gomodguard:
8954
blocked:
@@ -127,7 +92,7 @@ linters-settings:
12792
nolintlint:
12893
# Exclude following linters from requiring an explanation.
12994
# Default: []
130-
allow-no-explanation: [ funlen, gocognit, lll ]
95+
allow-no-explanation: []
13196
# Enable to require an explanation of nonzero length after each nolint directive.
13297
# Default: false
13398
require-explanation: true
@@ -147,21 +112,6 @@ linters-settings:
147112
# Default: false
148113
all: true
149114

150-
lll:
151-
line-length: 120
152-
153-
wrapcheck:
154-
ignoreSigs:
155-
- "status.Error("
156-
- ".Errorf("
157-
- "errors.New("
158-
- "errors.Unwrap("
159-
- "errors.Join("
160-
- ".Wrap("
161-
- ".Wrapf("
162-
- ".WithMessage("
163-
- ".WithMessagef("
164-
- ".WithStack("
165115
linters:
166116
disable-all: true
167117
enable:
@@ -178,31 +128,26 @@ linters:
178128
- asciicheck # checks that your code does not contain non-ASCII identifiers
179129
- bidichk # checks for dangerous unicode character sequences
180130
- bodyclose # checks whether HTTP response body is closed successfully
181-
- cyclop # checks function and package cyclomatic complexity
182-
- dupl # tool for code clone detection
131+
- containedctx # Containedctx is a linter that detects struct contained context.Context field.
132+
- contextcheck # checks the function whether use a non-inherited context
133+
#- copyloopvar # checks for copying a loop variable to a function literal (1.57)
183134
- durationcheck # checks for two durations multiplied together
184135
- errname # checks that sentinel errors are prefixed with the Err and error types are suffixed with the Error
185136
- errorlint # finds code that will cause problems with the error wrapping scheme introduced in Go 1.13
186137
- execinquery # checks query string in Query function which reads your Go src files and warning it finds
187138
- exhaustive # checks exhaustiveness of enum switch statements
188139
- exportloopref # checks for pointers to enclosing loop variables
189140
- forbidigo # forbids identifiers
190-
- funlen # tool for detection of long functions
141+
- forcetypeassert # finds forced type assertions
191142
- gocheckcompilerdirectives # validates go compiler directive comments (//go:)
192-
- gochecknoglobals # checks that no global variables exist
193-
#- gochecknoinits # checks that no init functions are present in Go code
194-
- gocognit # computes and checks the cognitive complexity of functions
195143
- goconst # finds repeated strings that could be replaced by a constant
196144
- gocritic # provides diagnostics that check for bugs, performance and style issues
197-
- gocyclo # computes and checks the cyclomatic complexity of functions
198-
# - godot # checks if comments end in a period
145+
- gofmt # checks whether code was gofmt-ed
199146
- goimports # in addition to fixing imports, goimports also formats your code in the same style as gofmt
200147
- gomnd # detects magic numbers
201-
# - gomoddirectives # manages the use of 'replace', 'retract', and 'excludes' directives in go.mod
202148
- gomodguard # allow and block lists linter for direct Go module dependencies. This is different from depguard where there are different block types for example version constraints and module recommendations
203149
- goprintffuncname # checks that printf-like functions are named with f at the end
204150
- gosec # inspects source code for security problems
205-
- lll # reports long lines
206151
- loggercheck # checks key value pairs for common logger libraries (kitlog,klog,logr,zap)
207152
- makezero # finds slice declarations with non-zero initial length
208153
- musttag # enforces field tags in (un)marshaled structs
@@ -216,13 +161,17 @@ linters:
216161
- nosprintfhostport # checks for misuse of Sprintf to construct a host with port in a URL
217162
- predeclared # finds code that shadows one of Go's predeclared identifiers
218163
- promlinter # checks Prometheus metrics naming via promlint
164+
- protogetter # Reports direct reads from proto message fields when getters should be used.
219165
- reassign # checks that package variables are not reassigned
220166
- revive # fast, configurable, extensible, flexible, and beautiful linter for Go, drop-in replacement of golint
221167
- rowserrcheck # checks whether Err of rows is checked successfully
168+
- sloglint # Ensure consistent code style when using log/slog.
169+
- spancheck # checks for incorrect usage of opentracing.Span
222170
- sqlclosecheck # checks that sql.Rows and sql.Stmt are closed
223171
- stylecheck # is a replacement for golint
224172
- tenv # detects using os.Setenv instead of t.Setenv since Go1.17
225173
- testableexamples # checks if examples are testable (have an expected output)
174+
- testifylint
226175
#- testpackage # makes you use a separate _test package
227176
- tparallel # detects inappropriate usage of t.Parallel() method in your Go test codes
228177
- unconvert # removes unnecessary type conversions
@@ -231,51 +180,6 @@ linters:
231180
- wastedassign # finds wasted assignment statements
232181
- whitespace # detects leading and trailing whitespace
233182

234-
## you may want to enable
235-
#- decorder # checks declaration order and count of types, constants, variables and functions
236-
#- gci # controls golang package import order and makes it always deterministic
237-
#- ginkgolinter # [if you use ginkgo/gomega] enforces standards of using ginkgo and gomega
238-
- godox # detects FIXME, TODO and other comment keywords
239-
#- goheader # checks is file header matches to pattern
240-
- interfacebloat # checks the number of methods inside an interface
241-
- ireturn # accept interfaces, return concrete types
242-
- prealloc # [premature optimization, but can be used in some cases] finds slice declarations that could potentially be preallocated
243-
#- varnamelen # [great idea, but too many false positives] checks that the length of a variable's name matches its scope
244-
- wrapcheck # checks that errors returned from external packages are wrapped
245-
246-
## disabled
247-
#- containedctx # detects struct contained context.Context field
248-
#- contextcheck # [too many false positives] checks the function whether use a non-inherited context
249-
#- depguard # [replaced by gomodguard] checks if package imports are in a list of acceptable packages
250-
#- dogsled # checks assignments with too many blank identifiers (e.g. x, _, _, _, := f())
251-
#- dupword # [useless without config] checks for duplicate words in the source code
252-
#- errchkjson # [don't see profit + I'm against of omitting errors like in the first example https://github.com/breml/errchkjson] checks types passed to the json encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted
253-
#- forcetypeassert # [replaced by errcheck] finds forced type assertions
254-
#- goerr113 # [too strict] checks the errors handling expressions
255-
#- gofmt # [replaced by goimports] checks whether code was gofmt-ed
256-
#- gofumpt # [replaced by goimports, gofumports is not available yet] checks whether code was gofumpt-ed
257-
#- grouper # analyzes expression groups
258-
#- importas # enforces consistent import aliases
259-
#- maintidx # measures the maintainability index of each function
260-
#- misspell # [useless] finds commonly misspelled English words in comments
261-
#- nlreturn # [too strict and mostly code is not more readable] checks for a new line before return and branch statements to increase code clarity
262-
#- paralleltest # [too many false positives] detects missing usage of t.Parallel() method in your Go test
263-
#- tagliatelle # checks the struct tags
264-
#- thelper # detects golang test helpers without t.Helper() call and checks the consistency of test helpers
265-
#- wsl # [too strict and mostly code is not more readable] whitespace linter forces you to use empty lines
266-
267-
## deprecated
268-
#- deadcode # [deprecated, replaced by unused] finds unused code
269-
#- exhaustivestruct # [deprecated, replaced by exhaustruct] checks if all struct's fields are initialized
270-
#- golint # [deprecated, replaced by revive] golint differs from gofmt. Gofmt reformats Go source code, whereas golint prints out style mistakes
271-
#- ifshort # [deprecated] checks that your code uses short syntax for if-statements whenever possible
272-
#- interfacer # [deprecated] suggests narrower interface types
273-
#- maligned # [deprecated, replaced by govet fieldalignment] detects Go structs that would take less memory if their fields were sorted
274-
#- nosnakecase # [deprecated, replaced by revive var-naming] detects snake case of variable naming and function name
275-
#- scopelint # [deprecated, replaced by exportloopref] checks for unpinned variables in go programs
276-
#- structcheck # [deprecated, replaced by unused] finds unused struct fields
277-
#- varcheck # [deprecated, replaced by unused] finds unused global variables and constants
278-
279183

280184
issues:
281185
# Maximum count of issues with the same text.
@@ -311,12 +215,3 @@ issues:
311215
- text: "http://www.apache.org/licenses/LICENSE-2.0"
312216
linters:
313217
- goimport
314-
315-
severity:
316-
default-severity: error
317-
rules:
318-
- linters:
319-
- dupl
320-
- godot
321-
- lll
322-
severity: info

0 commit comments

Comments
 (0)