Skip to content

Code quality#40

Merged
cyanzhong merged 2 commits into
mainfrom
copilot/comprehensive-codebase-quality-scan
Mar 15, 2026
Merged

Code quality#40
cyanzhong merged 2 commits into
mainfrom
copilot/comprehensive-codebase-quality-scan

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 15, 2026

Comprehensive code quality pass: fix an async safety bug, reduce duplication, tighten style, and improve test coverage from 41 → 58 tests.

Bug fix

proofreadNow() was missing the stale-doc guard that reviewProblems() and lintScheduler.runLint() both have — async lint results could be dispatched against a changed document.

async function proofreadNow() {
  const view = MarkEdit.editorView;
  const doc = view.state.doc;
  const text = doc.toString();
  const lints = await lint(text);
  if (view.state.doc !== doc) return; // was missing
  view.dispatch({ effects: setDiagnosticsEffect.of(lints.map(lintToDiagnostic)) });
}

DRY refactoring

Extracted injectStyleSheet(id, css) in styling.ts to replace 4 copies of the same check-create-append pattern across extension.ts, tooltip.ts, card.ts, and panel.ts.

Style

  • async()async () in menu.ts
  • raw.addToDict === false ? false : trueraw.addToDict !== false in settings.ts

Test coverage

  • rules.test.ts — preset behavior, subset invariants, no duplicate rule names
  • kinds.test.ts — preset values, subset invariants
  • card.test.ts — shared card CSS structure validation
  • styling.test.ts — all kinds have light+dark colors, hover/active/badge rules generated
Original prompt

This section details on the original issue you should resolve

<issue_title>Comprehensive codebase quality scan</issue_title>
<issue_description>The goal is to conduct a comprehensive code review of the existing codebase. This includes refactoring where appropriate, ensuring consistent code style, removing unused code and resources, improving test coverage and quality, and validating that the overall architecture is coherent and maintainable. The code should be clear and easy for developers to read and follow.

Existing user-facing behavior must remain unchanged.</issue_description>

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

…, expanded tests

Co-authored-by: cyanzhong <6745066+cyanzhong@users.noreply.github.com>
Copilot AI changed the title [WIP] Conduct comprehensive codebase quality scan Code quality: stale-doc guard, DRY CSS injection, expanded test coverage Mar 15, 2026
Copilot AI requested a review from cyanzhong March 15, 2026 09:32
@cyanzhong cyanzhong changed the title Code quality: stale-doc guard, DRY CSS injection, expanded test coverage Code quality Mar 15, 2026
@cyanzhong cyanzhong marked this pull request as ready for review March 15, 2026 10:37
@cyanzhong cyanzhong merged commit 96441cc into main Mar 15, 2026
2 checks passed
@cyanzhong cyanzhong deleted the copilot/comprehensive-codebase-quality-scan branch March 15, 2026 10:41
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.

Comprehensive codebase quality scan

2 participants