fix(visitor): record string occurrence for accurate position reporting by TobyTheHutt · Pull Request #49 · jgautheron/goconst (original) (raw)
Fix string position tracking so duplicate string literals report all occurrences correctly.
Previously, addString only stored positions for the first occurrence and when minOccurrences was reached, which could under-report locations. The visitor now records every occurrence while still using the existing count map for threshold checks.
Changes:
- Updated
visitor.goto append a position for every matching string occurrence. - Unit coverage in
visitor_test.gowith full position capture across differentminOccurrencesvalues. - Integration coverage in
integration_test.gowith end-to-end position counts fromtestdata.
Resolves: #45