Skip to content

fix: add bounds checking for CLI array index accesses#221

Merged
himerus merged 1 commit intodevfrom
feature/fix-add-bounds-checking-for-cli-array
Mar 26, 2026
Merged

fix: add bounds checking for CLI array index accesses#221
himerus merged 1 commit intodevfrom
feature/fix-add-bounds-checking-for-cli-array

Conversation

@himerus
Copy link
Copy Markdown
Contributor

@himerus himerus commented Mar 26, 2026

Summary

src/cli/index.ts has 12+ locations that access args[0], args[1] without bounds checking before access. Example at lines 375-376:

const cemA = args[0];
const cemB = args[1];
if (!cemA || !cemB) {  // Only checked AFTER access

While TypeScript's noUncheckedIndexedAccess flag makes these return T | undefined, the pattern is inconsistent — some locations check before access, others after. Standardize to check array length first, then access.

Acceptance criteria:

  1. All args[] ...

Created automatically by Automaker

Standardize all required args[] accesses in cli/index.ts to check
args.length first, then access with type assertion. This applies to
cmdHealth (trend), cmdMigrate, cmdSuggest, cmdBundle, cmdCompare,
cmdValidate, and cmdCdn — replacing the pattern of access-then-check
with the consistent check-before-access pattern.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@himerus himerus merged commit 600373c into dev Mar 26, 2026
4 of 8 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 26, 2026

Warning

Rate limit exceeded

@himerus has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 15 minutes and 3 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7705f42a-40e2-4c9e-ac0a-ff19b7c189f8

📥 Commits

Reviewing files that changed from the base of the PR and between 8208b22 and 201ebaa.

📒 Files selected for processing (1)
  • src/cli/index.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix-add-bounds-checking-for-cli-array

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant