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

Magic number in second function parameter not reported #25

Closed
dje29 opened this issue May 11, 2021 · 2 comments
Closed

Magic number in second function parameter not reported #25

dje29 opened this issue May 11, 2021 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@dje29
Copy link

dje29 commented May 11, 2021

Short summary

It seems magic number in the 2nd parameter of a function call are not reported.

Steps to reproduce the behavior

Using this code

package main

import (
	"log"
)

func test1(err int) {
	log.Printf("something %d", err)
}

func test2(str string, err int) {
	log.Printf("%s %d", str, err)
}

func test3(err int, str string) {
	log.Printf("%s %d", str, err)
}

func test() int {
	test1(123)
	test2("something else", 123)
	test3(123, "another something else")
	return 123
}
go vet -vettool $(which mnd) ./test.go

go-mnd version or commit ref

v1.3.0

Go version (output of 'go version')

go version go1.14.15 linux/amd64

Operating system / Environment

Linux Ubuntu 18.04, but case is reproducible with docker image too

docker run --rm -v "$PWD":/app -w /app tommymuehle/go-mnd:latest ./test.go
/app/test.go:20:8: Magic number: 123, in <argument> detected
/app/test.go:22:8: Magic number: 123, in <argument> detected
/app/test.go:23:9: Magic number: 123, in <return> detected

Expected behavior

The Magic number on line 21 should be reported:

test2("something else", 123)

Actual behavior

The Magic numbers are reported for other cases but not for magic number in 2nd function parameter.

@dje29
Copy link
Author

dje29 commented May 11, 2021

For some reason the v1.3.0 is the one I get by default when I run

go get -u github.com/tommy-muehle/go-mnd/cmd/mnd

So just in case I tried building docker images from sources from current head of master: (ae979d2)

And result seems to be the same.

@tommy-muehle tommy-muehle self-assigned this May 25, 2021
@tommy-muehle tommy-muehle added the bug Something isn't working label May 25, 2021
@tommy-muehle
Copy link
Owner

@dje29
Thanks for the report! I could reproduce the behaviour. And unfortunately the README isn't up to date. Please use

go get -u github.com/tommy-muehle/go-mnd/v2/cmd/mnd

to get the latest version.

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