Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pkg/lint/lintersdb/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config {
WithSince("v1.38.0").
WithPresets(linter.PresetStyle).
WithLoadForGoAnalysis().
WithURL("https://github.com/sanposhiho/wastedassign").
WithNoopFallback(m.cfg),
WithURL("https://github.com/sanposhiho/wastedassign"),

linter.NewConfig(golinters.NewWhitespace(whitespaceCfg)).
WithSince("v1.19.0").
Expand Down
8 changes: 7 additions & 1 deletion test/testdata/sqlclosecheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var (
)

func rowsCorrectDeferBlock() {

rows, err := db.QueryContext(ctx, "SELECT name FROM users WHERE age=?", age)
if err != nil {
log.Fatal(err)
Expand Down Expand Up @@ -91,6 +90,13 @@ func rowsMissingClose() {
log.Printf("%s are %d years old", strings.Join(names, ", "), age)
}

func rowsMissingCloseG[T ~int64](db *sql.DB, a T) {
rows, _ := db.Query("select id from tb") // want "Rows/Stmt was not closed"
for rows.Next() {
// ...
}
}

func rowsNonDeferClose() {
rows, err := db.QueryContext(ctx, "SELECT name FROM users WHERE age=?", age)
if err != nil {
Expand Down
12 changes: 12 additions & 0 deletions test/testdata/wastedassign.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ func mugen() {
return
}

func mugenG[T ~int](hoge T) {
var i int
for {
hoge = 5 // want "assigned to hoge, but reassigned without using the value"
// break
}

println(i)
println(hoge)
return
}

func noMugen() {
var i int
var hoge int
Expand Down