-
Notifications
You must be signed in to change notification settings - Fork 6
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
Code quality changes - Shellcheck #24
base: master
Are you sure you want to change the base?
Conversation
Shellcheck changes
@@ -1,4 +1,5 @@ | |||
#!/usr/bin/env bash | |||
# shellcheck source=/dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is something we want in examples. What does it do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It ensures that the shellcheck tool doesn't try to follow the path, since this path does not lead to a valid file in almost all cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it not lead to a valid file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I thought this was on the other example files in the root, where the source paths there reference something that probably doesn't exist. Should those files even be there since these examples are given?
The issue here is working directory related. Running shellcheck from the scripts directory without this comment won't report any issues because the file exists.
The correct way to amend this is:
# shellcheck source-path=SCRIPTDIR
Which tells shellcheck to treat the path as if it were relative from the script's directory.
@@ -1,4 +1,5 @@ | |||
#!/usr/bin/env bash | |||
# shellcheck source=/dev/null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it not lead to a valid file?
Co-authored-by: Simon Lindholm <[email protected]>
Co-authored-by: Simon Lindholm <[email protected]>
Co-authored-by: Simon Lindholm <[email protected]>
I ran the code through shellcheck which is de facto standard static analysis tool for shell scripts.
I made the changes required to pass, only ignoring a few warnings for the special use cases.
Why did I do this?
We are using shellcheck and include testdata_tools in our repos for contests so the library got flagged.
For libraries it is important to make sure errors/warnings don't disrupt the experience of the library user.