Skip to content

Commit a891816

Browse files
authored
Merge pull request #174 from hatappi/re-asses-lint
Re-asses lint
2 parents 90a2d12 + 2e858d3 commit a891816

35 files changed

+705
-1000
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
go-version-file: go.mod
4444

4545
- name: Install lint tools
46-
run: make install-tools
46+
run: make tools
4747

4848
- name: Set Reviewdog args
4949
id: reviewdog

.golangci.yml

Lines changed: 49 additions & 303 deletions
Original file line numberDiff line numberDiff line change
@@ -1,334 +1,80 @@
1-
# This file contains all available configuration options
2-
# with their default values.
3-
4-
# options for analysis running
51
run:
6-
# default concurrency is a available CPU number
7-
concurrency: 4
8-
9-
# timeout for analysis, e.g. 30s, 5m, default is 1m
10-
timeout: 1m
11-
12-
# exit code when at least one issue was found, default is 1
2+
timeout: 5m
133
issues-exit-code: 1
14-
15-
# include test files or not, default is true
164
tests: true
17-
18-
# list of build tags, all linters use it. Default is empty list.
19-
build-tags:
20-
- mytag
21-
22-
# which dirs to skip: issues from them won't be reported;
23-
# can use regexp here: generated.*, regexp is applied on full path;
24-
# default value is empty list, but default dirs are skipped independently
25-
# from this option's value (see skip-dirs-use-default).
26-
skip-dirs:
27-
- src/external_libs
28-
- autogenerated_by_my_lib
29-
30-
# default is true. Enables skipping of directories:
31-
# vendor$, third_party$, testdata$, examples$, Godeps$, builtin$
325
skip-dirs-use-default: true
6+
modules-download-mode: readonly
7+
allow-parallel-runners: true
338

34-
# which files to skip: they will be analyzed, but issues from them
35-
# won't be reported. Default value is empty list, but there is
36-
# no need to include all autogenerated files, we confidently recognize
37-
# autogenerated files. If it's not please let us know.
38-
skip-files:
39-
- ".*\\.my\\.go$"
40-
- lib/bad.go
41-
42-
# by default isn't set. If set we pass it to "go list -mod={option}". From "go help modules":
43-
# If invoked with -mod=readonly, the go command is disallowed from the implicit
44-
# automatic updating of go.mod described above. Instead, it fails when any changes
45-
# to go.mod are needed. This setting is most useful to check that go.mod does
46-
# not need updates, such as in a continuous integration and testing system.
47-
# If invoked with -mod=vendor, the go command assumes that the vendor
48-
# directory holds the correct copies of dependencies and ignores
49-
# the dependency descriptions in go.mod.
50-
# modules-download-mode: vendor
51-
52-
53-
# output configuration options
549
output:
55-
# colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number"
5610
format: colored-line-number
57-
58-
# print lines of code with issue, default is true
5911
print-issued-lines: true
60-
61-
# print linter name in the end of issue text, default is true
6212
print-linter-name: true
6313

64-
65-
# all available settings of specific linters
6614
linters-settings:
6715
errcheck:
68-
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
69-
# default is false: such cases aren't reported by default.
70-
check-type-assertions: false
71-
72-
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
73-
# default is false: such cases aren't reported by default.
7416
check-blank: false
7517

