Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wastedassign to v2.0.6 #2020

Merged
merged 2 commits into from
May 29, 2021
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ require (
github.com/polyfloyd/go-errorlint v0.0.0-20210510181950-ab96adb96fea
github.com/ryancurrah/gomodguard v1.2.1
github.com/ryanrolds/sqlclosecheck v0.3.0
github.com/sanposhiho/wastedassign v1.0.0
github.com/sanposhiho/wastedassign/v2 v2.0.6
github.com/securego/gosec/v2 v2.7.0
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c
github.com/shirou/gopsutil/v3 v3.21.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/golinters/wastedassign.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package golinters

import (
"github.com/sanposhiho/wastedassign"
"github.com/sanposhiho/wastedassign/v2"
"golang.org/x/tools/go/analysis"

"github.com/golangci/golangci-lint/pkg/golinters/goanalysis"
Expand Down
28 changes: 14 additions & 14 deletions test/testdata/wastedassign.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,28 +27,28 @@ func noUseParams(params string) int {

func f(param int) int {
println(param)
useOutOfIf := 1212121 // ERROR "assigned, but reassigned without using the value"
useOutOfIf := 1212121 // ERROR "assigned to useOutOfIf, but reassigned without using the value"
ret := 0
if false {
useOutOfIf = 200 // ERROR "assigned, but never used afterwards"
useOutOfIf = 200 // ERROR "assigned to useOutOfIf, but never used afterwards"
return 0
} else if param == 100 {
useOutOfIf = 100 // ERROR "assigned, but reassigned without using the value"
useOutOfIf = 100 // ERROR "assigned to useOutOfIf, but reassigned without using the value"
useOutOfIf = 201
useOutOfIf = pa(useOutOfIf)
useOutOfIf += 200 // ERROR "assigned, but reassigned without using the value"
useOutOfIf += 200 // ERROR "assigned to useOutOfIf, but reassigned without using the value"
} else {
useOutOfIf = 100
useOutOfIf += 100
useOutOfIf = pa(useOutOfIf)
useOutOfIf += 200 // ERROR "assigned, but reassigned without using the value"
useOutOfIf += 200 // ERROR "assigned to useOutOfIf, but reassigned without using the value"
}

if false {
useOutOfIf = 200 // ERROR "assigned, but never used afterwards"
useOutOfIf = 200 // ERROR "assigned to useOutOfIf, but never used afterwards"
return 0
} else if param == 200 {
useOutOfIf = 100 // ERROR "assigned, but reassigned without using the value"
useOutOfIf = 100 // ERROR "assigned to useOutOfIf, but reassigned without using the value"
useOutOfIf = 201
useOutOfIf = pa(useOutOfIf)
useOutOfIf += 200
Expand All @@ -62,7 +62,7 @@ func f(param int) int {
println(useOutOfIf)
useOutOfIf = 192
useOutOfIf += 100
useOutOfIf += 200 // ERROR "assigned, but never used afterwards"
useOutOfIf += 200 // ERROR "assigned to useOutOfIf, but never used afterwards"
return ret
}

Expand All @@ -71,7 +71,7 @@ func checkLoopTest() int {
noUse := 1111
println(noUse)

noUse = 1111 // ERROR "assigned, but never used afterwards"
noUse = 1111 // ERROR "assigned to noUse, but never used afterwards"
for {
if hoge == 14 {
break
Expand All @@ -86,29 +86,29 @@ func r(param int) int {
useOutOfIf := 1212121
ret := 0
if false {
useOutOfIf = 200 // ERROR "assigned, but never used afterwards"
useOutOfIf = 200 // ERROR "assigned to useOutOfIf, but never used afterwards"
return 0
} else if param == 100 {
ret = useOutOfIf
} else if param == 200 {
useOutOfIf = 100 // ERROR "assigned, but reassigned without using the value"
useOutOfIf = 100 // ERROR "assigned to useOutOfIf, but reassigned without using the value"
useOutOfIf = 100
useOutOfIf = pa(useOutOfIf)
useOutOfIf += 200 // ERROR "assigned, but reassigned without using the value"
useOutOfIf += 200 // ERROR "assigned to useOutOfIf, but reassigned without using the value"
}
useOutOfIf = 12
println(useOutOfIf)
useOutOfIf = 192
useOutOfIf += 100
useOutOfIf += 200 // ERROR "assigned, but never used afterwards"
useOutOfIf += 200 // ERROR "assigned to useOutOfIf, but never used afterwards"
return ret
}

func mugen() {
var i int
var hoge int
for {
hoge = 5 // ERROR "assigned, but reassigned without using the value"
hoge = 5 // ERROR "assigned to hoge, but reassigned without using the value"
// break
}

Expand Down