Skip to content

Commit aafe6c3

Browse files
committed
[SP-2993] chore: update makefile, fix linting errors
1 parent 4b6fd3c commit aafe6c3

File tree

22 files changed

+606
-522
lines changed

22 files changed

+606
-522
lines changed

.golangci.yml

Lines changed: 206 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,235 @@
1+
# golangci-lint configuration
2+
# https://golangci-lint.run/usage/configuration/
3+
14
run:
2-
timeout: 3m
3-
skip-dirs:
4-
- tests
5+
timeout: 5m
6+
tests: true
57

6-
linters-settings:
7-
cyclop:
8-
max-complexity: 30
9-
package-average: 10.0
8+
output:
9+
formats:
10+
- format: colored-line-number
11+
print-issued-lines: true
12+
print-linter-name: true
13+
sort-results: true
14+
15+
linters:
16+
disable-all: true
17+
enable:
18+
# Enabled by default
19+
- errcheck # Checks for unchecked errors
20+
- gosimple # Simplifies code
21+
- govet # Reports suspicious constructs
22+
- ineffassign # Detects ineffectual assignments
23+
- staticcheck # Comprehensive static analysis
24+
- unused # Checks for unused code
25+
26+
# Error handling & bugs
27+
- errorlint # Find code that will cause problems with error wrapping
28+
- nilerr # Finds code that returns nil even if error is not nil
29+
30+
# Performance
31+
- prealloc # Finds slice declarations that could potentially be pre-allocated
32+
- bodyclose # Checks whether HTTP response body is closed successfully
33+
34+
# Style & code quality
35+
- gofmt # Checks whether code is formatted
36+
- gofumpt # Stricter gofmt
37+
- goimports # Checks import formatting
38+
- revive # Fast, configurable, extensible, flexible linter
39+
- stylecheck # Stylecheck is a replacement for golint
40+
- unconvert # Removes unnecessary type conversions
41+
- unparam # Reports unused function parameters
42+
- whitespace # Checks for unnecessary newlines
43+
- misspell # Finds commonly misspelled English words
44+
45+
# Code complexity
46+
- gocognit # Computes and checks cognitive complexity
47+
- gocyclo # Computes and checks cyclomatic complexity
48+
- funlen # Checks function length
49+
- nestif # Reports deeply nested if statements
50+
51+
# Potential bugs & best practices
52+
- goconst # Finds repeated strings that could be constants
53+
- gocritic # Comprehensive and opinionated linter
54+
- gosec # Security-focused linter
55+
- noctx # Finds HTTP requests without context.Context
56+
- sqlclosecheck # Checks sql.Rows and sql.Stmt are closed
1057

58+
# Code correctness
59+
- exhaustive # Checks exhaustiveness of enum switch statements
60+
- makezero # Finds slice declarations with non-zero initial length
61+
- predeclared # Finds code that shadows predeclared identifiers
62+
- reassign # Checks that package variables are not reassigned
63+
- usestdlibvars # Detects the possibility to use standard lib variables
64+
65+
# Comments & documentation
66+
- godot # Checks if comments end in a period
67+
68+
# Linter management
69+
- nolintlint # Reports ill-formed or insufficient nolint directives
70+
71+
linters-settings:
1172
errcheck:
1273
check-type-assertions: true
74+
check-blank: true
75+
exclude-functions:
76+
- (*database/sql.Rows).Close
77+
- (*database/sql.Stmt).Close
78+
79+
errorlint:
80+
errorf: true
81+
asserts: true
82+
comparison: true
1383

1484
exhaustive:
1585
check:
1686
- switch
1787
- map
88+
default-signifies-exhaustive: false
1889

1990
funlen:
20-
lines: 150
21-
statements: 80
91+
lines: 120
92+
statements: 60
93+
ignore-comments: true
2294