76-
# [deprecated] comma-separated list of pairs of the form pkg:regex
77-
# the regex is used to ignore names within pkg. (default "fmt:.*").
78-
# see https://github.com/kisielk/errcheck#the-deprecated-method for details
79-
ignore: fmt:.*,io/ioutil:^Read.*
80-
81-
# path to a file containing a list of functions to exclude from checking
82-
# see https://github.com/kisielk/errcheck#excluding-functions for details
83-
# exclude: /path/to/file.txt
84-
85-
funlen:
86-
lines: 130
87-
statements: 60
88-
8918
govet:
90-
# report about shadowed variables
19+
enable-all: true
9120
check-shadowing: true
92-
93-
# settings per analyzer
94-
settings:
95-
printf: # analyzer name, run `go tool vet help` to see all analyzers
96-
funcs: # run `go tool vet help printf` to see available settings for `printf` analyzer
97-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Infof
98-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Warnf
99-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
100-
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
101-
102-
# enable or disable analyzers by name
103-
enable:
104-
- atomicalign
105-
enable-all: false
10621
disable:
107-
- shadow
108-
disable-all: false
109-
golint:
110-
# minimal confidence for issues, default is 0.8
111-
min-confidence: 0.8
22+
- fieldalignment
23+
11224
gofmt:
113-
# simplify code: gofmt with `-s` option, true by default
11425
simplify: true
115-
goimports:
116-
# put imports beginning with prefix after 3rd-party packages;
117-
# it's a comma-separated list of prefixes
118-
local-prefixes: github.com/org/project
119-
gocyclo:
120-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
121-
min-complexity: 30
122-
gocognit:
123-
# minimal code complexity to report, 30 by default (but we recommend 10-20)
124-
min-complexity: 10
125-
maligned:
126-
# print struct with more effective memory layout or not, false by default
127-
suggest-new: true
128-
dupl:
129-
# tokens count to trigger issue, 150 by default
130-
threshold: 100
131-
goconst:
132-
# minimal length of string constant, 3 by default
133-
min-len: 3
134-
# minimal occurrences count to trigger, 3 by default
135-
min-occurrences: 3
136-
depguard:
137-
list-type: blacklist
138-
include-go-root: false
139-
packages:
140-
- github.com/sirupsen/logrus
141-
packages-with-error-message:
142-
# specify an error message to output when a blacklisted package is used
143-
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
144-
misspell:
145-
# Correct spellings using locale preferences for US or UK.
146-
# Default is to use a neutral variety of English.
147-
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
148-
locale: US
149-
ignore-words:
150-
- someword
151-
lll:
152-
# max line length, lines longer will be reported. Default is 120.
153-
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
154-
line-length: 128
155-
# tab width in spaces. Default to 1.
156-
tab-width: 1
157-
unused:
158-
# treat code as a program (not a library) and report unused exported identifiers; default is false.
159-
# XXX: if you enable this setting, unused will report a lot of false-positives in text editors:
160-
# if it's called for subdir of a project it can't find funcs usages. All text editor integrations
161-
# with golangci-lint call it on a directory with the changed file.
162-
check-exported: false
163-
unparam:
164-
# Inspect exported functions, default is false. Set to true if no external program/library imports your code.
165-
# XXX: if you enable this setting, unparam will report a lot of false-positives in text editors:
166-
# if it's called for subdir of a project it can't find external interfaces. All text editor integrations
167-
# with golangci-lint call it on a directory with the changed file.
168-
check-exported: false
169-
nakedret:
170-
# make an issue if func has more lines of code than this setting and it has naked returns; default is 30
171-
max-func-lines: 30
172-
prealloc:
173-
# XXX: we don't recommend using this linter before doing performance profiling.
174-
# For most programs usage of prealloc will be a premature optimization.
175-
176-
# Report preallocation suggestions only on simple loops that have no returns/breaks/continues/gotos in them.
177-
# True by default.
178-
simple: true
179-
range-loops: true # Report preallocation suggestions on range loops, true by default
180-
for-loops: false # Report preallocation suggestions on for loops, false by default
181-
gocritic:
182-
183-
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
184-
disabled-checks:
185-
- regexpMust
186-
187-
# Enable multiple checks by tags, run `GL_DEBUG=gocritic golangci-lint run` to see all tags and checks.
188-
# Empty list by default. See https://github.com/go-critic/go-critic#usage -> section "Tags".
189-
enabled-tags:
190-
- performance
19126

192-
settings: # settings passed to gocritic
193-
captLocal: # must be valid enabled check name
194-
paramsOnly: true
195-
rangeValCopy:
196-
sizeThreshold: 32
197-
godox:
198-
# report any comments starting with keywords, this is useful for TODO or FIXME comments that
199-
# might be left in the code accidentally and should be resolved before merging
200-
keywords: # default keywords are TODO, BUG, and FIXME, these can be overwritten by this setting
201-
- NOTE
202-
- OPTIMIZE # marks code that should be optimized before merging
203-
- HACK # marks hack-arounds that should be removed before merging
204-
dogsled:
205-
# checks assignments with too many blank identifiers; default is 2
206-
max-blank-identifiers: 2
207-
208-
whitespace:
209-
multi-if: false # Enforces newlines (or comments) after every multi-line if statement
210-
multi-func: false # Enforces newlines (or comments) after every multi-line function signature
211-
wsl:
212-
# If true append is only allowed to be cuddled if appending value is
213-
# matching variables, fields or types on line above. Default is true.
214-
strict-append: true
215-
# Allow calls and assignments to be cuddled as long as the lines have any
216-
# matching variables, fields or types. Default is true.
217-
allow-assign-and-call: true
218-
# Allow multiline assignments to be cuddled. Default is true.
219-
allow-multiline-assign: true
220-
# Allow declarations (var) to be cuddled.
221-
allow-cuddle-declarations: false
222-
# Allow trailing comments in ending of blocks
223-
allow-trailing-comment: false
224-
# Force newlines in end of case at this limit (0 = never).
225-
force-case-trailing-whitespace: 0
27+
goimports:
28+
local-prefixes: github.com/hatappi/gomodoro
29+
30+
gci:
31+
custom-order: true
32+
sections:
33+
- standard
34+
- default
35+
- prefix(github.com/hatappi)
36+
- prefix(github.com/hatappi/gomodoro)
37+
38+
ireturn:
39+
allow:
40+
- error
41+
- github.com\/gdamore\/tcell\.Screen
42+
- github.com\/mitchellh\/mapstructure\.DecodeHookFunc
43+
44+
forbidigo:
45+
forbid:
46+
- '^log\..+(# Use github.com/hatappi/go-kit/log)'
47+
exclude_godoc_examples: false
48+
49+
cyclop:
50+
max-complexity: 20
22651

