Skip to content

Commit 146d15c

Browse files
MirrexOneldez
authored andcommitted
Update linter's name
1 parent 0c4b7c6 commit 146d15c

File tree

13 files changed

+59
-88
lines changed

13 files changed

+59
-88
lines changed

.golangci.next.reference.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ linters:
6868
- goprintffuncname
6969
- gosec
7070
- gosmopolitan
71-
- gounqvet
71+
- unqueryvet
7272
- govet
7373
- grouper
7474
- iface
@@ -182,7 +182,7 @@ linters:
182182
- goprintffuncname
183183
- gosec
184184
- gosmopolitan
185-
- gounqvet
185+
- unqueryvet
186186
- govet
187187
- grouper
188188
- iface
@@ -1679,7 +1679,7 @@ linters:
16791679
- Hiragana
16801680
- Katakana
16811681

1682-
gounqvet:
1682+
unqueryvet:
16831683
# Enable SQL builder checking.
16841684
# Default: true
16851685
check-sql-builders: false

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ require (
149149
codeberg.org/chavacava/garif v0.2.0 // indirect
150150
dev.gaijin.team/go/golib v0.6.0 // indirect
151151
github.com/Masterminds/semver/v3 v3.3.1 // indirect
152-
github.com/MirrexOne/gounqvet v1.2.0
152+
github.com/MirrexOne/unqueryvet v1.2.1
153153
github.com/alfatraining/structtag v1.0.0 // indirect
154154
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
155155
github.com/beorn7/perks v1.0.1 // indirect
@@ -225,3 +225,5 @@ require (
225225
gopkg.in/ini.v1 v1.67.0 // indirect
226226
gopkg.in/yaml.v2 v2.4.0 // indirect
227227
)
228+
229+
replace github.com/MirrexOne/unqueryvet => ../unqueryvet

go.sum

Lines changed: 0 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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,7 +2342,7 @@
23422342
}
23432343
}
23442344
},
2345-
"gounqvetSettings": {
2345+
"unqueryvetSettings": {
23462346
"type": "object",
23472347
"additionalProperties": false,
23482348
"properties": {
@@ -4685,8 +4685,8 @@
46854685
"gosmopolitan": {
46864686
"$ref": "#/definitions/settings/definitions/gosmopolitanSettings"
46874687
},
4688-
"gounqvet": {
4689-
"$ref": "#/definitions/settings/definitions/gounqvetSettings"
4688+
"unqueryvet": {
4689+
"$ref": "#/definitions/settings/definitions/unqueryvetSettings"
46904690
},
46914691
"govet": {
46924692
"$ref": "#/definitions/settings/definitions/govetSettings"

pkg/config/linters_settings.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ var defaultLintersSettings = LintersSettings{
8686
EscapeHatches: []string{},
8787
WatchForScripts: []string{"Han"},
8888
},
89-
Gounqvet: GounqvetSettings{
89+
Unqueryvet: UnqueryvetSettings{
9090
CheckSQLBuilders: true,
9191
},
9292
Inamedparam: INamedParamSettings{
@@ -253,7 +253,7 @@ type LintersSettings struct {
253253
Gomodguard GoModGuardSettings `mapstructure:"gomodguard"`
254254
Gosec GoSecSettings `mapstructure:"gosec"`
255255
Gosmopolitan GosmopolitanSettings `mapstructure:"gosmopolitan"`
256-
Gounqvet GounqvetSettings `mapstructure:"gounqvet"`
256+
Unqueryvet UnqueryvetSettings `mapstructure:"unqueryvet"`
257257
Govet GovetSettings `mapstructure:"govet"`
258258
Grouper GrouperSettings `mapstructure:"grouper"`
259259
Iface IfaceSettings `mapstructure:"iface"`
@@ -614,7 +614,7 @@ type GosmopolitanSettings struct {
614614
WatchForScripts []string `mapstructure:"watch-for-scripts"`
615615
}
616616

617-
type GounqvetSettings struct {
617+
type UnqueryvetSettings struct {
618618
CheckSQLBuilders bool `mapstructure:"check-sql-builders"`
619619
AllowedPatterns []string `mapstructure:"allowed-patterns"`
620620
}

pkg/golinters/gounqvet/testdata/gounqvet_custom.go

Lines changed: 0 additions & 51 deletions
This file was deleted.

pkg/golinters/gounqvet/testdata/gounqvet_custom.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//golangcitest:args -Egounqvet
1+
//golangcitest:args -Eunqueryvet
22
package testdata
33

44
import (
@@ -7,25 +7,21 @@ import (
77
"strconv"
88
)
99

10-
// badQueries
1110
func _() {
1211
query := "SELECT * FROM users" // want "avoid SELECT \\* - explicitly specify needed columns for better performance, maintainability and stability"
1312

1413
var db *sql.DB
1514
rows, _ := db.Query("SELECT * FROM orders WHERE status = ?", "active") // want "avoid SELECT \\* - explicitly specify needed columns for better performance, maintainability and stability"
1615
_ = rows
1716

18-
// This should not trigger because it's a COUNT function
1917
count := "SELECT COUNT(*) FROM users"
2018
_ = count
2119

22-
// Good queries (should not trigger)
2320
goodQuery := "SELECT id, name, email FROM users"
2421
_ = goodQuery
2522

2623
fmt.Println(query)
2724

28-
// Use strconv to satisfy std lib import requirement
2925
_ = strconv.Itoa(42)
3026
}
3127

@@ -36,15 +32,12 @@ type SQLBuilder interface {
3632
Query() string
3733
}
3834

39-
// badSQLBuilder
4035
func _(builder SQLBuilder) {
4136
query := builder.Select("*").From("products") // want "avoid SELECT \\* in SQL builder - explicitly specify columns to prevent unnecessary data transfer and schema change issues"
4237
_ = query
4338
}
4439

45-
// goodSQLBuilder
4640
func _(builder SQLBuilder) {
47-
// Good usage - should not trigger
4841
query := builder.Select("id", "name", "price").From("products")
4942
_ = query
5043
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//golangcitest:args -Eunqueryvet
2+
//golangcitest:config_path testdata/unqueryvet_custom.yml
3+
package testdata
4+
5+
import (
6+
"database/sql"
7+
"fmt"
8+
"strconv"
9+
)
10+
11+
func _() {
12+
query := "SELECT * FROM users" // want "avoid SELECT \\* - explicitly specify needed columns for better performance, maintainability and stability"
13+
14+
var db *sql.DB
15+
rows, _ := db.Query("SELECT * FROM orders WHERE status = ?", "active") // want "avoid SELECT \\* - explicitly specify needed columns for better performance, maintainability and stability"
16+
_ = rows
17+
18+
count := "SELECT COUNT(*) FROM users"
19+
_ = count
20+
21+
goodQuery := "SELECT id, name, email FROM users"
22+
_ = goodQuery
23+
24+
fmt.Println(query)
25+
26+
_ = strconv.Itoa(42)
27+
}
28+
29+
// Custom allowed patterns test - SELECT * from temp tables should be allowed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: "2"
2+
3+
linters:
4+
settings:
5+
unqueryvet:
6+
check-sql-builders: false

0 commit comments

Comments
 (0)