-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathunqueryvet.go
More file actions
43 lines (36 loc) · 1.36 KB
/
unqueryvet.go
File metadata and controls
43 lines (36 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package unqueryvet
import (
"github.com/MirrexOne/unqueryvet"
pkgconfig "github.com/MirrexOne/unqueryvet/pkg/config"
"github.com/golangci/golangci-lint/v2/pkg/config"
"github.com/golangci/golangci-lint/v2/pkg/goanalysis"
)
func New(settings *config.UnqueryvetSettings) *goanalysis.Linter {
cfg := pkgconfig.DefaultSettings()
if settings != nil {
// IgnoredFiles, and Severity are explicitly ignored.
cfg.CheckSQLBuilders = settings.CheckSQLBuilders
cfg.CheckAliasedWildcard = settings.CheckAliasedWildcard
cfg.CheckStringConcat = settings.CheckStringConcat
cfg.CheckFormatStrings = settings.CheckFormatStrings
cfg.CheckStringBuilder = settings.CheckStringBuilder
cfg.CheckSubqueries = settings.CheckSubqueries
cfg.IgnoredFunctions = settings.IgnoredFunctions
if len(settings.AllowedPatterns) > 0 {
cfg.AllowedPatterns = settings.AllowedPatterns
}
cfg.SQLBuilders = pkgconfig.SQLBuildersConfig{
Squirrel: settings.SQLBuilders.Squirrel,
GORM: settings.SQLBuilders.GORM,
SQLx: settings.SQLBuilders.SQLx,
Ent: settings.SQLBuilders.Ent,
PGX: settings.SQLBuilders.PGX,
Bun: settings.SQLBuilders.Bun,
SQLBoiler: settings.SQLBuilders.SQLBoiler,
Jet: settings.SQLBuilders.Jet,
}
}
return goanalysis.
NewLinterFromAnalyzer(unqueryvet.NewWithConfig(&cfg)).
WithLoadMode(goanalysis.LoadModeSyntax)
}