Skip to content

Commit 0d43769

Browse files
build(deps): bump github.com/MirrexOne/unqueryvet from 1.3.0 to 1.4.0 (#6299)
Co-authored-by: Fernandez Ludovic <[email protected]>
1 parent e45bbde commit 0d43769

File tree

7 files changed

+161
-8
lines changed

7 files changed

+161
-8
lines changed

.golangci.next.reference.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3993,7 +3993,22 @@ linters:
39933993
# Enable SQL builder checking.
39943994
# Default: true
39953995
check-sql-builders: false
3996-
# Regex patterns for acceptable SELECT * usage.
3996+
# Enable aliased wildcard detection like `SELECT t.*`.
3997+
# Default: true
3998+
check-aliased-wildcard: false
3999+
# Enable string concatenation analysis.
4000+
# Default: true
4001+
check-string-concat: false
4002+
# Enable format string analysis like `fmt.Sprintf`.
4003+
# Default: true
4004+
check-format-strings: false
4005+
# Enable strings.Builder analysis.
4006+
# Default: true
4007+
check-string-builder: false
4008+
# Enable subquery analysis.
4009+
# Default: true
4010+
check-subqueries: false
4011+
# Regex patterns for acceptable `SELECT *` usage.
39974012
# Default:
39984013
# - "SELECT \\* FROM information_schema\\..*"
39994014
# - "SELECT \\* FROM pg_catalog\\..*"
@@ -4003,6 +4018,22 @@ linters:
40034018
allowed-patterns:
40044019
- "SELECT \\* FROM temp_.*"
40054020
- "SELECT \\* FROM.*-- migration"
4021+
# Functions to ignore (regex patterns)
4022+
# Default: []
4023+
ignored-functions:
4024+
- "debug\\..*"
4025+
- "test.*"
4026+
# SQL builder libraries to check.
4027+
# Default: all true.
4028+
sql-builders:
4029+
squirrel: false
4030+
gorm: false
4031+
sqlx: false
4032+
ent: false
4033+
pgx: false
4034+
bun: false
4035+
sqlboiler: false
4036+
jet: false
40064037

40074038
unused:
40084039
# Mark all struct fields that have been written to as used.

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ require (
1616
github.com/Antonboom/testifylint v1.6.4
1717
github.com/BurntSushi/toml v1.6.0
1818
github.com/Djarvur/go-err113 v0.1.1
19-
github.com/MirrexOne/unqueryvet v1.3.0
19+
github.com/MirrexOne/unqueryvet v1.4.0
2020
github.com/OpenPeeDeeP/depguard/v2 v2.2.1
2121
github.com/alecthomas/chroma/v2 v2.21.1
2222
github.com/alecthomas/go-check-sumtype v0.3.1

go.sum

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsonschema/golangci.next.jsonschema.json

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4083,12 +4083,82 @@
40834083
"type": "boolean",
40844084
"default": true
40854085
},
4086+
"check-aliased-wildcard": {
4087+
"description": "Enable aliased wildcard detection like SELECT t.*.",
4088+
"type": "boolean",
4089+
"default": true
4090+
},
4091+
"check-string-concat": {
4092+
"description": "Enable string concatenation analysis.",
4093+
"type": "boolean",
4094+
"default": true
4095+
},
4096+
"check-format-strings": {
4097+
"description": "Enable format string analysis like fmt.Sprintf.",
4098+
"type": "boolean",
4099+
"default": true
4100+
},
4101+
"check-string-builder": {
4102+
"description": "Enable strings.Builder analysis.",
4103+
"type": "boolean",
4104+
"default": true
4105+
},
4106+
"check-subqueries": {
4107+
"description": "Enable subquery analysis.",
4108+
"type": "boolean",
4109+
"default": true
4110+
},
40864111
"allowed-patterns": {
40874112
"description": "Regex patterns for acceptable SELECT * usage.",
40884113
"type": "array",
40894114
"items": {
40904115
"type": "string"
40914116
}
4117+
},
4118+
"ignored-functions": {
4119+
"description": "Functions to ignore.",
4120+
"type": "array",
4121+
"items": {
4122+
"type": "string"
4123+
}
4124+
},
4125+
"sql-builders": {
4126+
"type": "object",
4127+
"additionalProperties": false,
4128+
"properties": {
4129+
"squirrel": {
4130+
"type": "boolean",
4131+
"default": true
4132+
},
4133+
"gorm": {
4134+
"type": "boolean",
4135+
"default": true
4136+
},
4137+
"sqlx": {
4138+
"type": "boolean",
4139+
"default": true
4140+
},
4141+
"ent": {
4142+
"type": "boolean",
4143+
"default": true
4144+
},
4145+
"pgx": {
4146+
"type": "boolean",
4147+
"default": true
4148+
},
4149+
"bun": {
4150+
"type": "boolean",
4151+
"default": true
4152+
},
4153+
"sqlboiler": {
4154+
"type": "boolean",
4155+
"default": true
4156+
},
4157+
"jet": {
4158+
"type": "boolean",
4159+
"default": true
4160+
}
4161+
}
40924162
}
40934163
}
40944164
},

