Skip to content

Bug: --include silently fails for optional checks without --enable #3079

@BebeSparkelSparkel

Description

@BebeSparkelSparkel

When using --include=SC2250 (or other optional checks), ShellCheck silently produces no output instead of warning the user that the check needs to be enabled first with --enable.
This creates a confusing user experience where the --include flag appears to not work, when in reality it requires an undocumented additional flag to function.
This is particularly problematic when users are trying to enforce specific coding standards, as they may incorrectly assume their checks are being applied when they are actually being silently ignored.

  • The rule's wiki page does not already cover this
  • I have cloned the repo and installed with cabal and this is still a problem.

Here's a snippet or screenshot that shows the problem:

#!/bin/bash
set -- "-$ASCII_CONVERSION" "$@"

Here's what shellcheck currently says with just --include:

$ shellcheck --include=SC2250 test.sh
# No output

Here's what shellcheck says with both flags:

$ shellcheck --enable=all --include=SC2250 test.sh
In test.sh line 2:
    set -- "-$ASCII_CONVERSION" "$@"
             ^---------------^ SC2250 (style): Prefer putting braces around variable references even when not strictly required.

Here's what I wanted or expected to see:

The --include flag should either:

  1. Work independently for all check codes, including optional ones, OR
  2. Provide a clear error message when trying to include an optional check without enabling it

The current behavior is confusing because:

  • The manual doesn't clearly state that --include won't work for optional checks without --enable
  • There's no warning or error when trying to include an optional check without enabling it
  • Using --include alone silently fails instead of indicating that the check needs to be enabled first

This makes debugging and configuring ShellCheck more difficult than necessary, especially for users who are trying to enforce specific coding standards.

Additional Context:

The manual does document both flags separately but doesn't explicitly state their interdependency:

  • --include is described as explicitly including specified codes
  • --enable is described as enabling optional checks
  • There's no mention that --include won't work for optional checks without --enable

A user would reasonably expect that --include=SC2250 would either:

  • Include and enable the check
  • Or produce an error message explaining why no warnings are generated

Instead, it silently produces no output, leading to confusion about whether the check is working at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions