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

Bump wastedassign to v1.0.0 #1955

Merged
merged 2 commits into from May 5, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -60,7 +60,7 @@ require (
github.com/polyfloyd/go-errorlint v0.0.0-20210418123303-74da32850375
github.com/ryancurrah/gomodguard v1.2.0
github.com/ryanrolds/sqlclosecheck v0.3.0
github.com/sanposhiho/wastedassign v0.2.0
github.com/sanposhiho/wastedassign v1.0.0
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.

28 changes: 14 additions & 14 deletions test/testdata/wastedassign.go
Expand Up @@ -27,28 +27,28 @@ func noUseParams(params string) int {

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

if false {
useOutOfIf = 200 // ERROR "reassigned, but never used afterwards"
useOutOfIf = 200 // ERROR "assigned, but never used afterwards"
return 0
} else if param == 200 {
useOutOfIf = 100 // ERROR "reassigned, but reassigned without using the value"
useOutOfIf = 100 // ERROR "assigned, 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 "reassigned, but never used afterwards"
useOutOfIf += 200 // ERROR "assigned, but never used afterwards"
return ret
}

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

noUse = 1111 // ERROR "reassigned, but never used afterwards"
noUse = 1111 // ERROR "assigned, 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 "reassigned, but never used afterwards"
useOutOfIf = 200 // ERROR "assigned, but never used afterwards"
return 0
} else if param == 100 {
ret = useOutOfIf
} else if param == 200 {
useOutOfIf = 100 // ERROR "reassigned, but reassigned without using the value"
useOutOfIf = 100 // ERROR "assigned, but reassigned without using the value"
useOutOfIf = 100
useOutOfIf = pa(useOutOfIf)
useOutOfIf += 200 // ERROR "reassigned, but reassigned without using the value"
useOutOfIf += 200 // ERROR "assigned, but reassigned without using the value"
}
useOutOfIf = 12
println(useOutOfIf)
useOutOfIf = 192
useOutOfIf += 100
useOutOfIf += 200 // ERROR "reassigned, but never used afterwards"
useOutOfIf += 200 // ERROR "assigned, but never used afterwards"
return ret
}

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

Expand Down