Skip to content

fix(visitor): detect repeated literals inside composite literal elements#46

Merged
jgautheron merged 2 commits intojgautheron:masterfrom
TobyTheHutt:feat/44-detect-string-literals-inside-composite-literals
Mar 4, 2026
Merged

fix(visitor): detect repeated literals inside composite literal elements#46
jgautheron merged 2 commits intojgautheron:masterfrom
TobyTheHutt:feat/44-detect-string-literals-inside-composite-literals

Conversation

@TobyTheHutt
Copy link
Copy Markdown
Contributor

@TobyTheHutt TobyTheHutt commented Mar 4, 2026

Implemented support for collecting repeated literals inside composite literal elements.

  • Added *ast.CompositeLit handling in the AST visitor and extraction logic for:
    • direct literal elements like []string{"x"}
    • keyed elements like map[string]string{"k":"v"} and struct{...}{Field: "x"}
  • Added visitor unit tests for composite literal detection and exclusion behavior.
  • Added API regression test proving repeated literals found only in composite literals are reported once min-occurrences is reached.

Resolves: #44

Signed-off-by: Tobias Harnickell <tobias@harnickell.ch>
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 4, 2026

Codecov Report

❌ Patch coverage is 85.71429% with 2 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@92d0720). Learn more about missing BASE report.

Files with missing lines Patch % Lines
visitor.go 85.71% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master      #46   +/-   ##
=========================================
  Coverage          ?   66.05%           
=========================================
  Files             ?        4           
  Lines             ?      766           
  Branches          ?        0           
=========================================
  Hits              ?      506           
  Misses            ?      227           
  Partials          ?       33           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@TobyTheHutt
Copy link
Copy Markdown
Contributor Author

@jgautheron hope you're the right person to look into this with.

The CI is using go-version: 1.17.x with the golangci-lint version v2.10.1, which passes the -buildvcs flag. This flag was introduced in Go 1.18. This causes the pipeline to fail.

The Go version in CI is long past deprecation, since we have Go 1.26 today and should be updated in general.

From past PRs I see, that the Test / Lint CI did not run at all, which explains why this issue only pops up now

If you like, I provide a new PR to update the GO versions in the CI to a supported Go version >1.24.0.

Signed-off-by: Tobias Harnickell <tobias@harnickell.ch>
@jgautheron
Copy link
Copy Markdown
Owner

If you like, I provide a new PR to update the GO versions in the CI to a supported Go version >1.24.0.
Yes gladly!

@jgautheron jgautheron merged commit 6a82105 into jgautheron:master Mar 4, 2026
@TobyTheHutt TobyTheHutt deleted the feat/44-detect-string-literals-inside-composite-literals branch March 5, 2026 07:33
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

Successfully merging this pull request may close these issues.

detect string literals inside composite literals

2 participants