Skip to content

Commit b1bf701

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 691a0f5 commit b1bf701

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
@@ -1586,29 +1586,11 @@ linters:
15861586
# Enable SQL builder checking.
15871587
# Default: true
15881588
check-sql-builders: false
1589-
# Functions to skip during analysis.
1590-
# Default: []
1591-
ignored-functions:
1592-
- "fmt.Printf"
1593-
- "log.Printf"
1594-
# Packages to ignore completely.
1595-
# Default: []
1596-
ignored-packages:
1597-
- "testing"
1598-
- "debug"
15991589
# Regex patterns for acceptable SELECT * usage.
16001590
# Default: ["SELECT \\* FROM information_schema\\..*", "SELECT \\* FROM pg_catalog\\..*", "SELECT COUNT\\(\\*\\)", "SELECT MAX\\(\\*\\)", "SELECT MIN\\(\\*\\)"]
16011591
allowed-patterns:
16021592
- "SELECT \\* FROM temp_.*"
16031593
- "SELECT \\* FROM.*-- migration"
1604-
# File patterns to ignore.
1605-
# Default: ["*_test.go", "*.pb.go", "*_gen.go", "*.gen.go", "*_generated.go"]
1606-
ignored-file-patterns:
1607-
- "my_special_pattern.go"
1608-
# Directories to ignore.
1609-
# Default: ["vendor", "testdata", "migrations", "generated", ".git", "node_modules"]
1610-
ignored-directories:
1611-
- "my_special_dir"
16121594

16131595
gosmopolitan:
16141596
# 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
@@ -1086,10 +1086,6 @@ func (s *CustomLinterSettings) Validate() error {
10861086
}
10871087

10881088
type GounqvetSettings struct {
1089-
CheckSQLBuilders bool `mapstructure:"check-sql-builders"`
1090-
IgnoredFunctions []string `mapstructure:"ignored-functions"`
1091-
IgnoredPackages []string `mapstructure:"ignored-packages"`
1092-
AllowedPatterns []string `mapstructure:"allowed-patterns"`
1093-
IgnoredFilePatterns []string `mapstructure:"ignored-file-patterns"`
1094-
IgnoredDirectories []string `mapstructure:"ignored-directories"`
1089+
CheckSQLBuilders bool `mapstructure:"check-sql-builders"`
1090+
AllowedPatterns []string `mapstructure:"allowed-patterns"`
10951091
}

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
@@ -396,7 +396,6 @@ func (LinterBuilder) Build(cfg *config.Config) ([]*linter.Config, error) {
396396

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

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

0 commit comments

Comments
 (0)