Skip to content

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

Open
@GrosQuildu

Description

@GrosQuildu

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)
	}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions