Skip to content

[yamllint-fixer] Reduce yamllint trailing-spaces noise in generated lock files#43580

Open
github-actions[bot] wants to merge 4 commits into
mainfrom
fix-yamllint-trailing-spaces-generator-ebb9dc5c22330b13
Open

[yamllint-fixer] Reduce yamllint trailing-spaces noise in generated lock files#43580
github-actions[bot] wants to merge 4 commits into
mainfrom
fix-yamllint-trailing-spaces-generator-ebb9dc5c22330b13

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Reduces yamllint noise in generated *.lock.yml files by fixing root causes in the Go
YAML generator code.

yamllint config used:

{extends: default, rules: {line-length: disable, document-start: disable, truthy: {check-keys: false}, comments: {require-starting-space: true, min-spaces-from-content: 1}}}

Results

Metric Before After Reduction
Total warnings 616 577 39 (6.3%)

Warning breakdown

Category Before After
comments-indentation 333 333
indentation 231 231
trailing-spaces 51 12
empty-lines 1 1

Changes

  • pkg/workflow/frontmatter_extraction_yaml.go
    • commentOutProcessedFieldsInOnSection: when commenting out processed frontmatter
      fields in the on: section, blank lines inside multi-line blocks (e.g. an empty line
      within a commented-out steps: script) were emitted as # — a hash followed by a
      trailing space. The commented line is now strings.TrimRight-trimmed, so blank lines
      become a bare #. This accounts for the entire reduction (issue-monster alone dropped
      from 41 trailing-spaces to 2).
    • indentYAMLLines: whitespace-only lines were re-emitted verbatim, carrying the
      surrounding indentation as trailing whitespace. They now emit a bare newline. (Defensive;
      no committed lock file relied on the old behavior.)
  • pkg/workflow/frontmatter_extraction_yaml_test.go: updated TestIndentYAMLLines to
    assert the new blank-line normalization.

The remaining 12 trailing-spaces warnings are trailing whitespace inside user-authored
content (jq scripts, agent prompt text) carried through literal block scalars — trimming
those in the generator would alter user content, so they are intentionally left alone.

The larger comments-indentation and indentation categories stem from goccy/go-yaml
not indenting sequences (yamllint's indent-sequences: true default) in the on: block.
Fixing those requires a broad marshaling change that reformats every sequence in every lock
file, so it is deliberately out of scope for this surgical PR.

Notes

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • models.dev

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "models.dev"

See Network Configuration for more information.

Generated by 🧹 Daily yamllint Fixer · 240.8 AIC · ⌖ 9.02 AIC · ⊞ 6.7K ·

  • expires on Jul 12, 2026, 7:29 AM UTC-08:00

Generated by 👨‍🍳 PR Sous Chef · 3.83 AIC · ⌖ 6.47 AIC · ⊞ 3.7K ·
Comment /souschef to run again

Reduces yamllint trailing-spaces noise in generated *.lock.yml files by
fixing two root causes in the Go generator:

- commentOutProcessedFieldsInOnSection emitted "# " (hash + space) when
  commenting out blank lines inside multi-line blocks (e.g. an empty line
  in a commented-out steps script). TrimRight the commented line.
- indentYAMLLines re-emitted whitespace-only lines verbatim, carrying the
  surrounding indentation as trailing whitespace. Emit a bare newline.

trailing-spaces warnings drop from 51 to 12 (remaining are content inside
user-authored jq/prompt blocks, not machine-generated).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pelikhan pelikhan marked this pull request as ready for review July 5, 2026 15:41
Copilot AI review requested due to automatic review settings July 5, 2026 15:41
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

PR Code Quality Reviewer completed the code quality review.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Design Decision Gate 🏗️ completed the design decision gate check.

No ADR enforcement needed: PR #43580 does not have the 'implementation' label and has only 10 new lines of code in business logic directories (threshold: 100).

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Test Quality Sentinel completed test quality analysis.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reduces yamllint trailing-whitespace warnings in generated *.lock.yml workflow files by normalizing how the YAML generator emits blank / whitespace-only lines during indentation and when commenting out processed on: fields.

Changes:

  • Normalize whitespace-only lines in indentYAMLLines to emit a bare newline (avoids indentation becoming trailing whitespace).
  • Trim trailing spaces/tabs when constructing commented-out on: lines, preventing # on empty lines inside multi-line blocks.
  • Update TestIndentYAMLLines expectations to reflect the new blank-line normalization behavior.
Show a summary per file
File Description
pkg/workflow/frontmatter_extraction_yaml.go Normalizes blank/whitespace-only line emission to avoid trailing whitespace in generated YAML and commented-out on: fields.
pkg/workflow/frontmatter_extraction_yaml_test.go Adjusts unit test expectations to match the new blank-line behavior.

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: 0
  • Review effort level: Low

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes are correct, minimal, and well-tested. Both fixes cleanly address the root causes of trailing-whitespace generation:\n\n- indentYAMLLines: the else branch only fires for blank/whitespace-only lines, so non-blank content is unaffected.\n- commentOutProcessedFieldsInOnSection: strings.TrimRight safely removes trailing spaces from composed comment lines without altering content in the middle of a line.\n\nThe test update accurately reflects the new normalization behavior. No blocking issues.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · 13.2 AIC · ⌖ 5.91 AIC · ⊞ 4.9K

@github-actions github-actions Bot mentioned this pull request Jul 5, 2026
@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

🧪 Test Quality Sentinel Report

Test Quality Score: 85/100 — Excellent

Analyzed 1 test: 1 design test, 0 implementation tests, 0 violation(s).

📊 Metrics (1 test)
Metric Value
Analyzed 1 (Go: 1, JS: 0)
✅ Design 1 (100%)
⚠️ Implementation 0 (0%)
Edge/error coverage 1 (100%)
Duplicate clusters 0
Inflation No
🚨 Violations 0

Modified Test Cases:

Test File Classification Notes
TestIndentYAMLLines (blank-line subtest) pkg/workflow/frontmatter_extraction_yaml_test.go:91 Design test Validates yamllint compliance: blank lines emit bare newlines without trailing whitespace

Verdict

Passed. 0% implementation tests (threshold: 30%). No violations.

Summary: The test modification updates both the description and expected output to validate the corrected behavior—blank lines in indented YAML are now emitted without trailing whitespace, fixing yamllint's trailing-spaces rule. This is a high-value design test covering a critical edge case (blank-line normalization) in the YAML indentation logic. The change is minimal, precise, and validates the behavioral fix directly.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🧪 Test quality analysis by Test Quality Sentinel · 13.5 AIC · ⌖ 10.2 AIC · ⊞ 6.8K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Test Quality Sentinel: 85/100. 0% implementation tests (threshold: 30%). No violations. The test modification is high-value: it validates the critical behavioral fix that blank lines in indented YAML are emitted without trailing whitespace, ensuring yamllint compliance.

@github-actions

github-actions Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor Author

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd — one observation to address before merge.

📋 Key Themes & Highlights

Key Themes

  • Test gap on the higher-impact fix: commentOutProcessedFieldsInOnSection is the change responsible for the largest warning reduction (41→2 on issue-monster), but no unit test was added for its blank-line behaviour. The indentYAMLLines fix is well-covered by the updated TestIndentYAMLLines.

Positive Highlights

  • ✅ Surgical, well-scoped fix — only the two root-cause sites changed.
  • ✅ Clear PR description with before/after metrics and intentional non-fixes documented.
  • strings.TrimRight is the right idiom; does not affect non-blank commented lines.
  • indentYAMLLines test name updated to reflect the new semantics — good documentation.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 34.9 AIC · ⌖ 6.56 AIC · ⊞ 6.7K ·
Comment /matt to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · 34.9 AIC · ⌖ 6.56 AIC · ⊞ 6.7K
Comment /matt to run again

// TrimRight avoids emitting trailing whitespace when commenting out
// blank lines inside multi-line blocks (e.g. "# " on an empty script line),
// which yamllint flags as trailing-spaces.
commentedLine := strings.TrimRight(indentation+"# "+trimmed+commentReason, " \t")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The commentOutProcessedFieldsInOnSection fix drives the bulk of the improvement (41→2 on issue-monster) but there's no unit test exercising the blank-line-in-multi-line-block scenario to prevent regression.

💡 Suggested test skeleton

Add a case to an existing or new test for commentOutProcessedFieldsInOnSection that verifies blank lines inside a commented-out multi-line block don't produce trailing spaces:

// input: on-section YAML with a steps field containing a blank line mid-script
// expected: commented-out blank lines become bare "#" (no trailing space)
input := "on:\n  push:\n  steps: |\n    echo hi\n\n    echo bye\n"
// After commentOutProcessedFieldsInOnSection, blank lines should yield "#" not "# "

Without this, a future refactor of the comment-building logic could silently reintroduce trailing spaces on blank lines.

@copilot please address this.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking issues — both changes are mechanically correct.

The blank-line normalization is safe: YAML parsers treat a whitespace-only line identically to a bare blank line inside block scalars, and all callers pass structured YAML (not raw block scalar content with significant inner spacing).

**The in ** is correct: every constant ends with a non-whitespace character, so will never silently truncate comment text. The fix correctly converts the blank-line case # #.

One non-blocking observation below.

🔎 Code quality review by PR Code Quality Reviewer · 191.5 AIC · ⌖ 6.5 AIC · ⊞ 5.4K
Comment /review to run again

indent: " ",
wantOut: "first: value\n\n second: value\n \n third: value",
wantOut: "first: value\n\n second: value\n\n third: value",
},

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing test for the primary fix (commentOutProcessedFieldsInOnSection blank-line case): the PR correctly adds a blank-line normalization test for indentYAMLLines, but the higher-impact fix — which produces the 39-warning reduction — has no corresponding unit test asserting that a blank line inside a commented-out block yields bare # rather than # .

💡 Suggested addition

Add a case to TestCommentOutProcessedFieldsInOnSection (in compiler_yaml_test.go):

{
    name: "blank line inside on.steps emits bare # not # ",
    input: "on:\n  steps:\n    - name: test\n      run: |\n        echo hello\n\n        echo world\n",
    // blank line inside steps block should become "#" not "# "
    mustNotContain: []string{"# \n"},
    mustContain:    []string{"#\n"},
},

This mirrors what the PR does for TestIndentYAMLLines and protects the main regression target from regressing silently.

// TrimRight avoids emitting trailing whitespace when commenting out
// blank lines inside multi-line blocks (e.g. "# " on an empty script line),
// which yamllint flags as trailing-spaces.
commentedLine := strings.TrimRight(indentation+"# "+trimmed+commentReason, " \t")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latent regression trap: strings.TrimRight is applied to the fully-assembled indentation + "# " + trimmed + commentReason string — not just to the blank-line fragment. Today this is harmless because every commentReason constant ends with a letter. But if any future commentReason is accidentally written with a trailing space or tab, TrimRight will silently truncate it with no compile-time or test-time signal.

💡 Safer alternative

Apply the trim only when the line itself is blank (trimmed == ""), making the intent explicit and leaving commentReason untouched:

commentedLine := indentation + "# " + trimmed + commentReason
if trimmed == "" {
    commentedLine = strings.TrimRight(commentedLine, " \t")
}
result = append(result, commentedLine)

This removes the implicit coupling between the trim and the commentReason value.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, Update the branch if needed, complete the remaining work, and rerun checks.

Generated by 👨‍🍳 PR Sous Chef · 3.83 AIC · ⌖ 6.47 AIC · ⊞ 3.7K ·
Comment /souschef to run again

Copilot AI and others added 2 commits July 5, 2026 16:13
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

@copilot please run the pr-finisher skill, Update the branch if needed, complete the remaining work, and rerun checks.

...

Addressed in 3816286. The branch was already up to date with main, I added regression coverage for the blank-line commentOutProcessedFieldsInOnSection case and narrowed the trim so it only applies to blank commented lines. Local make fmt, make lint, focused pkg/workflow tests, and make recompile passed. make test-unit, make test, and make agent-report-progress still hit the existing unrelated pkg/cli failure in TestPRSousChefWorkflowAddCommentTargetContract, so CI on this new head still needs a maintainer re-trigger.

Copilot AI requested a review from gh-aw-bot July 5, 2026 16:29
@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot please run the pr-finisher skill, review the latest feedback, and rerun checks once the branch is ready.

Generated by 👨‍🍳 PR Sous Chef · 5.29 AIC · ⌖ 5.03 AIC · ⊞ 7.1K ·
Comment /souschef to run again

Copilot AI commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

@copilot please run the pr-finisher skill, review the latest feedback, and rerun checks once the branch is ready.

...

No further code changes were needed beyond 3816286. I rechecked the branch against main (still up to date), reran local validation, and got the same result as before: make fmt, make lint, and make recompile pass, while make test-unit, make test, and make agent-report-progress still hit the existing unrelated pkg/cli failure in TestPRSousChefWorkflowAddCommentTargetContract. The prior PR workflow runs on this head are action_required with no failed jobs, so CI still needs a maintainer re-trigger on the current head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reduce yamllint noise in generated *.lock.yml

3 participants