Skip to content

Commit cd4ec7f

Browse files
author
Ariel Kass
committed
update golang-lint setings to v2
Signed-off-by: Ariel Kass <[email protected]>
1 parent 13c65d3 commit cd4ec7f

File tree

2 files changed

+104
-211
lines changed

2 files changed

+104
-211
lines changed
Lines changed: 84 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -1,183 +1,96 @@
1-
---
2-
# https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
3-
# This file contains all available configuration options
4-
# with their default values.
5-
6-
# options for analysis running
1+
version: "2"
72
run:
8-
# default concurrency is a available CPU number
93
concurrency: 4
10-
11-
# timeout for analysis, e.g. 30s, 5m, default is 1m
12-
deadline: 10m
13-
14-
# exit code when at least one issue was found, default is 1
15-
issues-exit-code: 1
16-
17-
# https://github.com/golangci/golangci-lint/blob/v1.23.6/.golangci.example.yml#L45-L49
184
modules-download-mode: vendor
19-
20-
# include test files or not, default is true
5+
issues-exit-code: 1
216
tests: true
22-
23-
# which dirs to skip: they won't be analyzed;
24-
# can use regexp here: generated.*, regexp is applied on full path;
25-
# default value is empty list, but next dirs are always skipped independently
26-
# from this option's value:
27-
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
28-
skip-dirs:
29-
- vendor$
30-
31-
# which files to skip: they will be analyzed, but issues from them
32-
# won't be reported. Default value is empty list, but there is
33-
# no need to include all autogenerated files, we confidently recognize
34-
# autogenerated files. If it's not please let us know.
35-
skip-files:
36-
37-
# output configuration options
38-
output:
39-
# colored-line-number|line-number|json|tab|checkstyle|code-climate,
40-
# default is "colored-line-number"
41-
format: colored-line-number
42-
43-
# print lines of code with issue, default is true
44-
print-issued-lines: true
45-
46-
# print linter name in the end of issue text, default is true
47-
print-linter-name: true
48-
49-
# all available settings of specific linters
50-
linters-settings:
51-
cyclop:
52-
max-complexity: 20
53-
errcheck:
54-
# report about not checking of errors in type assetions:
55-
# `a := b.(MyStruct)`;
56-
# default is false: such cases aren't reported by default.
57-
check-type-assertions: true
58-
59-
# report about assignment of errors to blank identifier:
60-
# `num, _ := strconv.Atoi(numStr)`;
61-
# default is false: such cases aren't reported by default.
62-
check-blank: true
63-
64-
# path to a file containing a list of functions to exclude from checking
65-
# see https://github.com/kisielk/errcheck#excluding-functions for details
66-
# exclude: /path/to/file.txt
67-
govet:
68-
# report about shadowed variables
69-
check-shadowing: true
70-
golint:
71-
# minimal confidence for issues, default is 0.8
72-
min-confidence: 0
73-
gofmt:
74-
# simplify code: gofmt with `-s` option, true by default
75-
simplify: true
76-
goimports:
77-
# put imports beginning with prefix after 3rd-party packages;
78-
# it's a comma-separated list of prefixes
79-
local-prefixes: github.com/csi-addons/volume-replication-operator
80-
gocyclo:
81-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
82-
min-complexity: 20
83-
maligned:
84-
# print struct with more effective memory layout or not, false by default
85-
suggest-new: true
86-
dupl:
87-
# tokens count to trigger issue, 150 by default
88-
threshold: 100
89-
goconst:
90-
# minimal length of string constant, 3 by default
91-
min-len: 3
92-
# minimal occurrences count to trigger, 3 by default
93-
min-occurrences: 3
94-
depguard:
95-
list-type: blacklist
96-
include-go-root: false
97-
packages:
98-
- github.com/davecgh/go-spew/spew
99-
misspell:
100-
# Correct spellings using locale preferences for US or UK.
101-
# Default is to use a neutral variety of English.
102-
# Setting locale to US will correct the British spelling of 'colour' to
103-
# 'color'.
104-
locale: US
105-
ignore-words:
106-
- someword
107-
lll:
108-
# max line length, lines longer will be reported. Default is 120.
109-
# '\t' is counted as 1 character by default, and can be changed with the
110-
# tab-width option
111-
line-length: 180
112-
# tab width in spaces. Default to 1.
113-
tab-width: 1
114-
gocritic:
115-
enabled-tags:
116-
- performance
117-
- style
118-
- experimental
119-
disabled-checks:
120-
- sloppyReassign
121-
- elseif
122-
- unslice
123-
- wrapperFunc
124-
- unnamedResult
125-
- dupImport # https://github.com/go-critic/go-critic/issues/845
126-
unused:
127-
# treat code as a program (not a library) and report unused exported
128-
# identifiers; default is false.
129-
# XXX: if you enable this setting, unused will report a lot of
130-
# false-positives in text editors:
131-
# if it's called for subdir of a project it can't find funcs usages.
132-
# All text editor integrations
133-
# with golangci-lint call it on a directory with the changed file.
134-
check-exported: false
135-
unparam:
136-
# Inspect exported functions, default is false. Set to true if no external
137-
# program/library imports your code.
138-
# XXX: if you enable this setting, unparam will report a lot of
139-
# false-positives in text editors:
140-
# if it's called for subdir of a project it can't find external
141-
# interfaces. All text editor integrations
142-
# with golangci-lint call it on a directory with the changed file.
143-
check-exported: false
144-
nakedret:
145-
# make an issue if func has more lines of code than this setting and
146-
# it has naked returns; default is 30
147-
max-func-lines: 30
148-
gocognit:
149-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
150-
# TODO: decrease complexity with refacoring the code
151-
min-complexity: 40
152-
dogsled:
153-
max-blank-identifiers: 3
154-
nestif:
155-
min-complexity: 7
156-
1577
linters:
158-
enable-all: true
8+
default: all
1599
disable:
160-
- gomnd
161-
- prealloc
10+
- cyclop
16211
- dupl
163-
- nestif
164-
- gochecknoinits
12+
- err113
13+
- forbidigo
14+
- funlen
16515
- gochecknoglobals
166-
- godox
167-
- maligned
168-
- wsl
16+
- gochecknoinits
16917
- gocognit
17018
- gocyclo
171-
- cyclop
172-
- funlen
173-
- interfacer
174-
- testpackage
175-
- exhaustivestruct
176-
- goerr113
177-
- forbidigo
178-
# TODO: enable gomoddirectives
19+
- godox
17920
- gomoddirectives
180-
# TODO: enable gci
181-
- gci
182-
# TODO: enable wrapcheck linter
21+
- mnd
22+
- nestif
23+
- prealloc
24+
- testpackage
18325
- wrapcheck
26+
- wsl
27+
settings:
28+
cyclop:
29+
max-complexity: 20
30+
dogsled:
31+
max-blank-identifiers: 3
32+
dupl:
33+
threshold: 100
34+
errcheck:
35+
check-type-assertions: true
36+
check-blank: true
37+
gocognit:
38+
min-complexity: 40
39+
goconst:
40+
min-len: 3
41+
min-occurrences: 3
42+
gocritic:
43+
disabled-checks:
44+
- sloppyReassign
45+
- elseif
46+
- unslice
47+
- wrapperFunc
48+
- unnamedResult
49+
- dupImport
50+
enabled-tags:
51+
- performance
52+
- style
53+
- experimental
54+
gocyclo:
55+
min-complexity: 20
56+
lll:
57+
line-length: 180
58+
tab-width: 1
59+
misspell:
60+
locale: US
61+
ignore-rules:
62+
- someword
63+
nakedret:
64+
max-func-lines: 30
65+
nestif:
66+
min-complexity: 7
67+
unparam:
68+
check-exported: false
69+
exclusions:
70+
generated: lax
71+
presets:
72+
- comments
73+
- common-false-positives
74+
- legacy
75+
- std-error-handling
76+
paths:
77+
- third_party$
78+
- builtin$
79+
- examples$
80+
formatters:
81+
enable:
82+
- gofmt
83+
- gofumpt
84+
- goimports
85+
settings:
86+
gofmt:
87+
simplify: true
88+
goimports:
89+
local-prefixes:
90+
- github.com/csi-addons/volume-replication-operator
91+
exclusions:
92+
generated: lax
93+
paths:
94+
- third_party$
95+
- builtin$
96+
- examples$
Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,20 @@
1-
name: golangci-lint
2-
3-
on:
4-
pull_request:
5-
branches: [ '*' ]
6-
7-
jobs:
8-
golangci:
9-
name: lint
10-
runs-on: ubuntu-latest
11-
steps:
12-
13-
- name: Set up Go
14-
uses: actions/setup-go@v5
15-
with:
16-
go-version: 1.24
17-
18-
- uses: actions/checkout@v4
19-
20-
21-
- name: golangci-lint
22-
uses: golangci/golangci-lint-action@v8
23-
with:
24-
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
25-
version: v2.3.0
26-
27-
# Optional: working directory, useful for monorepos
28-
# working-directory: somedir
29-
30-
# Optional: golangci-lint command line arguments.
31-
args: --config=./.github/workflows/config/lint-config.yml -v
32-
33-
# Optional: show only new issues if it's a pull request. The default value is `false`.
34-
# only-new-issues: true
35-
36-
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
37-
# skip-pkg-cache: true
38-
39-
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
40-
# skip-build-cache: true
1+
version: "2"
2+
linters:
3+
exclusions:
4+
generated: lax
5+
presets:
6+
- comments
7+
- common-false-positives
8+
- legacy
9+
- std-error-handling
10+
paths:
11+
- third_party$
12+
- builtin$
13+
- examples$
14+
formatters:
15+
exclusions:
16+
generated: lax
17+
paths:
18+
- third_party$
19+
- builtin$
20+
- examples$

0 commit comments

Comments
 (0)