koalaman / shellcheck

ShellCheck, a static analysis tool for shell scripts
https://www.shellcheck.net
GNU General Public License v3.0
36.21k stars 1.77k forks source link

Feature: ignore a list of files without modifying them #2411

Open lamyergeier opened 2 years ago

lamyergeier commented 2 years ago

For bugs

For new checks and feature suggestions

How can I ignore a list of files? Is it posible to include that list in .shellcheckrc?

rbairwell commented 2 years ago

I would like this functionality as well - especially for integration with editors/IDEs (Visual Studio Code/VSCode is my current preference). It automatically runs shellcheck on all my shell files - which is usually what I want - but I have, in my current project, a couple of specific .sh files which I intentionally want to be "bad formatted/poor quality".

Yes, I could add # shellcheck disable=all at the start of the file(s), as per #1996's comment but it would be easier to either have a .shellcheckignore in the style of .gitignore/.dockerignore or to allow .shellcheckrc to have a list of files/directories to ignore.

(currently shellcheck 0.8.0)

TSMMark commented 1 year ago

Would love to see this

adamhibbert commented 1 year ago

me too

qneill-sifive commented 1 year ago

Ditto. Would increase adoption (easing configuration of CI in the tool/external to the collateral) in older repositories.

neatudarius commented 11 months ago

me too

artshade commented 11 months ago

Greetings!

In case of Visual Studio Code ("VSCode"; as of version 1.83.1, 2023-10-10) and Shellcheck extension, it's possible to configure the extension to ignore specific locations due to the approach the extension is implemented, i.e. exposed class constructor parameter ignorePatterns.


From the extension documentation (as of version 0.34.0, 2023-08-27):

The shellcheck.ignorePatterns works exactly the same as search.exclude, read more about glob patterns here

For example:

{
  "shellcheck.ignorePatterns": {
    "**/*.zsh": true,
    "**/*.zsh*": true,
    "**/.git/*.sh": true,
    "**/folder/**/*.sh": true
  }
}

To add additional ignore patterns atop the default patterns, you have to copy the default ignore patterns and then add yours to the end of the list (#1196).

Source


Just in case, the above JSON excerpt may be also stated in VSCode User and Workspace Settings.


Please keep it safe and stay sublime!

Best and kind regards ✨

Related

- "Shellcheck VSCode extension": '.../src/utils/filematcher.ts'#L2; - "JSHint": '.../jshint-server/src/server.ts'#L258; - "JSHint" GitHub repository; - #2849.

cavo789 commented 6 months ago

Hello

Just to mention such feature would be nice i.e. being able to start shellcheck in the console (not from within VSCode) with the possibility to exclude folders like with --exclude "folder1,folder2,folder3".

Here and there I see workarounds like using find xxxx | grep xxx | xargs xxx but these are slow and didn't return the correct exit code. Indeed if a shell script contains errors, I would like the get an exitCode different than 0 but, with find I get, I suppose, the exitCode of the last scanned file and this is perhaps 0 even when shellcheck has detected a lot of warnings before.

keszybz commented 2 months ago

I have a slightly different use case: the project generates a shell completion script by combining a static file completions/something.bash, completions/something.fish, …, and a second part dynamically generated from Python argparse config. The static script looks like a shell script, it even has the header with a license comment and she-bang, but does not define all variables. I'd like to configure shellcheck to ignore this partial script. I do not want to silence the warnings in the file, because then they'd also be silenced in the combined script.

kantum commented 18 hours ago

Hi,

I have a .env file that I want to ignore (because its not a script in the first place).

I have githooks using shellcheck.

When I encrypt my .env with sops, the comment get encrypted and shellcheck is triggered and I have no way to ignore it.

Anyone has an idea why this issue is not addressed? I cannot find any good reason not to add a .shellcheckignore or something similar.

I'm willing to contribute if someone have the time to give me direction.