Skip to content

Commit f3a0864

Browse files
committed
chore: quick lint configuration
1 parent ddfc831 commit f3a0864

File tree

3 files changed

+95
-6
lines changed

3 files changed

+95
-6
lines changed

.golangci.yml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
version: "2"
2+
3+
formatters:
4+
enable:
5+
- gci
6+
- gofumpt
7+
settings:
8+
gofumpt:
9+
extra-rules: true
10+
11+
linters:
12+
default: all
13+
disable:
14+
- cyclop # duplicate of gocyclo
15+
- dupl
16+
- errchkjson
17+
- exhaustive
18+
- exhaustruct
19+
- lll
20+
- mnd
21+
- nilnil
22+
- nlreturn
23+
- nonamedreturns
24+
- paralleltest
25+
- prealloc
26+
- rowserrcheck # not relevant (SQL)
27+
- sqlclosecheck # not relevant (SQL)
28+
- testpackage
29+
- tparallel
30+
- varnamelen
31+
- wsl # Deprecated
32+
- forcetypeassert # recheck in the future.
33+
34+
settings:
35+
depguard:
36+
rules:
37+
main:
38+
deny:
39+
- pkg: github.com/instana/testify
40+
desc: not allowed
41+
- pkg: github.com/pkg/errors
42+
desc: Should be replaced by standard lib errors package
43+
funlen:
44+
lines: -1
45+
statements: 40
46+
goconst:
47+
min-len: 5
48+
min-occurrences: 3
49+
gocritic:
50+
disabled-checks:
51+
- sloppyReassign
52+
- rangeValCopy
53+
- octalLiteral
54+
- paramTypeCombine # already handle by gofumpt.extra-rules
55+
enabled-tags:
56+
- diagnostic
57+
- style
58+
- performance
59+
settings:
60+
hugeParam:
61+
sizeThreshold: 100
62+
gocyclo:
63+
min-complexity: 20
64+
godox:
65+
keywords:
66+
- FIXME
67+
govet:
68+
disable:
69+
- fieldalignment
70+
enable-all: true
71+
misspell:
72+
locale: US
73+
mnd:
74+
ignored-numbers:
75+
- "124"
76+
wsl:
77+
force-case-trailing-whitespace: 1
78+
allow-trailing-comment: true
79+
exclusions:
80+
presets:
81+
- comments
82+
- std-error-handling
83+
- common-false-positives
84+
85+
issues:
86+
max-issues-per-linter: 0
87+
max-same-issues: 0

ascii_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,24 @@ func BenchmarkIsASCII(b *testing.B) {
4242
for _, size := range sizes {
4343
b.Run(fmt.Sprintf("Len=%d", size), func(b *testing.B) {
4444
s := generateString(size)
45+
4546
b.ReportAllocs()
4647
b.ResetTimer()
4748

48-
for i := 0; i < b.N; i++ {
49+
for range b.N {
4950
if _, ok := isASCII(s); !ok {
5051
b.Fatal("unexpected result")
5152
}
5253
}
5354
})
54-
5555
}
56-
5756
}
5857

5958
func generateString(l int) string {
6059
s := make([]byte, l)
6160
for i := range s {
6261
s[i] = byte(i)
6362
}
63+
6464
return string(s)
6565
}

asciicheck.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func NewAnalyzer() *analysis.Analyzer {
2020
}
2121

2222
func run(pass *analysis.Pass) (any, error) {
23-
inspect := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
23+
insp := pass.ResultOf[inspect.Analyzer].(*inspector.Inspector)
2424

2525
nodeFilter := []ast.Node{
2626
(*ast.File)(nil),
@@ -35,7 +35,7 @@ func run(pass *analysis.Pass) (any, error) {
3535
(*ast.AssignStmt)(nil),
3636
}
3737

38-
inspect.Preorder(nodeFilter, func(n ast.Node) {
38+
insp.Preorder(nodeFilter, func(n ast.Node) {
3939
switch n := n.(type) {
4040
case *ast.File:
4141
checkIdent(pass, n.Name)
@@ -71,6 +71,7 @@ func run(pass *analysis.Pass) (any, error) {
7171
}
7272
}
7373
})
74+
7475
return nil, nil
7576
}
7677

@@ -84,7 +85,7 @@ func checkIdent(pass *analysis.Pass, v *ast.Ident) {
8485
pass.Report(
8586
analysis.Diagnostic{
8687
Pos: v.Pos(),
87-
Message: fmt.Sprintf("identifier \"%s\" contain non-ASCII character: %#U", v.Name, ch),
88+
Message: fmt.Sprintf("identifier %q contain non-ASCII character: %#U", v.Name, ch),
8889
},
8990
)
9091
}
@@ -94,6 +95,7 @@ func checkFieldList(pass *analysis.Pass, f *ast.FieldList) {
9495
if f == nil {
9596
return
9697
}
98+
9799
for _, f := range f.List {
98100
for _, name := range f.Names {
99101
checkIdent(pass, name)

0 commit comments

Comments
 (0)