Skip to content

Commit 786d9f3

Browse files
committed
chore: update lint config
Signed-off-by: Dario Faccin <[email protected]>
1 parent b439e04 commit 786d9f3

File tree

2 files changed

+250
-110
lines changed

2 files changed

+250
-110
lines changed

.github/workflows/main.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
branch_name: ${{ github.ref }}
1818

19-
staticcheck:
19+
static-analysis:
2020
uses: omec-project/.github/.github/workflows/static-analysis.yml@main
2121
with:
2222
branch_name: ${{ github.ref }}
@@ -31,7 +31,7 @@ jobs:
3131
with:
3232
branch_name: ${{ github.ref }}
3333

34-
fossa-check:
34+
fossa-scan:
3535
uses: omec-project/.github/.github/workflows/fossa-scan.yml@main
3636
with:
3737
branch_name: ${{ github.ref }}

.golangci.yml

+248-108
Original file line numberDiff line numberDiff line change
@@ -1,130 +1,270 @@
11
# SPDX-FileCopyrightText: 2025 Intel Corporation
2+
# Copyright 2025 Canonical Ltd.
3+
#
24
# SPDX-License-Identifier: Apache-2.0
5+
#
36

4-
version: "2"
7+
# This file contains all available configuration options
8+
# with their default values.
9+
# options for analysis running
510
run:
11+
# default concurrency is a available CPU number
612
concurrency: 4
13+
# timeout for analysis, e.g. 30s, 5m, default is 1m
14+
timeout: 1m
15+
# exit code when at least one issue was found, default is 1
716
issues-exit-code: 1
17+
# include test files or not, default is true
818
tests: true
19+
# list of build tags, all linters use it. Default is empty list.
20+
build-tags: []
21+
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
22+
# If invoked with -mod=readonly, the go command is disallowed from the implicit
23+
# automatic updating of go.mod described above. Instead, it fails when any changes
24+
# to go.mod are needed. This setting is most useful to check that go.mod does
25+
# not need updates, such as in a continuous integration and testing system.
26+
# If invoked with -mod=vendor, the go command assumes that the vendor
27+
# directory holds the correct copies of dependencies and ignores
28+
# the dependency descriptions in go.mod.
29+
#modules-download-mode: readonly|release|vendor
30+
# Allow multiple parallel golangci-lint instances running.
31+
# If false (default) - golangci-lint acquires file lock on start.
932
allow-parallel-runners: true
33+
# output configuration options
1034
output:
35+
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
1136
formats:
12-
text:
13-
path: stdout
14-
print-linter-name: true
15-
print-issued-lines: true
37+
- format: colored-line-number
38+
# print lines of code with issue, default is true
39+
print-issued-lines: true
40+
# print linter name in the end of issue text, default is true
41+
print-linter-name: true
42+
# all available settings of specific linters
43+
linters-settings:
44+
errcheck:
45+
# report about not checking of errors in type assertions: `a := b.(MyStruct)`;
46+
# default is false: such cases aren't reported by default.
47+
check-type-assertions: false
48+
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
49+
# default is false: such cases aren't reported by default.
50+
check-blank: true
51+
# [deprecated] comma-separated list of pairs of the form pkg:regex
52+
# the regex is used to ignore names within pkg. (default "fmt:.*").
53+
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
54+
#ignore: fmt:.*,io/ioutil:^Read.*
55+
# path to a file containing a list of functions to exclude from checking
56+
# see https://github.com/kisielk/errcheck#excluding-functions for details
57+
#exclude: /path/to/file.txt
58+
funlen:
59+
lines: 60
60+
statements: 40
61+
gocognit:
62+
# minimal code complexity to report, 30 by default (but we recommend 10-20)
63+
min-complexity: 10
64+
nestif:
65+
# minimal complexity of if statements to report, 5 by default
66+
min-complexity: 4
67+
goconst:
68+
# minimal length of string constant, 3 by default
69+
min-len: 3
70+
# minimal occurrences count to trigger, 3 by default
71+
min-occurrences: 3
72+
gocritic:
73+
# Which checks should be enabled; can't be combined with 'disabled-checks';
74+
# See https://go-critic.github.io/overview#checks-overview
75+
# To check which checks are enabled run `GL_DEBUG=gocritic golangci-lint run`
76+
# By default list of stable checks is used.
77+
# enabled-checks:
78+
# - rangeValCopy
79+
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
80+
disabled-checks:
81+
- regexpMust
82+
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
83+
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
84+
enabled-tags:
85+
- performance
86+
disabled-tags:
87+
- experimental
88+
settings: # settings passed to gocritic
89+
captLocal: # must be valid enabled check name
90+
paramsOnly: true
91+
rangeValCopy:
92+
sizeThreshold: 32
93+
gocyclo:
94+
# minimal code complexity to report, 30 by default (but we recommend 10-20)
95+
min-complexity: 10
96+
godox:
97+
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
98+
# might be left in the code accidentally and should be resolved before merging
99+
keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting
100+
#- TODO
101+
- FIXME
102+
- BUG
103+
#- NOTE
104+
#- OPTIMIZE # marks code that should be optimized before merging
105+
#- HACK # marks hack-arounds that should be removed before merging
106+
- XXX # Fatal! Important problem
107+
gofmt:
108+
# simplify code: gofmt with `-s` option, true by default
109+
simplify: true
110+
goimports:
111+
# put imports beginning with prefix after 3rd-party packages;
112+
# it's a comma-separated list of prefixes
113+
local-prefixes: github.com/omec-project
114+
# gomodguard:
115+
# allowed:
116+
# modules: # List of allowed modules
117+
# - gopkg.in/yaml.v2
118+
# domains: # List of allowed module domains
119+
# - golang.org
120+
# blocked:
121+
# modules: # List of blocked modules
122+
# - github.com/uudashr/go-module: # Blocked module
123+
# recommendations: # Recommended modules that should be used instead (Optional)
124+
# - golang.org/x/mod
125+
# reason: "`mod` is the official go.mod parser library." # Reason why the recommended module should be used (Optional)
126+
# versions: # List of blocked module version constraints
127+
# - github.com/mitchellh/go-homedir: # Blocked module with version constraint
128+
# version: "< 1.1.0" # Version constraint, see https://github.com/Masterminds/semver#basic-comparisons
129+
# reason: "testing if blocked version constraint works." # Reason why the version constraint exists. (Optional)
130+
govet:
131+
# settings per analyzer
132+
settings:
133+
printf: # analyzer name, run `go tool vet help` to see all analyzers
134+
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
135+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
136+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
137+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
138+
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
139+
# enable all analyzers
140+
enable-all: true
141+
lll:
142+
# max line length, lines longer will be reported. Default is 120.
143+
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
144+
line-length: 120
145+
# tab width in spaces. Default to 1.
146+
tab-width: 1
147+
nakedret:
148+
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
149+
max-func-lines: 30
150+
testpackage:
151+
# regexp pattern to skip files
152+
skip-regexp: (export|internal)_test\.go
153+
whitespace:
154+
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
155+
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
156+
# misspell:
157+
#locale: US
158+
# ignore-words:
159+
wsl:
160+
# If true append is only allowed to be cuddled if appending value is
161+
# matching variables, fields or types on line above. Default is true.
162+
strict-append: true
163+
# Allow calls and assignments to be cuddled as long as the lines have any
164+
# matching variables, fields or types. Default is true.
165+
allow-assign-and-call: true
166+
# Allow multiline assignments to be cuddled. Default is true.
167+
allow-multiline-assign: true
168+
# Allow declarations (var) to be cuddled.
169+
allow-cuddle-declarations: false
170+
# Allow trailing comments in ending of blocks
171+
allow-trailing-comment: true
172+
# Force newlines in end of case at this limit (0 = never).
173+
force-case-trailing-whitespace: 0
174+
# Force cuddling of err checks with err var assignment
175+
force-err-cuddling: false
176+
# Allow leading comments to be separated with empty liens
177+
allow-separated-leading-comment: false
178+
16179
linters:
17180
enable:
18-
- asciicheck
19-
- dogsled
20-
- goconst
181+
- gofmt
182+
# - govet
183+
- errcheck
184+
- unused
185+
- gosimple
186+
- ineffassign
187+
- typecheck
188+
# Additional
189+
# - lll
21190
- godox
191+
# - mnd
192+
- goconst
193+
# - gocognit
194+
# - nestif
22195
- gomodguard
23-
- misspell
24196
- nakedret
25-
- noctx
26-
- predeclared
27-
- unconvert
28-
- unparam
197+
- gci
198+
- misspell
199+
- gofumpt
29200
- whitespace
30-
disable:
31-
- staticcheck
32-
settings:
33-
errcheck:
34-
check-type-assertions: false
35-
check-blank: true
36-
funlen:
37-
lines: 60
38-
statements: 40
39-
gocognit:
40-
min-complexity: 10
41-
goconst:
42-
min-len: 3
43-
min-occurrences: 3
44-
gocritic:
45-
disabled-checks:
46-
- regexpMust
47-
enabled-tags:
48-
- performance
49-
disabled-tags:
50-
- experimental
51-
settings:
52-
captLocal:
53-
paramsOnly: true
54-
rangeValCopy:
55-
sizeThreshold: 32
56-
gocyclo:
57-
min-complexity: 10
58-
godox:
59-
keywords:
60-
- FIXME
61-
- BUG
62-
- XXX
63-
govet:
64-
enable-all: true
65-
settings:
66-
printf:
67-
funcs:
68-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
69-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
70-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
71-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
72-
lll:
73-
line-length: 120
74-
tab-width: 1
75-
nakedret:
76-
max-func-lines: 30
77-
nestif:
78-
min-complexity: 4
79-
testpackage:
80-
skip-regexp: (export|internal)_test\.go
81-
whitespace:
82-
multi-if: false
83-
multi-func: false
84-
wsl:
85-
strict-append: true
86-
allow-assign-and-call: true
87-
allow-multiline-assign: true
88-
force-case-trailing-whitespace: 0
89-
allow-trailing-comment: true
90-
allow-separated-leading-comment: false
91-
allow-cuddle-declarations: false
92-
force-err-cuddling: false
93-
exclusions:
94-
generated: lax
95-
presets:
96-
- comments
97-
- common-false-positives
98-
- legacy
99-
- std-error-handling
100-
paths:
101-
- third_party$
102-
- builtin$
103-
- examples$
201+
- unconvert
202+
- predeclared
203+
- noctx
204+
- dogsled
205+
- bodyclose
206+
- asciicheck
207+
# - stylecheck
208+
# - unparam
209+
# - wsl
210+
211+
#disable-all: false
212+
fast: true
104213
issues:
105-
uniq-by-line: true
106-
new-from-rev: ""
214+
# List of regexps of issue texts to exclude, empty list by default.
215+
# But independently from this option we use default exclude patterns,
216+
# it can be disabled by `exclude-use-default: false`. To list all
217+
# excluded by default patterns execute `golangci-lint run --help`
218+
exclude: []
219+
# Excluding configuration per-path, per-linter, per-text and per-source
220+
exclude-rules: []
221+
# Exclude some linters from running on tests files.
222+
# Independently from option `exclude` we use default exclude patterns,
223+
# it can be disabled by this option. To list all
224+
# excluded by default patterns execute `golangci-lint run --help`.
225+
# Default value for this option is true.
226+
exclude-use-default: true
227+
# The default value is false. If set to true exclude and exclude-rules
228+
# regular expressions become case sensitive.
229+
exclude-case-sensitive: false
230+
# The list of ids of default excludes to include or disable. By default it's empty.
231+
include: []
232+
#- EXC0002 # disable excluding of issues about comments from golint
233+
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
234+
#max-issues-per-linter: 0
235+
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
236+
#max-same-issues: 0
237+
# Show only new issues: if there are unstaged changes or untracked files,
238+
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
239+
# It's a super-useful option for integration of golangci-lint into existing
240+
# large codebase. It's not practical to fix all existing issues at the moment
241+
# of integration: much better don't allow issues in new code.
242+
# Default is false.
107243
new: false
244+
# Show only new issues created after git revision `REV`
245+
new-from-rev: ""
246+
# Show only new issues created in git patch with set file path.
247+
#new-from-patch: path/to/patch/file
248+
uniq-by-line: true
108249
severity:
109-
default: error
250+
# Default value is empty string.
251+
# Set the default severity for issues. If severity rules are defined and the issues
252+
# do not match or no severity is provided to the rule this will be the default
253+
# severity applied. Severities should match the supported severity names of the
254+
# selected out format.
255+
# - Code climate: https://docs.codeclimate.com/docs/issues#issue-severity
256+
# - Checkstyle: https://checkstyle.sourceforge.io/property_types.html#severity
257+
# - Github: https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-error-message
258+
default-severity: error
259+
# The default value is false.
260+
# If set to true severity-rules regular expressions become case sensitive.
261+
case-sensitive: false
262+
# Default value is empty list.
263+
# When a list of severity rules are provided, severity information will be added to lint
264+
# issues. Severity rules have the same filtering capability as exclude rules except you
265+
# are allowed to specify one matcher per severity rule.
266+
# Only affects out formats that support setting severity information.
110267
rules:
111268
- linters:
112-
- mnd
269+
- gomnd
113270
severity: ignore
114-
formatters:
115-
enable:
116-
- gci
117-
- gofmt
118-
- gofumpt
119-
settings:
120-
gofmt:
121-
simplify: true
122-
goimports:
123-
local-prefixes:
124-
- github.com/omec-project
125-
exclusions:
126-
generated: lax
127-
paths:
128-
- third_party$
129-
- builtin$
130-
- examples$

0 commit comments

Comments
 (0)