Files
codeql/go/ql/test/query-tests/RedundantCode/RedundantExpr/tst.go
2022-05-20 10:07:19 -07:00

31 lines
384 B
Go

package main
func foo(x int) int {
return x - x /* NOT OK */ + (x & x) /* NOT OK */
}
func bar(b bool, x float32) float32 {
if b {
return (x + x) / 2 // NOT OK
} else {
return (x * x) / 2 // OK
}
}
const c = 1
func baz(b bool) int {
var d = 1
if b {
return d - 1 // OK
} else {
return c - 1 // OK
}
}
func main() {
if c == '\xA8' || c == '\xA9' {
foo(42)
}
}