Skip to content

Commit 0aad6a2

Browse files
author
Maarten van der Heijden
committed
Add linting
1 parent 532c1d5 commit 0aad6a2

File tree

6 files changed

+105
-4
lines changed

6 files changed

+105
-4
lines changed

.golangci.yaml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
linters-settings:
2+
gocritic:
3+
disabled-checks:
4+
- "paramTypeCombine"
5+
enabled-tags:
6+
- "performance"
7+
- "style"
8+
- "diagnostic"
9+
linters:
10+
enable:
11+
- asasalint
12+
- asciicheck
13+
- bidichk
14+
- bodyclose
15+
- containedctx
16+
- contextcheck
17+
- cyclop
18+
- decorder
19+
- dogsled
20+
- dupword
21+
- durationcheck
22+
- errcheck
23+
- errname
24+
- errorlint
25+
- execinquery
26+
- exhaustive
27+
- exportloopref
28+
- forbidigo
29+
- ginkgolinter
30+
- gocheckcompilerdirectives
31+
- gochecknoinits
32+
- gocognit
33+
- goconst
34+
- gocritic
35+
- gocyclo
36+
- goerr113
37+
- gofmt
38+
- gofumpt
39+
- goheader
40+
- goimports
41+
- gomoddirectives
42+
- gomodguard
43+
- goprintffuncname
44+
- gosec
45+
- gosimple
46+
- gosmopolitan
47+
- govet
48+
- grouper
49+
- ifshort
50+
- importas
51+
- ineffassign
52+
- interfacebloat
53+
- interfacer
54+
- ireturn
55+
- loggercheck
56+
- maintidx
57+
- makezero
58+
- mirror
59+
- misspell
60+
- musttag
61+
- nakedret
62+
- nestif
63+
- nilerr
64+
- nilnil
65+
- nlreturn
66+
- nonamedreturns
67+
- nosprintfhostport
68+
- paralleltest
69+
- prealloc
70+
- predeclared
71+
- promlinter
72+
- reassign
73+
- rowserrcheck
74+
- sqlclosecheck
75+
- staticcheck
76+
- tenv
77+
- thelper
78+
- tparallel
79+
- typecheck
80+
- unconvert
81+
- unparam
82+
- unused
83+
- usestdlibvars
84+
- wastedassign
85+
- whitespace
86+
- zerologlint

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,11 @@ test: fmt ## Run unit tests, alias: t
1212

1313
fmt: ## Format go code
1414
@go mod tidy
15-
@go fmt ./...
15+
@gofumpt -l -w .
16+
17+
tools: ## Install extra tools for development
18+
go install mvdan.cc/gofumpt@latest
19+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
20+
21+
lint: ## Lint the code locally
22+
golangci-lint run --timeout 600s

plugin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ func SettingOnly() Option {
3535

3636
// New creates a new instance of the plugin that can be registered in gorm. Without any settings, all queries will be
3737
// LIKE-d.
38+
//
39+
//nolint:ireturn // Acceptable
3840
func New(opts ...Option) gorm.Plugin {
3941
plugin := &gormLike{}
4042

plugin_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
package gormlike
22

33
import (
4+
"testing"
5+
46
"github.com/ing-bank/gormtestutil"
57
"github.com/stretchr/testify/assert"
6-
"testing"
78
)
89

910
func TestDeepGorm_Name_ReturnsExpectedName(t *testing.T) {

query.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ package gormlike
22

33
import (
44
"fmt"
5+
"strings"
6+
57
"gorm.io/gorm"
68
"gorm.io/gorm/clause"
7-
"strings"
89
)
910

1011
const tagName = "gormlike"
1112

13+
//nolint:gocognit,cyclop // Acceptable
1214
func (d *gormLike) queryCallback(db *gorm.DB) {
1315
// If we only want to like queries that are explicitly set to true, we back out early if anything's amiss
1416
settingValue, settingOk := db.Get(tagName)
@@ -110,6 +112,7 @@ func (d *gormLike) queryCallback(db *gorm.DB) {
110112

111113
if useOr {
112114
query = query.Or(condition, value)
115+
113116
continue
114117
}
115118

query_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package gormlike
22

33
import (
4+
"testing"
5+
46
"github.com/google/uuid"
57
"github.com/ing-bank/gormtestutil"
68
"github.com/stretchr/testify/assert"
79
"gorm.io/gorm"
8-
"testing"
910
)
1011

12+
// nolint:maintidx // Acceptable
1113
func TestGormLike_Initialize_TriggersLikingCorrectly(t *testing.T) {
1214
t.Parallel()
1315

0 commit comments

Comments
 (0)