22752
linters:
228-
disable-all: true
229-
enable:
230-
- bodyclose
231-
- deadcode
232-
- depguard
233-
- dogsled
234-
- dupl
235-
- errcheck
53+
enable-all: true
54+
disable:
55+
- wrapcheck
56+
- varnamelen
57+
- nlreturn
58+
- gochecknoglobals
59+
- goerr113
60+
- exhaustruct
61+
- wsl
23662
- funlen
237-
- goconst
238-
- gocritic
239-
- gocyclo
240-
- gofmt
241-
- goimports
242-
- golint
243-
- gosec
244-
- gosimple
245-
- govet
246-
- ineffassign
247-
- interfacer
248-
- lll
249-
- misspell
250-
- nakedret
63+
- tagliatelle
64+
# deprecated linters
25165
- scopelint
252-
- staticcheck
253-
- structcheck
254-
- stylecheck
255-
- typecheck
256-
- unconvert
257-
- unparam
258-
- unused
66+
- maligned
67+
- interfacer
68+
- exhaustivestruct
69+
- golint
70+
- deadcode
71+
- ifshort
25972
- varcheck
260-
- whitespace
261-
262-
disabled:
263-
- gochecknoinits
264-
73+
- nosnakecase
74+
- structcheck
26575

26676
issues:
267-
# List of regexps of issue texts to exclude, empty list by default.
268-
# But independently from this option we use default exclude patterns,
269-
# it can be disabled by `exclude-use-default: false`. To list all
270-
# excluded by default patterns execute `golangci-lint run --help`
271-
exclude:
272-
- abcdef
273-
274-
# Excluding configuration per-path, per-linter, per-text and per-source
275-
exclude-rules:
276-
# Exclude some linters from running on tests files.
277-
- path: _test\.go
278-
linters:
279-
- gocyclo
280-
- errcheck
281-
- dupl
282-
- gosec
283-
- scopelint
284-
285-
# Exclude known linters from partially hard-vendored code,
286-
# which is impossible to exclude via "nolint" comments.
287-
- path: internal/hmac/
288-
text: "weak cryptographic primitive"
289-
linters:
290-
- gosec
291-
292-
- path: editor/editor.go
293-
text: "G204: Subprocess launched with variable"
294-
linters:
295-
- gosec
296-
297-
- path: notify
298-
text: "Subprocess launched with variable"
299-
linters:
300-
- gosec
301-
302-
303-
# Exclude some staticcheck messages
304-
- linters:
305-
- staticcheck
306-
text: "SA9003:"
307-
308-
# Exclude lll issues for long lines with go:generate
309-
- linters:
310-
- lll
311-
source: "^//go:generate "
312-
313-
- path: pomodoro/pomodoro.go
314-
text: "singleCaseSwitch: should rewrite switch statement to if statement"
315-
316-
# Independently from option `exclude` we use default exclude patterns,
317-
# it can be disabled by this option. To list all
318-
# excluded by default patterns execute `golangci-lint run --help`.
319-
# Default value for this option is true.
32077
exclude-use-default: false
321-
322-
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
32378
max-issues-per-linter: 0
324-
325-
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
32679
max-same-issues: 0
327-
328-
# Show only new issues: if there are unstaged changes or untracked files,
329-
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
330-
# It's a super-useful option for integration of golangci-lint into existing
331-
# large codebase. It's not practical to fix all existing issues at the moment
332-
# of integration: much better don't allow issues in new code.
333-
# Default is false.
33480
new: false

0 commit comments

Comments
 (0)