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

iterate-over-empty-map.yaml false positives #47

Open
GrosQuildu opened this issue Jan 18, 2024 · 0 comments
Open

iterate-over-empty-map.yaml false positives #47

GrosQuildu opened this issue Jan 18, 2024 · 0 comments

Comments

@GrosQuildu
Copy link
Collaborator

The iterate-over-empty-map.yaml should exclude from results cases when the map is passed to a function - the function probably will write to it. We can use cross-function analysis from pro engine to check if there really are the writes.

package main

import "fmt"

func Do(y map[string]int64) int64 {
	y["a"] = 1
	y["b"] = 2
	return 3
}

func main() {
	fmt.Println("Hello, 世界")
	x := map[string]int64{}
	Do(x)
	fmt.Printf("%d\n", len(x))
	for k, v := range x {
		fmt.Println(k, v)
	}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant