Skip to content

test(diffguard-lsp): cover text.rs edge cases#1608

Merged
EffortlessSteven merged 2 commits into
mainfrom
claude/improve-code-coverage-dZYp6-lsp-text
May 16, 2026
Merged

test(diffguard-lsp): cover text.rs edge cases#1608
EffortlessSteven merged 2 commits into
mainfrom
claude/improve-code-coverage-dZYp6-lsp-text

Conversation

@EffortlessSteven
Copy link
Copy Markdown
Member

@EffortlessSteven EffortlessSteven commented May 16, 2026

Summary

Closes the largest coverage gap in crates/diffguard-lsp/src/text.rs (was 86.93% region coverage, 26 uncovered regions). Pure test-only additions — no behavior change.

Closes #1609 (tracked alongside sibling PRs).

New unit tests cover:

  • split_lines with empty input and single-line input
  • changed_lines_between for identical inputs and truncation boundary
  • build_synthetic_diff skipping line 0 and out-of-range lines, and header-only output when no lines change
  • apply_incremental_change with no range (full replace), invalid start position, invalid end position, and start-after-end errors
  • byte_offset_at_position end-of-text, past-end, past-last-line, character beyond line length, and multibyte (surrogate-pair) handling
  • utf16_length surrogate-pair counting

The one .expect("apply") line uses an inline // diffguard: ignore rust.no_unwrap suppression — it's inside #[cfg(test)] and matches the same idiom used by the pre-existing test on line 159, but the diff lint can't distinguish test modules from production code in src/.

Test plan

  • cargo test -p diffguard-lsp text:: — 20/20 pass
  • cargo clippy -p diffguard-lsp --all-targets -- -D warnings — clean
  • cargo fmt -p diffguard-lsp -- --check

Adds unit tests for split_lines empty input, build_synthetic_diff edge
cases (line 0 skip, out-of-range lines, no-change header), incremental
change handling (no-range full replace, invalid start/end positions,
start-after-end error), byte_offset_at_position end-of-text and
past-line boundaries plus multibyte UTF-16 handling, and utf16_length
surrogate-pair counting.

Pure test-only additions — no behavior change. Closes a 26-region
coverage gap in diffguard-lsp/src/text.rs (was 86.93% region coverage).
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

Warning

Rate limit exceeded

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

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 76c90782-d7a6-43a3-b107-fd55cd2ed303

📥 Commits

Reviewing files that changed from the base of the PR and between 29bd0ad and 3461f13.

📒 Files selected for processing (1)
  • crates/diffguard-lsp/src/text.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/improve-code-coverage-dZYp6-lsp-text

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.

Comment thread crates/diffguard-lsp/src/text.rs Fixed
Inline 'diffguard: ignore' on the .expect("apply") used in
apply_incremental_change_with_no_range_replaces_whole_text. The line is
in a #[cfg(test)] module so the rule's intent does not apply, but the
diff lint cannot distinguish test modules from src/ files.

Refs #1609.
@EffortlessSteven EffortlessSteven marked this pull request as ready for review May 16, 2026 18:47
@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@EffortlessSteven EffortlessSteven merged commit 69d3b4c into main May 16, 2026
18 of 19 checks passed
@EffortlessSteven EffortlessSteven deleted the claude/improve-code-coverage-dZYp6-lsp-text branch May 16, 2026 18:48
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.

Close code coverage gaps in lsp + analytics + main

3 participants