Add Phase 4 edge case test coverage for rules packages - #156
Conversation
Cover low-coverage paths in requiredstructure (cueExprForValue with []any/map inputs, extractYAML unclosed front matter, writeNodeText CodeSpan branch, advanceToMatch no-match path, extractPIFileParam multi-line PI), crossfilereferenceintegrity (DefaultSettings, configDiag via invalid glob, parseTarget anchor-only/encoded/empty/protocol-relative, toStringSlice mixed-type []any), concisenessscoring/classifier (validateArtifact per-field errors, compileLexicon per-list insufficiency), and catalog (Category, scanIncludesForTarget depth/read/match/cycle fallbacks, resolveGitignore disabled/no-matcher/source-dir paths). Coverage improvements: catalog 92.8→94.1%, crossfilereferenceintegrity 85.8→88.1%, requiredstructure 87.9→90.9%, classifier 90.2→93.4%. https://claude.ai/code/session_01JixwRS7SKuEBR1jV7fAJat
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #156 +/- ##
==========================================
+ Coverage 87.06% 87.69% +0.62%
==========================================
Files 97 97
Lines 10346 10346
==========================================
+ Hits 9008 9073 +65
+ Misses 856 805 -51
+ Partials 482 468 -14 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR expands unit test coverage for Phase 4 edge cases across multiple mdsmith rule packages, focusing on previously untested validation/error paths and boundary conditions to support the repo’s coverage-improvement plan.
Changes:
- Added new edge-case/unit tests for
requiredstructure,crossfilereferenceintegrity,concisenessscoring/classifier, andcatalog. - Updated the coverage plan to mark Phase 4 tasks (and local “run tests/lint” checklist) as completed.
- Ignored
coverage.outto prevent coverage artifacts from being accidentally committed.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| plan/85_coverage-to-95-percent.md | Marks Phase 4 coverage tasks as completed and records test/lint runs. |
| internal/rules/requiredstructure/rule_test.go | Adds tests for CUE expr generation, YAML extraction edge cases, heading text CodeSpan path, heading matching no-match paths, and multi-line PI parsing. |
| internal/rules/crossfilereferenceintegrity/rule_test.go | Adds tests for defaults, invalid glob → config diagnostic, parseTarget edge cases, type conversion failures, and anchor-only missing heading behavior. |
| internal/rules/concisenessscoring/classifier/model_test.go | Adds tests for artifact validation failures and per-list lexicon minimum-size validation. |
| internal/rules/catalog/rule_test.go | Adds tests for rule category, gitignore resolution variants, and include-scan fallback paths (depth/read errors/no includes/direct match/cycle skip). |
| .gitignore | Adds coverage.out ignore entry for coverage artifacts. |
Mark "All tests pass" and "golangci-lint reports no issues" as completed in the Acceptance Criteria section, consistent with the Phase 4 run-checklist already marked done. https://claude.ai/code/session_01JixwRS7SKuEBR1jV7fAJat
|
🟢 Merge Queue — picked up This PR is in the queue and will be batched with other Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run. |
|
🔵 Merge Queue — CI running Merged into batch branch Next: No action needed — you'll be notified when CI completes. |
|
✅ Merge Queue — merged This PR landed on Next: Done — nothing more to do here. |
Summary
This PR adds comprehensive test coverage for edge cases and error paths across four rule packages (
concisenessscoring/classifier,crossfilereferenceintegrity,requiredstructure, andcatalog), targeting Phase 4 of the coverage improvement plan. These tests cover validation logic, error handling, and boundary conditions that were previously untested.Key Changes
concisenessscoring/classifier
TestValidateArtifact_*tests covering field validation:model_idandversionfieldsTestCompileLexicon_*tests for per-list validation:crossfilereferenceintegrity
TestDefaultSettingsto verify default rule configurationTestCheck_InvalidIncludeGlobReturnsConfigDiagfor invalid glob pattern handlingTestParseTarget_*tests covering edge cases:#section)TestToStringSlice_*tests for type conversion edge casesTestCheck_AnchorOnlyLinkMissingHeadingfor anchor validationrequiredstructure
TestCueExprForValue_*tests for CUE expression generation:TestExtractYAML_*tests for YAML front matter extraction:TestHeadingText_WithCodeSpanfor code span handling in headingsTestAdvanceToMatch_*tests for heading matching logic:TestExtractPIFileParam_MultiLinefor multi-line processing instruction parsingcatalog
TestRule_Categoryto verify rule categorizationTestResolveGitignore_*tests for gitignore resolution:TestScanIncludesForTarget_*tests for include scanning fallback paths:Documentation
plan/85_coverage-to-95-percent.mdto mark Phase 4 tasks as completecoverage.outto.gitignorefor test coverage artifactsNotable Implementation Details
TestValidateArtifact_InvalidThreshold)strings.Containsfstest.MapFS) used for file I/O testinghttps://claude.ai/code/session_01JixwRS7SKuEBR1jV7fAJat