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 quick fix options to disable the rule for the line, file or the project #116

Open
felipecrs opened this issue Sep 25, 2020 · 11 comments

Comments

@felipecrs
Copy link
Collaborator

felipecrs commented Sep 25, 2020

Example, from vscode-groovy-lint:

Gp2fRQPOKU

Disable for the line

Includes a statement in the previous line, such as # shellcheck disable=SC2035. Reference.

Disable for the entire file

Includes a ShellCheck directive statement before the first command in the file.

Disable for the project

Adds the ShellCheck directive statement to the .shellcheckrc file (and create the file if it does not exist).

@dseynhae
Copy link

We can't just move a directive to the first line of a file, if there is a shebang present (which has to be the first line, nay, the first characters of that file!).

In my case, even if I don't have a shebang as the first line, I have a directive to indicate the style of the script:

shellcheck shell=bash

I believe that a directive like that also has to be on the first line (and a shebang makes for not needing this directive.

Next, there are corporate directives on where to put licensing information, for a lot of the bigger companies. This accounts for the next few lines (typically a comment). These lines can also hold revision control information... (for older revision control systems)...

Let's think about a more intuitive way, and maybe a way that works for more customer scenarios?

@felipecrs
Copy link
Collaborator Author

felipecrs commented Sep 25, 2020

Right, I said exactly what koalaman said in the ShellCheck documentation:

Includes a ShellCheck directive statement before the first command in the file.

I believe we should simply find what is the first command in the file, and put the directives one line before it. :)

That should cover all the cases while remaining KISS, right?

@dseynhae
Copy link

If this is what you mean:

  put_new_directive_on second_line
else
  put_new_directive_on_second_line
end

Maybe...

What about:

skip_all_comment_lines at the start of the file();
insert_new_directive()

The latter seems to be safer and more comprehensive than the first?
And definitely KISS!

@felipecrs
Copy link
Collaborator Author

felipecrs commented Sep 25, 2020

That was not what I meant... when koalaman said "command" I believe he meant anything except "comments". Does not matter which is the number of the line, the first command can be in the final of the file for example.

Regarding:

skip_all_comment_lines at the start of the file();
insert_new_directive()

Yes, it's the same thing that I'm thinking, I believe, which is:

find_first_command_in_the_file(); // this implies skipping all the comments
insert_new_directive_one_line_above_it() 

@felipecrs
Copy link
Collaborator Author

felipecrs commented Sep 25, 2020

E.g.:

#!/bin/bash

# Copyright Felipe
# Dummy line

# Another comment

# Usage: hello-world

echo "hello-world"

would become:

#!/bin/bash

# Copyright Felipe
# Dummy line

# Another comment

# Usage: hello-world

# shellcheck disable=SC2035

echo "hello-world"

More calls would result in:

#!/bin/bash

# Copyright Felipe
# Dummy line

# Another comment

# Usage: hello-world

# shellcheck disable=SC2035
# shellcheck disable=SC2034

echo "hello-world"

(preferably)

@dcd-arnold
Copy link

I would like to have at least the line-based action. It is really a pain to add the comment.

@lonix1
Copy link

lonix1 commented Aug 30, 2023

It is really a pain to add the comment.

+1 My use case: I always forget the syntax, even though it's as simple as # shellcheck disable=SCxxxx.

So I must visit this site to find it. But I forget which repo it's in. So I must search for it... Luckily I remember "google.com", so it's not so bad. 😆

@felipecrs
Copy link
Collaborator Author

felipecrs commented Aug 30, 2023

Now you have snippets by the way: #1190

@DanKaplanSES
Copy link

DanKaplanSES commented Sep 14, 2023

I would like to have at least the line-based action. It is really a pain to add the comment.

I agree. To be honest, even if it generated a hard coded comment like # shellcheck disable=<SC####> or every error linked to https://github.com/koalaman/shellcheck/wiki/Ignore , it would save me a google.

@felipecrs Are there downsides to extracting Disable for the line as a separate issue?

@felipecrs
Copy link
Collaborator Author

No downsides, but it's probably not necessary. PRs are welcome regardless of being only for the line or not.

@DanKaplanSES
Copy link

Ah, my mistake. I assumed you wanted a PR to implement all three.

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

5 participants