2395
gocognit:
24-
min-complexity: 25
96+
min-complexity: 20
97+
98+
gocyclo:
99+
min-complexity: 15
100+
101+
goconst:
102+
min-len: 3
103+
min-occurrences: 3
104+
ignore-tests: true
105+
106+
gocritic:
107+
enabled-tags:
108+
- diagnostic
109+
- style
110+
- performance
111+
- experimental
112+
- opinionated
113+
disabled-checks:
114+
- whyNoLint
115+
- unnamedResult
116+
settings:
117+
hugeParam:
118+
sizeThreshold: 256
119+
120+
gofumpt:
121+
extra-rules: true
122+
123+
goimports:
124+
local-prefixes: github.com/scanoss/folder-hashing-api
25125

26126
gosec:
127+
severity: medium
128+
confidence: medium
27129
excludes:
28-
- G204
130+
- G204 # Audit use of command execution - we'll check these manually
131+
- G304 # File path provided as taint input - check manually
29132

30133
govet:
31-
check-shadowing: true
32134
enable-all: true
33-
disable-all: false
34135
disable:
35-
- fieldalignment
136+
- fieldalignment # Can be too noisy
137+
- shadow # Often produces false positives
36138

37-
nakedret:
38-
max-func-lines: 10
139+
misspell:
140+
locale: US
141+
ignore-words:
142+
- scanoss
39143

40-
lll:
41-
line-length: 180
144+
nestif:
145+
min-complexity: 5
146+
147+
nolintlint:
148+
allow-unused: false
149+
allow-no-explanation: []
150+
require-explanation: true
151+
require-specific: true
152+
153+
prealloc:
154+
simple: true
155+
range-loops: true
156+
for-loops: true
157+
158+
revive:
159+
rules:
160+
- name: blank-imports
161+
- name: context-as-argument
162+
- name: context-keys-type
163+
- name: dot-imports
164+
- name: error-return
165+
- name: error-strings
166+
- name: error-naming
167+
- name: exported
168+
- name: increment-decrement
169+
- name: var-naming
170+
- name: var-declaration
171+
- name: package-comments
172+
- name: range
173+
- name: receiver-naming
174+
- name: time-naming
175+
- name: unexported-return
176+
- name: indent-error-flow
177+
- name: errorf
178+
- name: empty-block
179+
- name: superfluous-else
180+
- name: unused-parameter
181+
- name: unreachable-code
182+
- name: redefines-builtin-id
183+
184+
staticcheck:
185+
checks: ["all"]
186+
187+
stylecheck:
188+
checks: ["all", "-ST1000", "-ST1003"]
189+
dot-import-whitelist: []
190+
http-status-code-whitelist: []
191+
192+
unparam:
193+
check-exported: false
42194

43-
linters:
44-
enable:
45-
- cyclop
46-
- errname
47-
- exhaustive
48-
- funlen
49-
- gocognit
50-
- goconst
51-
- gocritic
52-
- godot
53-
- goimports
54-
- gosec
55-
- lll
56-
- loggercheck
57-
- makezero
58-
- nakedret
59-
- nilerr
60-
- nilnil
61-
- nolintlint
62-
- nonamedreturns
63-
- predeclared
64-
- reassign
65-
- stylecheck
66-
- unconvert
67-
- unparam
68-
- usestdlibvars
69-
- whitespace
70195
issues:
196+
max-issues-per-linter: 0
197+
max-same-issues: 0
198+
199+
exclude-dirs:
200+
- vendor
201+
- third_party
202+
203+
exclude-files:
204+
- ".*\\.pb\\.go$"
205+
- ".*_gen\\.go$"
206+
71207
exclude-rules:
208+
# Exclude some linters from running on tests files
72209
- path: _test\.go
73210
linters:
74211
- gocognit
212+
- gocyclo
213+
- funlen
214+
- goconst
215+
- gosec
216+
- errcheck
217+
218+
# Exclude godot for TODO comments
219+
- source: "// TODO"
220+
linters:
221+
- godot
222+
223+
# Allow complex main functions
224+
- path: cmd/
225+
linters:
226+
- funlen
227+
- gocognit
228+
229+
# Exclude ineffassign for err variables that are shadowed
230+
- linters:
231+
- ineffassign
232+
text: "ineffectual assignment to err"
233+
234+
exclude-use-default: false
235+
exclude-case-sensitive: false

0 commit comments

Comments
 (0)