Skip to content

feat: add --largest-files option and duplication location details#15

Merged
exKAZUu merged 3 commits into
mainfrom
feat/largest-files-option
Jul 6, 2026
Merged

feat: add --largest-files option and duplication location details#15
exKAZUu merged 3 commits into
mainfrom
feat/largest-files-option

Conversation

@exKAZUu

@exKAZUu exKAZUu commented Jul 6, 2026

Copy link
Copy Markdown
Member

Customer Summary

  • Adds a --largest-files <n> CLI option (config key: largestFiles) that lists the n largest 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.
  • Makes duplication findings actionable: duplicated blocks findings now include the line ranges of each copy (e.g. duplicated blocks 3 >= 2 [117-128 ~ 171-182; ...]), and a new Duplicate symbols section lists cross-file duplicate declarations with file:line locations (top 10 by file count).

Technical Summary

  • src/cli.ts:
    • Adds the --largest-files flag, a findLargestFiles helper, a Largest files by code LOC text section, and a largestFiles array in the JSON output (omitted when disabled).
    • Adds an optional detail field to RiskTrigger (also present in JSON risks), populated for duplicated blocks with per-group line ranges.
    • Prints a Duplicate symbols section (capped at 10 groups) from the already-computed architecture.duplicateSymbolGroups.
  • src/metrics.ts / src/types.ts: DuplicationMetrics gains duplicateBlockGroups: DuplicateBlockOccurrence[][] with 1-based line ranges of every counted copy, grouped by shared shape (additive API change; counting logic is unchanged).
  • src/cliConfig.ts: adds largestFiles to CliOptions, CodeGaugeConfig, and ResolvedOptions with validation; defaults to 0 (disabled).
  • README.md: documents the new option.

Why

  • The high-risk findings only report files that exceed thresholds (e.g. file LOC >= 500), so there was no ranked overview of large-ish files below the thresholds. Agent workflows (e.g. the refactor-structure skill in agentic-workflows) previously relied on find | xargs wc -l | sort -rn for this; --largest-files replaces that with code LOC that respects code-gauge's ignore rules.
  • Duplication counts alone (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 against agentic-workflows/src and spot-checked the output: the reported duplicated block ranges (workflow/pullRequest.ts 117-128 vs 171-182) are an exact copy-paste, and the Duplicate symbols section correctly identifies formatError (5 files) and readPackageJson (4 files) as extract-to-shared-util candidates.
  • Confirmed --largest-files 5 (text) and --largest-files 3 --json output, and that both the section and the JSON key are omitted when the flag is absent.
  • yarn test --run (14 tests), yarn typecheck, and yarn lint all passed.

🤖 Generated with Claude Code

exKAZUu and others added 2 commits July 6, 2026 21:23
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
Co-authored-by: WillBooster (Claude Code) <agent@willbooster.com>
@exKAZUu exKAZUu changed the title feat: add --largest-files option to list largest files by code LOC feat: add --largest-files option and duplication location details Jul 6, 2026
@autofix-troubleshooter

Copy link
Copy Markdown

Hi! I'm the autofix logoautofix.ci troubleshooter bot.

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>
@exKAZUu
exKAZUu merged commit 498a961 into main Jul 6, 2026
6 checks passed
@exKAZUu
exKAZUu deleted the feat/largest-files-option branch July 6, 2026 12:44
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.

2 participants