Skip to content

Enable and disable directives are not symmetrical #3368

@Zamiell

Description

@Zamiell

For new checks and feature suggestions

The Issue

Hello, and thanks for the excellent tool.

I am not sure whether this is a bug or a missing feature, but I expect enable directives and disable directives to have symmetrical syntax. But they don't, as illustrated by the following code snippet:

# shellcheck enable=check-extra-masked-return
# shellcheck disable=check-set-e-suppressed

The enable directive works, but the disable directive chokes:

In ./bash/.bash_profile_remote line 7:
# shellcheck disable=check-set-e-suppressed
^-- SC1073 (error): Couldn't parse this shellcheck directive. Fix to allow more checks.
                                           ^-- SC1072 (error): Expected '=' after directive key. Fix any mentioned problems and try again.

For more information:
  https://www.shellcheck.net/wiki/SC1072 -- Expected '=' after directive key....
  https://www.shellcheck.net/wiki/SC1073 -- Couldn't parse this shellcheck di...

The current workaround is to specify the short-hand code instead of the long name, like this:

# shellcheck enable=check-extra-masked-return
# shellcheck disable=SC2310

But doing this is confusing, because when you are enabling and disabling a bunch of rules, it looks buggy to have the long names for all of the enable directives and then using the short name for all of the disable directives.

I can try to submit a PR to fix this if needed.

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