Skip to content

Commit a57eb14

Browse files
MirrexOneldez
authored andcommitted
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 9b31b40 commit a57eb14

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
@@ -1656,29 +1656,11 @@ linters:
16561656
# Enable SQL builder checking.
16571657
# Default: true
16581658
check-sql-builders: false
1659-
# Functions to skip during analysis.
1660-
# Default: []
1661-
ignored-functions:
1662-
- "fmt.Printf"
1663-
- "log.Printf"
1664-
# Packages to ignore completely.
1665-
# Default: []
1666-
ignored-packages:
1667-
- "testing"
1668-
- "debug"
16691659
# Regex patterns for acceptable SELECT * usage.
16701660
# Default: ["SELECT \\* FROM information_schema\\..*", "SELECT \\* FROM pg_catalog\\..*", "SELECT COUNT\\(\\*\\)", "SELECT MAX\\(\\*\\)", "SELECT MIN\\(\\*\\)"]
16711661
allowed-patterns:
16721662
- "SELECT \\* FROM temp_.*"
16731663
- "SELECT \\* FROM.*-- migration"
1674-
# File patterns to ignore.
1675-
# Default: ["*_test.go", "*.pb.go", "*_gen.go", "*.gen.go", "*_generated.go"]
1676-
ignored-file-patterns:
1677-
- "my_special_pattern.go"
1678-
# Directories to ignore.
1679-
# Default: ["vendor", "testdata", "migrations", "generated", ".git", "node_modules"]
1680-
ignored-directories:
1681-
- "my_special_dir"
16821664

16831665
gosmopolitan:
16841666
# 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
@@ -1105,10 +1105,6 @@ func (s *CustomLinterSettings) Validate() error {
11051105
}
11061106

11071107
type GounqvetSettings struct {
1108-
CheckSQLBuilders bool `mapstructure:"check-sql-builders"`
1109-
IgnoredFunctions []string `mapstructure:"ignored-functions"`
1110-
IgnoredPackages []string `mapstructure:"ignored-packages"`
1111-
AllowedPatterns []string `mapstructure:"allowed-patterns"`
1112-
IgnoredFilePatterns []string `mapstructure:"ignored-file-patterns"`
1113-
IgnoredDirectories []string `mapstructure:"ignored-directories"`
1108+
CheckSQLBuilders bool `mapstructure:"check-sql-builders"`
1109+
AllowedPatterns []string `mapstructure:"allowed-patterns"`
11141110
}

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

402402
linter.NewConfig(gounqvet.New(&cfg.Linters.Settings.Gounqvet)).
403403
WithSince("v2.5.0").
404-
WithLoadForGoAnalysis().
405404
WithURL("https://github.com/MirrexOne/gounqvet"),
406405

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

0 commit comments

Comments
 (0)