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

Check for no-longer-applicable disable directives and warn when found. #1170

Open
3 of 4 tasks
matthewpersico opened this issue Apr 5, 2018 · 0 comments
Open
3 of 4 tasks

Comments

@matthewpersico
Copy link

matthewpersico commented Apr 5, 2018

For bugs

  • Rule Id (if any, e.g. SC1000): Any rule actually
  • My shellcheck version (shellcheck --version or 'online'): online
  • I tried on shellcheck.net and verified that this is still a problem on the latest commit
  • It's not reproducible on shellcheck.net, but I think that's because it's an OS, configuration or encoding issue

For new checks and feature suggestions

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

#!bash

datafile='the/foo/file'

for i in $(grep -v '#' "$datafile")
do
    echo "$i"
done

#shellcheck disable=SC2013
for i in $(grep -v '#' "$datafile")
do
    echo "$i"
done
    
#shellcheck disable=SC2013
while read -r i
do
    echo "$i"
done < "$datafile"
    

Here's what shellcheck currently says:

Line 5	SC2013: To read lines rather than words, pipe/redirect to a 'while read' loop.

Here's what I wanted or expected to see:

Line 5	SC2013: To read lines rather than words, pipe/redirect to a 'while read' loop.
Line 16	SC2013: Does not apply to next line; remove it.

Sometimes when you go back and edit files, you manage to undo the issue that shellcheck was complaining about. That means the disable directive is no longer applicable and should be removed. Can we have the parser check for disabled checks and warn us if the disable no longer applies?

@matthewpersico matthewpersico changed the title TODO: Add title Check for no-longer-applicable disable directives and warn when found. Apr 5, 2018
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