findAllDuplicateIDs returns a map of ID → file paths for IDs that appear more than once.
(tasks []*model.Task)
| 21 | |
| 22 | // findAllDuplicateIDs returns a map of ID → file paths for IDs that appear more than once. |
| 23 | func findAllDuplicateIDs(tasks []*model.Task) map[string][]string { |
| 24 | counts := make(map[string][]*model.Task) |
| 25 | for _, t := range tasks { |
| 26 | counts[t.ID] = append(counts[t.ID], t) |
| 27 | } |
| 28 | |
| 29 | dupes := make(map[string][]string) |
| 30 | for id, group := range counts { |
| 31 | if len(group) > 1 { |
| 32 | paths := make([]string, len(group)) |
| 33 | for i, t := range group { |
| 34 | paths[i] = t.FilePath |
| 35 | } |
| 36 | dupes[id] = paths |
| 37 | } |
| 38 | } |
| 39 | return dupes |
| 40 | } |
| 41 | |
| 42 | // warnDuplicateIDs prints a warning to stderr if any duplicate IDs exist. |
| 43 | // Returns the duplicate map for callers that need it. |
no outgoing calls