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

wrong detection when we use copy #12

Open
MatheusNtg opened this issue Mar 22, 2022 · 1 comment
Open

wrong detection when we use copy #12

MatheusNtg opened this issue Mar 22, 2022 · 1 comment
Labels
wontfix This will not be worked on

Comments

@MatheusNtg
Copy link

if we have the following situation

func someFunc() {
	slice1 := []int{1, 2, 3}
	slice2 := make([]int, len(slice1))
	copy(slice2, slice1)
	slice2 = append(slice2, 4)
}

The linter will identify a false positive, even though we filled the slice2 with copy builtin function.

@ashanbrown
Copy link
Owner

Thanks for the report. Currently, the tool does not try to detect this case so you'd have to add a nolint for it. Feel free to put up a PR if you think you can detect this sort of case generally and reliably. The current detection engine is very simple and does not try to follow the code, so there are a lot of ways that a user could generate a false positive with this tool. The belief behind this linter is that these cases aren't so common that using nolint isn't too much of an imposition to avoid the kind of error this detects, but that may not be true for your use case if you are doing a lot of copies.

@ashanbrown ashanbrown added the wontfix This will not be worked on label Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants