[yamllint-fixer] Fix yamllint comments-indentation for fully-commented on: children - #46960
Conversation
When every child of an `on:` event key (e.g. `deployment_status:`) is commented out, the trailing comment block sat at the child indent (4) while its parent key was at indent 2 and the following top-level key at column 0, tripping yamllint's comments-indentation rule. dedentTrailingOnCommentBlock now dedents a deep trailing block to column 0 when its nearest real content line is a shallower parent key (no sibling to anchor to), while still preserving nested-event blocks that have a real sibling at their indent. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. No ADR enforcement needed: PR #46960 does not have the 'implementation' label and has only 62 new lines of code in business logic directories (threshold: 100). |
|
✅ PR Code Quality Reviewer completed the code quality review. |
|
✅ Test Quality Sentinel completed test quality analysis. |
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅ |
There was a problem hiding this comment.
Pull request overview
Refines YAML generation to dedent fully commented nested on: children and eliminate yamllint indentation warnings.
Changes:
- Detects fully commented nested event parents.
- Adds regression coverage for dedented and preserved blocks.
Show a summary per file
| File | Description |
|---|---|
pkg/workflow/frontmatter_on_section_cleanup.go |
Refines trailing-comment dedentation. |
pkg/workflow/frontmatter_on_section_cleanup_test.go |
Adds regression cases. |
Review details
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
- Review effort level: Medium
| if anchorIndent >= firstLineIndent { | ||
| return lines |
There was a problem hiding this comment.
Logic is correct and well-tested. The anchor-based check cleanly distinguishes the fully-commented-parent case (dedent) from the real-sibling case (preserve), and the two new regression tests cover both paths. No issues found.
🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 13 AIC · ⌖ 4.99 AIC · ⊞ 5K
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /diagnosing-bugs and /tdd — approving with one minor observation.
📋 Key Themes & Highlights
Key Themes
- Root cause vs symptom: The fix correctly targets the real problem (over-broad early-return in
dedentTrailingOnCommentBlock) rather than suppressing the yamllint warning downstream. - Anchor heuristic: Looking at the nearest preceding non-blank line and comparing indentation levels is simple and effective for the described cases.
- Test coverage: Both the regression case (fully-commented parent → dedent) and the guard case (real sibling → no dedent) are covered.
Positive Highlights
- ✅ Clear code comments explaining the before/after semantics
- ✅ Both the bug case and the adjacent "preserve" case are tested
- ✅ The logic change is minimal and surgical
Observation
The anchor walk (anchor-- loop) can cross outside the on: block if the trailing comment block starts early. In practice this is safe because an on: key itself sits at indent 0, which is always shallower than the comment indent, so the heuristic still dedents correctly. But if the section ever gains a preceding non-blank line that happens to be at the same indent as the comment (e.g. another deeply-nested event key), the guard would fire and leave the comments un-dedented. Consider adding a comment noting this assumption, or bounding the anchor search to the section's start index.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 21.1 AIC · ⌖ 4.47 AIC · ⊞ 6.7K
Comment /matt to run again
🧪 Test Quality Sentinel Report✅ Test Quality Score: 100/100 — Excellent
📊 Metrics (2 tests)
📋 Analysis DetailsTest Structure:
Design Invariants Verified:
Quality Signals:
Verdict
Both new tests are high-value, precise design-level tests that directly validate the bug fix and its critical boundary condition. The table-driven structure and comprehensive assertions provide strong confidence in the behavior.
|
There was a problem hiding this comment.
Clean fix. The anchor-walk logic is correct — the start-walk at line 738 already guarantees lines[start-1] is a non-blank, non-comment real content line, so the anchor blank-skip loop in the new branch is simply extra safety. Both test cases cover the two new branches precisely.
Minor: tab/space byte-count assumption (pre-existing)
firstLineIndent and anchorIndent are computed as raw byte lengths via len(s) - len(strings.TrimLeft(s, " \t")), so a tab counts as 1, not 8. Mixed tab/space indentation in the same on: block would produce a wrong anchorIndent >= firstLineIndent comparison. This assumption is shared with the existing firstLineIndent <= 2 path above and is not introduced by this PR; mixed indentation in GitHub Actions YAML is virtually nonexistent in practice. Not blocking.
🔎 Code quality review by PR Code Quality Reviewer · 35.2 AIC · ⌖ 4.4 AIC · ⊞ 5.6K
Comment /review to run again
|
@copilot run pr-finisher skill |
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Fixed in 63ba691. The reviewer was correct — the new dedent condition also matched |
|
🎉 This pull request is included in a new release. Release: |
Summary
Fixes a yamllint
comments-indentationwarning that appeared when anon:event key (e.g.deployment_status:) had all its children commented out. In that case the previous logic kept the comment block at its original 4-space indent, which violated yamllint's rule because the nearest real content line is the shallower parent key. The fix dedents those fully-commented blocks to column 0.When at least one real sibling line exists at the same indentation (e.g.
types:alongside# forks:), the block is left untouched as before.Changes
pkg/workflow/frontmatter_on_section_cleanup.gopkg/workflow/frontmatter_on_section_cleanup_test.go"deeply nested trailing block whose parent has no real children is dedented"— verifiesdeployment_status:with only commented-out children is dedented."deeply nested trailing block with a real sibling at its indent is left untouched"— verifiespull_request:with bothtypes:and commented# forks:retains indentation.pkg/workflow/compiler_forks_test.gopull_request:.Motivation
The yamllint
comments-indentationrule requires comments to align with the content that follows them. A deeply-indented comment block with no real sibling content has no valid anchor at that indent level; dedenting to column 0 matches the top-level content that follows theon:section and satisfies the linter.Testing
All changes are covered by updated and new unit tests in
frontmatter_on_section_cleanup_test.goandcompiler_forks_test.go.