Skip to content

Add shellcheck disable directives for heredoc markdown backticks#3548

Merged
pelikhan merged 3 commits intomainfrom
copilot/add-shellcheck-directives-heredoc
Nov 9, 2025
Merged

Add shellcheck disable directives for heredoc markdown backticks#3548
pelikhan merged 3 commits intomainfrom
copilot/add-shellcheck-directives-heredoc

Conversation

Copy link
Contributor

Copilot AI commented Nov 9, 2025

Plan: Add shellcheck disable directives for markdown heredoc false positives ✅ COMPLETE

Problem

Static analysis identified 945 false positive warnings (SC2006/SC2287) from shellcheck misinterpreting markdown backticks in heredoc documentation blocks as command substitution.

Changes Made

Source modifications:

  • pkg/workflow/sh.go - Added shellcheckDisableBackticks constant and updated 1 usage
  • pkg/workflow/compiler_yaml.go - Updated 3 usages to use the constant
  • pkg/workflow/prompt_step.go - Updated 1 usage to use the constant
  • All 74 workflow .lock.yml files regenerated (no functional changes)

Refactoring:

  • Extracted literal string "# shellcheck disable=SC2006,SC2287\n" to a constant shellcheckDisableBackticks in sh.go
  • Updated all 5 locations to use the constant for better maintainability
  • Added documentation explaining why the directive is needed

Results

Before Fix:

  • 953 total actionlint findings
  • 945 SC2006/SC2287 false positives

After Fix:

  • 34 total actionlint findings (unrelated errors)
  • 0 SC2006/SC2287 warnings

Impact

99.2% reduction in shellcheck false positives (945 → 0)
✅ Build successful
✅ All unit tests pass
✅ All 74 workflows compiled successfully
✅ No functional changes to workflow execution
✅ Improved code maintainability with constant extraction

Verification

✅ Constant defined in pkg/workflow/sh.go with clear documentation
✅ All 5 locations updated to use the constant
✅ Compiled workflows still contain correct shellcheck disable directives
✅ Tests pass and workflows compile successfully

Original prompt

This section details on the original issue you should resolve

<issue_title>[task] Add shellcheck disable directives for markdown heredoc false positives</issue_title>
<issue_description>## Objective
Add shellcheck disable directives to heredoc blocks in compiled workflows to suppress 945 false positive warnings (SC2006/SC2287) caused by markdown backticks in prompt documentation.

Context

Static analysis scan identified 945 false positives from shellcheck misinterpreting markdown backticks (e.g., /tmp/gh-aw/agent/) in heredoc documentation as command substitution. These are not actual security issues but create noise in linting output.

Related to discussion #3527.

Approach

Apply the fix template from /tmp/gh-aw/cache-memory/fix-templates/actionlint-sc2006-sc2287-heredoc-backticks.md:

  1. Identify heredoc blocks in workflow compilation code that write markdown with backticks
  2. Add shellcheck disable comment above affected heredoc blocks:
    # shellcheck disable=SC2006,SC2287
    cat >> "$GH_AW_PROMPT" << PROMPT_EOF
    ...markdown content with backticks...
    PROMPT_EOF
  3. This should be done in the Go compiler code that generates the prompt writing step

Files to Modify

  • pkg/workflow/compiler.go or related workflow generation files where heredoc prompt writing is generated
  • Any other workflow compilation code that generates heredoc blocks with markdown content

Acceptance Criteria

  • Shellcheck disable directives added to heredoc generation in compiler
  • Recompile workflows with make recompile
  • Re-run gh aw compile --actionlint shows reduced findings (945 fewer warnings)
  • Verify compiled .lock.yml files contain disable directives
  • No functional changes to workflow execution

Impact

Reduces linting findings from 953 to 8 (99.2% reduction), making actionlint output more useful for identifying real issues.
Related to #3527

AI generated by Plan Command for discussion #3527</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add shellcheck disable directives for heredoc false positives Add shellcheck disable directives for heredoc markdown backticks Nov 9, 2025
Copilot AI requested a review from pelikhan November 9, 2025 19:31
@pelikhan pelikhan marked this pull request as ready for review November 9, 2025 19:33
Copilot AI review requested due to automatic review settings November 9, 2025 19:33
if len(chunks) > 0 {
// Use quoted heredoc marker to prevent shell variable expansion
// shellcheck disable directive suppresses false positives from markdown backticks
yaml.WriteString(" # shellcheck disable=SC2006,SC2287\n")
Copy link
Contributor

Choose a reason for hiding this comment

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

@copilot move literal to a constant to reuse in the other locations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Extracted the literal to constant shellcheckDisableBackticks in pkg/workflow/sh.go and updated all 5 locations to use it. Commit b478905

Copy link
Contributor

Copilot AI left a comment

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 adds shellcheck disable directives (# shellcheck disable=SC2006,SC2287) to suppress false positive warnings in generated GitHub Actions workflow YAML files. These warnings occur because shellcheck incorrectly interprets markdown backticks within heredoc content as shell command substitution syntax.

Key Changes:

  • Added explanatory comments and disable directives in three Go compiler files that generate heredoc blocks
  • Regenerated 79+ .lock.yml workflow files with the new directives

Reviewed Changes

Copilot reviewed 76 out of 76 changed files in this pull request and generated no comments.

File Description
pkg/workflow/sh.go Added shellcheck disable directive to WritePromptTextToYAML function for heredoc generation
pkg/workflow/prompt_step.go Added shellcheck disable directive to appendPromptStepWithHeredoc function
pkg/workflow/compiler_yaml.go Added shellcheck disable directives to three heredoc locations in generatePrompt function
.github/workflows/*.lock.yml (79 files) Generated workflow files with shellcheck disable directives added to all heredoc blocks containing prompts

The changes are consistent, well-documented, and properly address false positive shellcheck warnings. The comment "shellcheck disable directive suppresses false positives from markdown backticks" accurately explains the purpose of the directives.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI requested a review from pelikhan November 9, 2025 19:48
@pelikhan pelikhan merged commit 7292890 into main Nov 9, 2025
39 of 43 checks passed
@pelikhan pelikhan deleted the copilot/add-shellcheck-directives-heredoc branch November 9, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[task] Add shellcheck disable directives for markdown heredoc false positives

2 participants