Skip to content

Commit

Permalink
Merge pull request #25 from sanposhiho/fix/match-the-wording-of-READM…
Browse files Browse the repository at this point in the history
…E-and-report-from-wastedassign

Match the wording of the readme and report from wastedassign
  • Loading branch information
sanposhiho committed Mar 4, 2021
2 parents e18aa2d + e4067d2 commit 185ca7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions testdata/src/a/a.go
Expand Up @@ -28,28 +28,28 @@ func noUseParams(params string) int {

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

if false {
useOutOfIf = 200 // want "reassigned, but never used afterwards"
return 0
} else if param == 200 {
useOutOfIf = 100 // want "wasted assignment"
useOutOfIf = 100 // want "reassigned, but reassigned without using the value"
useOutOfIf = 201
useOutOfIf = pa(useOutOfIf)
useOutOfIf += 200
Expand Down Expand Up @@ -92,10 +92,10 @@ func r(param int) int {
} else if param == 100 {
ret = useOutOfIf
} else if param == 200 {
useOutOfIf = 100 // want "wasted assignment"
useOutOfIf = 100 // want "reassigned, but reassigned without using the value"
useOutOfIf = 100
useOutOfIf = pa(useOutOfIf)
useOutOfIf += 200 // want "wasted assignment"
useOutOfIf += 200 // want "reassigned, but reassigned without using the value"
}
useOutOfIf = 12
println(useOutOfIf)
Expand All @@ -109,7 +109,7 @@ func mugen() {
var i int
var hoge int
for {
hoge = 5 // want "wasted assignment"
hoge = 5 // want "reassigned, but reassigned without using the value"
// break
}

Expand Down
2 changes: 1 addition & 1 deletion wastedassign.go
Expand Up @@ -155,7 +155,7 @@ func (wr wastedReason) String() string {
case noUseUntilReturn:
return "reassigned, but never used afterwards"
case reassignedSoon:
return "wasted assignment"
return "reassigned, but reassigned without using the value"
case notWasted:
return ""
default:
Expand Down

0 comments on commit 185ca7f

Please sign in to comment.