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

Fails to detect some magic numbers #9

Closed
leonklingele opened this issue May 15, 2020 · 2 comments
Closed

Fails to detect some magic numbers #9

leonklingele opened this issue May 15, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@leonklingele
Copy link

Here are some cases which mnd fails to detect:

package main

import (
	"fmt"
)

func main() {
	ok()

	fail1()
	fail2()
}

func ok() {
	res := 42 * 2
	fmt.Println(res)
}

func fail1() {
	const c = 24
	res := c + (42 * 10)
	fmt.Println(res)
}

func fail2() {
	res := -12
	fmt.Println(res)
}
$ go vet -vettool $(which mnd) ./...
# mndtest
./main.go:14:9: Magic number: 42, in <operation> detected
./main.go:14:14: Magic number: 2, in <operation> detected
@tommy-muehle tommy-muehle self-assigned this May 18, 2020
@tommy-muehle tommy-muehle added the bug Something isn't working label May 18, 2020
@tommy-muehle
Copy link
Owner

@leonklingele
Thanks for the report! I'll fix it asap.

@tommy-muehle
Copy link
Owner

Fixed all missing cases in v2.0.1.
Thanks again for the report.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants