MCPcopy Create free account
hub / github.com/driangle/taskmd / findAllDuplicateIDs

Function findAllDuplicateIDs

apps/cli/internal/cli/duplicate.go:23–40  ·  view source on GitHub ↗

findAllDuplicateIDs returns a map of ID → file paths for IDs that appear more than once.

(tasks []*model.Task)

Source from the content-addressed store, hash-verified

21
22// findAllDuplicateIDs returns a map of ID → file paths for IDs that appear more than once.
23func 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.

Callers 2

TestFindAllDuplicateIDsFunction · 0.85
warnDuplicateIDsFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestFindAllDuplicateIDsFunction · 0.68