hardcodedfilepath: include same-package unexported consts in reuse suggestions - #52948
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes scope-aware constant reuse suggestions in the hardcodedfilepath analyzer.
Changes:
- Includes unexported constants from the current package.
- Preserves exported-only filtering for imported constants.
- Adds regression coverage for local unexported constant reuse.
Show a summary per file
| File | Description |
|---|---|
pkg/linters/hardcodedfilepath/hardcodedfilepath.go |
Applies source-specific visibility filtering. |
pkg/linters/hardcodedfilepath/testdata/src/hardcodedfilepath/hardcodedfilepath.go |
Tests reuse of an unexported local constant. |
Review details
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Balanced
|
@copilot All checks are green, but this PR still needs a maintainer-ready finish. Please refresh the branch if needed and run the
|
…filepath-const-filter Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Refreshed the branch with current |
|
🎉 This pull request is included in a new release. Release: |
collectKnownPathConstsapplied an exported-only filter to both imported constants and current-package constants. That caused same-package duplicates of unexported path constants to be misdiagnosed as “extract a new constant” instead of “reuse existing constant”.Behavioral fix: scope-aware constant visibility
collectKnownPathConststo treat visibility differently by source:*constants*packages: keep exported-only filteringRegression coverage: same-package unexported reuse path
localPathConst(not extraction of a new constant).