Skip to content

Commit f88156d

Browse files
committed
Linter fixes.
1 parent 4760f5d commit f88156d

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

.golangci.yml

+18
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ linters:
88
- scopelint # Deprecated
99
- golint # Deprecated
1010
- maligned # Deprecated
11+
# unsupported in Go v1.18
12+
- bodyclose
13+
- contextcheck
14+
- nilerr
15+
- noctx
16+
- rowserrcheck
17+
- sqlclosecheck
18+
- structcheck
19+
- tparallel
20+
- unparam
21+
- wastedassign
1122

1223
- exhaustivestruct # 'It is not recommended to use it for all files in a project'
1324
- forbidigo # forbids the use for fmt.Print(f|ln)
@@ -20,3 +31,10 @@ linters-settings:
2031
max-complexity: 15 # default value 10 requires unnecessary refactoring
2132
varnamelen:
2233
min-name-length: 1 # default value 3 is too short
34+
35+
issues:
36+
exclude-rules:
37+
# Exclude some linters from running on tests files.
38+
- path: _test\.go
39+
linters:
40+
- exhaustruct

pkg/example_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// © Ben Garrett https://github.com/bengarrett/zipcmt
2-
32
package zipcmt_test
43

54
import (

pkg/zipcmt.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ type (
8484
)
8585

8686
var (
87+
ErrFlag = errors.New("directories to scan must be listed after any option flags")
8788
ErrIsFile = errors.New("directory is a file")
8889
ErrMissing = errors.New("directory cannot be found")
8990
ErrPath = errors.New("directory path cannot be found or points to a file")
@@ -182,6 +183,7 @@ func (c *Config) WalkDir(root string) error { // nolint: cyclop,funlen,gocognit
182183
}
183184
// save the comment to a text file
184185
dat := save{
186+
name: "",
185187
src: path,
186188
cmmt: cmmt,
187189
mod: c.lastMod(d),
@@ -211,8 +213,7 @@ func walkErrs(root string, err error) error {
211213
var pathError *os.PathError
212214
if errors.As(err, &pathError) {
213215
if root != "" && root[:1] == "-" {
214-
return fmt.Errorf("detected an options flag, "+
215-
"all the directories to scan must be listed after any option flags: %s", root)
216+
return fmt.Errorf("detected an options flag, %w: %s", ErrFlag, root)
216217
}
217218
}
218219
if err != nil {

0 commit comments

Comments
 (0)