Skip to content

refactor: fix shellcheck for templates#233

Merged
richm merged 1 commit intolinux-system-roles:mainfrom
richm:refactor-fix-shellcheck-templates
Jan 29, 2026
Merged

refactor: fix shellcheck for templates#233
richm merged 1 commit intolinux-system-roles:mainfrom
richm:refactor-fix-shellcheck-templates

Conversation

@richm
Copy link
Contributor

@richm richm commented Jan 29, 2026

Signed-off-by: Rich Megginson rmeggins@redhat.com

Summary by Sourcery

Enhancements:

  • Add shellcheck disable/enable annotations around ansible templating headers in nbde_client-related shell script templates to prevent spurious lint errors.

@sourcery-ai
Copy link

sourcery-ai bot commented Jan 29, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR updates three shell script templates to properly handle shellcheck by disabling it around the Jinja-templated header comments, reducing false positives while preserving linting for the rest of the script content.

File-Level Changes

Change Details Files
Wrap Jinja-templated headers in shellcheck disable/enable directives in all shell templates.
  • Add explanatory comments that these files are templates rather than literal shell scripts.
  • Insert # shellcheck disable=all immediately after the shebang to suppress false positives on templated content.
  • Place # shellcheck enable=all after the Jinja comment header so subsequent script content remains linted.
templates/module-setup.sh.j2
templates/nbde_client-hook.sh.j2
templates/nbde_client-network-flush.j2

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • Consider using a more targeted # shellcheck disable=… list for the specific template-related warnings rather than disable=all, so that shellcheck can still catch real issues in the header section of these scripts.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Consider using a more targeted `# shellcheck disable=…` list for the specific template-related warnings rather than `disable=all`, so that shellcheck can still catch real issues in the header section of these scripts.

## Individual Comments

### Comment 1
<location> `templates/module-setup.sh.j2:2-3` </location>
<code_context>
 #!/bin/sh
+# This is a template, not an actual shell script, so tell shellcheck to
+# ignore the problematic templated parts
+# shellcheck disable=all
 {{ ansible_managed | comment }}
 {{ "system_role:nbde_client" | comment(prefix="", postfix="") }}
</code_context>

<issue_to_address>
**suggestion:** Clarify wording so the generated script is not described as “not an actual shell script”.

Since this header will appear in an actual executable script, calling it “not an actual shell script” is misleading for anyone reading the generated file. Please reword to something like: “This file is generated from a template; shellcheck is disabled for the templated lines below,” or similar, so the comment is accurate in both the template and the rendered script.

```suggestion
# This file is generated from a template; disable shellcheck for the templated
# lines below so the template directives do not trigger shellcheck warnings
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +2 to +3
# This is a template, not an actual shell script, so tell shellcheck to
# ignore the problematic templated parts
Copy link

Choose a reason for hiding this comment

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

suggestion: Clarify wording so the generated script is not described as “not an actual shell script”.

Since this header will appear in an actual executable script, calling it “not an actual shell script” is misleading for anyone reading the generated file. Please reword to something like: “This file is generated from a template; shellcheck is disabled for the templated lines below,” or similar, so the comment is accurate in both the template and the rendered script.

Suggested change
# This is a template, not an actual shell script, so tell shellcheck to
# ignore the problematic templated parts
# This file is generated from a template; disable shellcheck for the templated
# lines below so the template directives do not trigger shellcheck warnings

Signed-off-by: Rich Megginson <rmeggins@redhat.com>
@richm richm force-pushed the refactor-fix-shellcheck-templates branch from 600661c to be79ad3 Compare January 29, 2026 01:47
@richm richm merged commit f4239e7 into linux-system-roles:main Jan 29, 2026
30 checks passed
@richm richm deleted the refactor-fix-shellcheck-templates branch January 29, 2026 02:21
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.

1 participant