feat: add --largest-files option and duplication location details#15
Merged
Conversation
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
|
Hi! I'm the It looks like you correctly set up a CI job that uses the autofix.ci GitHub Action, but the autofix.ci GitHub App has not been installed for this repository. This means that autofix.ci unfortunately does not have the permissions to fix this pull request. If you are the repository owner, please install the app and then restart the CI workflow! 😃 |
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Customer Summary
--largest-files <n>CLI option (config key:largestFiles) that lists thenlargest files by code LOC, so users can get an overview of where the code mass lives — including files below the risk thresholds. Default output is unchanged; the section only appears when the option is set.duplicated blocksfindings now include the line ranges of each copy (e.g.duplicated blocks 3 >= 2 [117-128 ~ 171-182; ...]), and a newDuplicate symbolssection lists cross-file duplicate declarations withfile:linelocations (top 10 by file count).Technical Summary
src/cli.ts:--largest-filesflag, afindLargestFileshelper, aLargest files by code LOCtext section, and alargestFilesarray in the JSON output (omitted when disabled).detailfield toRiskTrigger(also present in JSONrisks), populated forduplicated blockswith per-group line ranges.Duplicate symbolssection (capped at 10 groups) from the already-computedarchitecture.duplicateSymbolGroups.src/metrics.ts/src/types.ts:DuplicationMetricsgainsduplicateBlockGroups: DuplicateBlockOccurrence[][]with 1-based line ranges of every counted copy, grouped by shared shape (additive API change; counting logic is unchanged).src/cliConfig.ts: addslargestFilestoCliOptions,CodeGaugeConfig, andResolvedOptionswith validation; defaults to 0 (disabled).README.md: documents the new option.Why
refactor-structureskill in agentic-workflows) previously relied onfind | xargs wc -l | sort -rnfor this;--largest-filesreplaces that with code LOC that respects code-gauge's ignore rules.duplicated blocks 3 >= 2,duplicate symbol groups 5 >= 5) tell users that duplication exists but not where, so they could not act on the finding without re-discovering it. The locations were already computed (or trivially available from the AST) but never surfaced in the report.Testing
yarn build, then ran the CLI againstagentic-workflows/srcand spot-checked the output: the reported duplicated block ranges (workflow/pullRequest.ts117-128 vs 171-182) are an exact copy-paste, and theDuplicate symbolssection correctly identifiesformatError(5 files) andreadPackageJson(4 files) as extract-to-shared-util candidates.--largest-files 5(text) and--largest-files 3 --jsonoutput, and that both the section and the JSON key are omitted when the flag is absent.yarn test --run(14 tests),yarn typecheck, andyarn lintall passed.🤖 Generated with Claude Code