pkg/config/linters_settings.go

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,22 @@ var defaultLintersSettings = LintersSettings{
164164
AllowPackages: []string{"main"},
165165
},
166166
Unqueryvet: UnqueryvetSettings{
167-
CheckSQLBuilders: true,
167+
CheckSQLBuilders: true,
168+
CheckAliasedWildcard: true,
169+
CheckStringConcat: true,
170+
CheckFormatStrings: true,
171+
CheckStringBuilder: true,
172+
CheckSubqueries: true,
173+
SQLBuilders: UnqueryvetSQLBuildersSettings{
174+
Squirrel: true,
175+
GORM: true,
176+
SQLx: true,
177+
Ent: true,
178+
PGX: true,
179+
Bun: true,
180+
SQLBoiler: true,
181+
Jet: true,
182+
},
168183
},
169184
Unused: UnusedSettings{
170185
FieldWritesAreUses: true,
@@ -1022,8 +1037,26 @@ type UnparamSettings struct {
10221037
}
10231038

10241039
type UnqueryvetSettings struct {
1025-
CheckSQLBuilders bool `mapstructure:"check-sql-builders"`
1026-
AllowedPatterns []string `mapstructure:"allowed-patterns"`
1040+
CheckSQLBuilders bool `mapstructure:"check-sql-builders"`
1041+
AllowedPatterns []string `mapstructure:"allowed-patterns"`
1042+
IgnoredFunctions []string `mapstructure:"ignored-functions"`
1043+
CheckAliasedWildcard bool `mapstructure:"check-aliased-wildcard"`
1044+
CheckStringConcat bool `mapstructure:"check-string-concat"`
1045+
CheckFormatStrings bool `mapstructure:"check-format-strings"`
1046+
CheckStringBuilder bool `mapstructure:"check-string-builder"`
1047+
CheckSubqueries bool `mapstructure:"check-subqueries"`
1048+
SQLBuilders UnqueryvetSQLBuildersSettings `mapstructure:"sql-builders"`
1049+
}
1050+
1051+
type UnqueryvetSQLBuildersSettings struct {
1052+
Squirrel bool `mapstructure:"squirrel"`
1053+
GORM bool `mapstructure:"gorm"`
1054+
SQLx bool `mapstructure:"sqlx"`
1055+
Ent bool `mapstructure:"ent"`
1056+
PGX bool `mapstructure:"pgx"`
1057+
Bun bool `mapstructure:"bun"`
1058+
SQLBoiler bool `mapstructure:"sqlboiler"`
1059+
Jet bool `mapstructure:"jet"`
10271060
}
10281061

10291062
type UnusedSettings struct {

pkg/golinters/unqueryvet/testdata/unqueryvet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ type SQLBuilder interface {
3333
}
3434

3535
func _(builder SQLBuilder) {
36-
query := builder.Select("*").From("products") // want "avoid SELECT \\* in SQL builder - explicitly specify columns to prevent unnecessary data transfer and schema change issues"
36+
query := builder.Select("*").From("products") // want `Squirrel Select\(\"\*\"\) - explicitly specify columns`
3737
_ = query
3838
}
3939

pkg/golinters/unqueryvet/unqueryvet.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,29 @@ func New(settings *config.UnqueryvetSettings) *goanalysis.Linter {
1212
cfg := pkgconfig.DefaultSettings()
1313

1414
if settings != nil {
15+
// IgnoredFiles, and Severity are explicitly ignored.
1516
cfg.CheckSQLBuilders = settings.CheckSQLBuilders
17+
cfg.CheckAliasedWildcard = settings.CheckAliasedWildcard
18+
cfg.CheckStringConcat = settings.CheckStringConcat
19+
cfg.CheckFormatStrings = settings.CheckFormatStrings
20+
cfg.CheckStringBuilder = settings.CheckStringBuilder
21+
cfg.CheckSubqueries = settings.CheckSubqueries
22+
cfg.IgnoredFunctions = settings.IgnoredFunctions
23+
1624
if len(settings.AllowedPatterns) > 0 {
1725
cfg.AllowedPatterns = settings.AllowedPatterns
1826
}
27+
28+
cfg.SQLBuilders = pkgconfig.SQLBuildersConfig{
29+
Squirrel: settings.SQLBuilders.Squirrel,
30+
GORM: settings.SQLBuilders.GORM,
31+
SQLx: settings.SQLBuilders.SQLx,
32+
Ent: settings.SQLBuilders.Ent,
33+
PGX: settings.SQLBuilders.PGX,
34+
Bun: settings.SQLBuilders.Bun,
35+
SQLBoiler: settings.SQLBuilders.SQLBoiler,
36+
Jet: settings.SQLBuilders.Jet,
37+
}
1938
}
2039

2140
return goanalysis.

0 commit comments

Comments
 (0)