Skip to content

Commit

Permalink
Bump wastedassign to v1.0.0 (#1955)
Browse files Browse the repository at this point in the history
  • Loading branch information
sanposhiho committed May 5, 2021
1 parent 96a7f62 commit c213e4e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
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

0 comments on commit c213e4e

Please sign in to comment.