2018-07-17 21:21:27 +02:00
|
|
|
package fixtures
|
|
|
|
|
2022-10-13 14:23:23 +03:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2018-07-17 21:21:27 +02:00
|
|
|
func foo(a, b, c, d int) {
|
|
|
|
a = 1.0 // ignore
|
|
|
|
b = "ignore"
|
|
|
|
c = 2 // ignore
|
|
|
|
println("lit", 12) // MATCH /avoid magic numbers like '12', create a named constant for it/
|
|
|
|
if a == 12.50 { // MATCH /avoid magic numbers like '12.50', create a named constant for it/
|
|
|
|
if b == "lit" {
|
|
|
|
c = "lit" // MATCH /string literal "lit" appears, at least, 3 times, create a named constant for it/
|
|
|
|
}
|
|
|
|
for i := 0; i < 1; i++ {
|
|
|
|
println("lit")
|
|
|
|
}
|
|
|
|
}
|
2022-10-13 14:23:23 +03:00
|
|
|
|
|
|
|
println(0666) // MATCH /avoid magic numbers like '0666', create a named constant for it/
|
|
|
|
os.Chmod("test", 0666) // ignore
|
|
|
|
os.FindProcess(102100) // ignore
|
|
|
|
fmt.Println("test", 12) // ignore
|
|
|
|
fmt.Printf("%d", 100) // MATCH /avoid magic numbers like '100', create a named constant for it/
|
2022-10-15 12:24:32 +03:00
|
|
|
myPrintln("%d", 100) // MATCH /avoid magic numbers like '100', create a named constant for it/
|
2022-10-13 14:23:23 +03:00
|
|
|
ignoredFunc(1000) // ignore
|
2022-10-15 12:24:32 +03:00
|
|
|
ignoredFunc1(1000) // ignore - match regexp too
|
2022-10-13 14:23:23 +03:00
|
|
|
|
|
|
|
println("The result of calling myFunc is: ", ignoredFunc(100)) // ignore
|
|
|
|
println("result is: ", ignoredFunc(notIgnoredFunc(ignoredFunc(100)))) // ignore
|
|
|
|
println("result of calling myFunc is: ", notIgnoredFunc(ignoredFunc(100))) // ignore
|
|
|
|
|
|
|
|
println("result myFunc is: ", notIgnoredFunc(100)) // MATCH /avoid magic numbers like '100', create a named constant for it/
|
|
|
|
println("The result is: ", ignoredFunc(notIgnoredFunc(100))) // MATCH /avoid magic numbers like '100', create a named constant for it/
|
|
|
|
}
|
|
|
|
|
|
|
|
func myPrintln(s string, num int) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-10-15 12:24:32 +03:00
|
|
|
func ignoredFunc1(num int) int {
|
2022-10-13 14:23:23 +03:00
|
|
|
return num
|
|
|
|
}
|
|
|
|
|
|
|
|
func ignoredFunc(num int) int {
|
|
|
|
return num
|
|
|
|
}
|
|
|
|
|
|
|
|
func notIgnoredFunc(num int) int {
|
|
|
|
return num
|
2018-07-17 21:21:27 +02:00
|
|
|
}
|