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

New directive to ignore file #1996

Closed
4 tasks done
krufab opened this issue Jun 25, 2020 · 3 comments
Closed
4 tasks done

New directive to ignore file #1996

krufab opened this issue Jun 25, 2020 · 3 comments

Comments

@krufab
Copy link

krufab commented Jun 25, 2020

For bugs

  • Rule Id:
  • My shellcheck version: 0.7.0
  • The rule's wiki page does not already cover this (e.g. https://shellcheck.net/wiki/SC2086)
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit

For new checks and feature suggestions

Here's what I wanted or expected to see:

I think it would be useful to have a new directive to ignore the whole file or part of it.
Or at least a flag when running shellcheck.
I'd see useful when you want to perform the check on *.sh but excluding some files

#!/usr/bin/env bash
# shellcheck disable=SCXXXX

#This whole file won't be scanned

A workaround is:

shellcheck --external-sources --source-path=SCRIPTDIR --exclude=SC1072,SC1073 installation/scripts/*.sh

and setting a wrong disable directive:

#!/usr/bin/env bash
# shellcheck disable=SC*


#This whole file won't be scanned
@ChrisTollefson
Copy link

ChrisTollefson commented Feb 5, 2021

Good idea! I agree that this would be useful, especially for dealing with lots of pre-existing/legacy files in a project. For my part, I like the following syntax, with just shellcheck disable=*:

#!/usr/bin/env bash
# shellcheck disable=*

echo "This whole file will be ignored."

Speaking of that, maybe the ability to similarly ignore all checks for a single line?

#!/usr/bin/env bash

# shellcheck disable=* # Ignore the following line completely.
echo "Line with lots of errors."

Wishful thinking...

Related to this, perhaps the ability to ignore entire files by adding them to a .shellcheckignore file (similar in concept to .gitignore)? Though I realize that's probably more complicated to implement...

Just some ideas. But anyway, I'm really glad I found shellcheck – it has helped me to improve my scripts dramatically!

@docwhat
Copy link

docwhat commented Oct 28, 2021

Related to this, perhaps the ability to ignore entire files by adding them to a .shellcheckignore file (similar in concept to .gitignore)? Though I realize that's probably more complicated to implement...

Having a .shellcheckignore or a shellcheck flag that could be set in .shellcheckrc would be much better.

In my case, I have a project that vendors external projects that have shell scripts that trigger shellcheck.

@koalaman
Copy link
Owner

In 0.7.2 you can specify a range, e.g. # shellcheck disable=SC1000-SC9999 and in the next version you'll be able to do # shellcheck disable=all

@docwhat Since ShellCheck currently only processes explicitly listed files without trying to discover them itself, this may already be supported by whichever tool you have that runs ShellCheck (there's currently no way to run shellcheck foo.sh and have it not check foo.sh)

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

4 participants