-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Summary
Implement executable line counting (exLOC) as the primary line metric for context-aware telemetry, while continuing to report physical lines for visibility. This aligns enforcement/assessment with real code changes and stops penalizing documentation.
Why
- Physical lines penalize comments/docs and misrepresent refactors.
- exLOC correlates better with complexity and health.
Prior Art
- Prototypes in /line_count (EXECUTABLE-LINES.md, line-counter.js, analyzer-enhanced.js, tests).
Scope
- Analyzer: compute and emit lines.physical, lines.executable, lines.comments, lines.commentRatio.
- Telemetry (context-aware output): print deltas for physical vs executable and add a short assessment.
- Configuration (.ai-coding-guide.json):
- ratchet.lineCountMode: "executable" | "physical" (default: "executable" for telemetry; gating unaffected)
- ratchet.metrics.trackPhysicalLines/trackExecutableLines/trackCommentRatio (booleans; default true)
- CI: keep non-blocking; no gating changes in this issue.
- Docs: add EXECUTABLE-LINES.md and a section in CONTEXT-AWARE-LINTING.md.
- Tests: unit for line counting; integration snapshot for telemetry output.
Non-Goals (here)
- Intent detection, domain-awareness, temporal trends (tracked separately; this lays the foundation).
- Changing ESLint rule thresholds (we already skip comments in limits).
Implementation Plan
- Create metrics/line-counter.js (production location) with removeComments/removeBlankLines/countExecutableLines/getLineMetrics.
- Wire into analyze pipeline (bin/cli.js analyze) to populate metrics in analysis-current.json.
- Update context-aware ratchet output to include Lines section with deltas (physical vs executable) and comment ratio.
- Config: read ratchet.lineCountMode + metrics flags from .ai-coding-guide.json (fallbacks safe).
- Unit tests for line-counter (ported from /line_count and aligned to production path).
- Integration test: run lint:json + analyze:current and snapshot Lines section.
- Docs: new docs/EXECUTABLE-LINES.md + link from CONTEXT-AWARE-LINTING.md.
Acceptance Criteria
- Analysis outputs lines.physical, lines.executable, lines.comments, lines.commentRatio.
- Context-aware run prints Lines block with deltas and clear assessment.
- Gating remains unchanged (traditional ratchet only) pending Health Gating Enforcement for Context-Aware Ratchet #203.
- Tests green; CI step non-blocking and visible.
- Docs published.
Cross-links
- Burn-in + promotion: Ratchet 2.0: context-aware code health, critical vs minor policy, weighted/density metrics, heuristics (Phase 2 next) #198
- Health gating: Health Gating Enforcement for Context-Aware Ratchet #203 (future: gate on exLOC-based density/health)
- Ongoing refactors: [Phase 3A] Reduce Cyclomatic Complexity (≥30% cut) across top hotspots #182/[Phase 3B] Architecture splits (>=30% reduction in max-lines/length warnings) #183 (this will provide better telemetry for them).
Notes
- Use /line_count prototypes as a starting point; refine regexes and edge cases over time.
- We can later add language-aware parsing if needed.
Metadata
Metadata
Assignees
Labels
No labels