plan 51: add MDS036 section-size-limits rule - #143
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #143 +/- ##
==========================================
+ Coverage 86.35% 86.61% +0.26%
==========================================
Files 94 95 +1
Lines 10149 10350 +201
==========================================
+ Hits 8764 8965 +201
Misses 903 903
Partials 482 482 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
MDS036 caps per-section line counts with lookup order per-heading (regex), per-level, then default max. A section spans a heading up to the next heading of any level, so nested subsections are measured independently of their parent. Disabled by default. Also primes MDS033's sync.Once warning in the integration fixture runner so rules alphabetically after MDS033 don't inherit a spurious "no allowed patterns" diagnostic from cross-test state.
32ddc21 to
a81e970
Compare
Add tests for uncovered branches (EnabledByDefault, int64/float max, per-level/per-heading validation errors, map[any]any keys from YAML). Drop the unreachable length<0 clamp and headingLine fallback so all remaining statements are exercised.
There was a problem hiding this comment.
Pull request overview
Adds a new Markdown lint rule (MDS036) to enforce per-section line-count limits, with configuration precedence by heading regex, heading level, then default max, and updates integration test setup to avoid a cross-test MDS033 warning artifact.
Changes:
- Introduces MDS036
section-size-limitsrule implementation + unit tests, rule docs, and fixture samples. - Registers the new rule across CLI/config/engine and updates the rules index.
- Primes MDS033’s one-time “no allowed patterns” warning in the integration fixture runner to prevent order-dependent diagnostics.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| plan/51_section-level-size-limits.md | Marks plan 51 complete and records implementation notes for MDS036. |
| PLAN.md | Updates plan 51 status to completed. |
| internal/rules/sectionsizelimits/rule.go | Implements the MDS036 rule logic and settings parsing. |
| internal/rules/sectionsizelimits/rule_test.go | Adds unit coverage for section sizing and settings parsing/validation. |
| internal/rules/MDS036-section-size-limits/README.md | Documents MDS036 behavior and configuration. |
| internal/rules/MDS036-section-size-limits/good/default.md | Adds “good” fixture for default max behavior. |
| internal/rules/MDS036-section-size-limits/good/per-level.md | Adds “good” fixture for per-level override behavior. |
| internal/rules/MDS036-section-size-limits/bad/default.md | Adds “bad” fixture validating default max diagnostic. |
| internal/rules/MDS036-section-size-limits/bad/per-level.md | Adds “bad” fixture validating per-level diagnostic. |
| internal/rules/index.md | Adds MDS036 to the rule catalog index. |
| internal/integration/rules_test.go | Primes MDS033’s sync.Once warning before running fixtures. |
| internal/engine/categories_test.go | Ensures MDS036 is registered for category tests. |
| internal/config/config_test.go | Ensures MDS036 is registered for config tests. |
| cmd/mdsmith/main.go | Registers MDS036 with the CLI build via blank import. |
Return all keys from DefaultSettings so re-applying defaults (as the fixture runner cleanup does) fully clears PerLevel and PerHeading, not just Max. Add a defensive headingLine fallback for headings with no line segments, matching the existing pattern in emptysectionbody.
Align with max-file-length naming. "Size" was ambiguous (bytes? tokens?); "length" mirrors the file-level analog and makes it clear the limit counts lines. Renames: - package sectionsizelimits -> maxsectionlength - rule name section-size-limits -> max-section-length - fixture dir MDS036-section-size-limits -> MDS036-max-section-length
| Per-level and per-heading overrides: | ||
|
|
||
| ```yaml | ||
| rules: | ||
| max-section-length: | ||
| max: 100 | ||
| per-level: | ||
| 1: 200 | ||
| 2: 80 | ||
| per-heading: | ||
| - pattern: "^Changelog$" | ||
| max: 500 | ||
| ``` |
There was a problem hiding this comment.
The rule supports per-heading (regex-based) limits, but there are no integration fixture files exercising per-heading settings. Consider adding at least one good/ and one bad/ fixture that uses per-heading to validate YAML/front-matter decoding and end-to-end behavior (similar to the existing default/per-level fixtures).
| 4. Document configuration and examples. | ||
| 1. [x] Define section boundary detection rules for heading levels. | ||
| 2. [x] Add configuration for per-heading or per-pattern limits. | ||
| 3. [x] Implement rule to count section length by lines or tokens. |
There was a problem hiding this comment.
Task 3 still says the rule counts section length by "lines or tokens", but the implementation/config in this PR is line-based only (Max/per-level/per-heading are line counts). Update the task text to match the implemented behavior so the completed plan remains accurate.
| 3. [x] Implement rule to count section length by lines or tokens. | |
| 3. [x] Implement rule to count section length by lines. |
|
🟢 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. |
MDS036 caps per-section line counts with lookup order per-heading
(regex), per-level, then default max. A section spans a heading up
to the next heading of any level, so nested subsections are measured
independently of their parent. Disabled by default.
Also primes MDS033's sync.Once warning in the integration fixture
runner so rules alphabetically after MDS033 don't inherit a spurious
"no allowed patterns" diagnostic from cross-test state.