Skip to content

Commit b9d2d8c

Browse files
committed
Fix all technical requirements from maintainer feedback
- Remove all ignore-related options from configuration - Remove gounqvet_test.go as requested - Fix testdata directives format (move 'want' to end of line) - Remove ignore fields from GounqvetSettings struct - Change WithLoadForGoAnalysis to LoadModeSyntax (no type info needed) - Add empty lines at end of all files - Simplify configuration to only check-sql-builders and allowed-patterns All technical feedback addressed.
1 parent e0bbdec commit b9d2d8c

File tree

6 files changed

+10
-79
lines changed

6 files changed

+10
-79
lines changed

.golangci.next.reference.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,29 +1584,11 @@ linters:
15841584
# Enable SQL builder checking.
15851585
# Default: true
15861586
check-sql-builders: false
1587-
# Functions to skip during analysis.
1588-
# Default: []
1589-
ignored-functions:
1590-
- "fmt.Printf"
1591-
- "log.Printf"
1592-
# Packages to ignore completely.
1593-
# Default: []
1594-
ignored-packages:
1595-
- "testing"
1596-
- "debug"
15971587
# Regex patterns for acceptable SELECT * usage.
15981588
# Default: ["SELECT \\* FROM information_schema\\..*", "SELECT \\* FROM pg_catalog\\..*", "SELECT COUNT\\(\\*\\)", "SELECT MAX\\(\\*\\)", "SELECT MIN\\(\\*\\)"]
15991589
allowed-patterns:
16001590
- "SELECT \\* FROM temp_.*"
16011591
- "SELECT \\* FROM.*-- migration"
1602-
# File patterns to ignore.
1603-
# Default: ["*_test.go", "*.pb.go", "*_gen.go", "*.gen.go", "*_generated.go"]
1604-
ignored-file-patterns:
1605-
- "my_special_pattern.go"
1606-
# Directories to ignore.
1607-
# Default: ["vendor", "testdata", "migrations", "generated", ".git", "node_modules"]
1608-
ignored-directories:
1609-
- "my_special_dir"
16101592

16111593
gosmopolitan:
16121594
# Allow and ignore `time.Local` usages.

pkg/config/linters_settings.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1081,10 +1081,6 @@ func (s *CustomLinterSettings) Validate() error {
10811081
}
10821082

10831083
type GounqvetSettings struct {
1084-
CheckSQLBuilders bool `mapstructure:"check-sql-builders"`
1085-
IgnoredFunctions []string `mapstructure:"ignored-functions"`
1086-
IgnoredPackages []string `mapstructure:"ignored-packages"`
1087-
AllowedPatterns []string `mapstructure:"allowed-patterns"`
1088-
IgnoredFilePatterns []string `mapstructure:"ignored-file-patterns"`
1089-
IgnoredDirectories []string `mapstructure:"ignored-directories"`
1084+
CheckSQLBuilders bool `mapstructure:"check-sql-builders"`
1085+
AllowedPatterns []string `mapstructure:"allowed-patterns"`
10901086
}

pkg/golinters/gounqvet/gounqvet.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,8 @@ func New(settings *config.GounqvetSettings) *goanalysis.Linter {
1313
var cfg *pkgconfig.GounqvetSettings
1414
if settings != nil {
1515
cfg = &pkgconfig.GounqvetSettings{
16-
CheckSQLBuilders: settings.CheckSQLBuilders,
17-
IgnoredFunctions: settings.IgnoredFunctions,
18-
IgnoredPackages: settings.IgnoredPackages,
19-
AllowedPatterns: settings.AllowedPatterns,
20-
IgnoredFilePatterns: settings.IgnoredFilePatterns,
21-
IgnoredDirectories: settings.IgnoredDirectories,
16+
CheckSQLBuilders: settings.CheckSQLBuilders,
17+
AllowedPatterns: settings.AllowedPatterns,
2218
}
2319
}
2420

@@ -29,5 +25,5 @@ func New(settings *config.GounqvetSettings) *goanalysis.Linter {
2925
"Detects SELECT * usage in SQL queries and SQL builders, encouraging explicit column selection",
3026
[]*analysis.Analyzer{analyzer},
3127
nil,
32-
).WithLoadMode(goanalysis.LoadModeTypesInfo)
33-
}
28+
).WithLoadMode(goanalysis.LoadModeSyntax)
29+
}

pkg/golinters/gounqvet/gounqvet_test.go

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

pkg/golinters/gounqvet/testdata/gounqvet.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import (
77
)
88

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

1312
var db *sql.DB
14-
// want "avoid SELECT \\* - explicitly specify needed columns for better performance, maintainability and stability"
15-
rows, _ := db.Query("SELECT * FROM orders WHERE status = ?", "active")
13+
rows, _ := db.Query("SELECT * FROM orders WHERE status = ?", "active") // want "avoid SELECT \\* - explicitly specify needed columns for better performance, maintainability and stability"
1614
_ = rows
1715

1816
// This should not trigger because it's a COUNT function
@@ -41,13 +39,12 @@ type SQLBuilder interface {
4139
}
4240

4341
func badSQLBuilder(builder SQLBuilder) {
44-
// want "avoid SELECT \\* in SQL builder - explicitly specify columns to prevent unnecessary data transfer and schema change issues"
45-
query := builder.Select("*").From("products")
42+
query := builder.Select("*").From("products") // want "avoid SELECT \\* in SQL builder - explicitly specify columns to prevent unnecessary data transfer and schema change issues"
4643
_ = query
4744
}
4845

4946
func goodSQLBuilder(builder SQLBuilder) {
5047
// Good usage - should not trigger
5148
query := builder.Select("id", "name", "price").From("products")
5249
_ = query
53-
}
50+
}

pkg/lint/lintersdb/builder_linter.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
395395

396396
linter.NewConfig(gounqvet.New(&cfg.Linters.Settings.Gounqvet)).
397397
WithSince("v2.5.0").
398-
WithLoadForGoAnalysis().
399398
WithURL("https://github.com/MirrexOne/gounqvet"),
400399

401400
linter.NewConfig(gosmopolitan.New(&cfg.Linters.Settings.Gosmopolitan)).

0 commit comments

Comments
 (0)