Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
2 tasks done
BebeSparkelSparkel opened this issue Nov 10, 2024 · 0 comments
Open
2 tasks done

Comments

@BebeSparkelSparkel
Copy link

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.

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

No branches or pull requests

1 participant