Memo / Enforcing code regulation with shellcheck
01 Mar 2020
Explanation
Memo about code regulation tool for shell script “shellcheck”
Environment
Solution
1. Installation
Package installation
Cloning the vim plugin syntastic into the directory for Vim plugins
Adding the following lines in the .vimrc
We have more info on the official repository of syntastic
After that, Vim starts to display the additional console for shellcheck.
2. Tips
What code regulation is enforced?
We have rules from SC1000 to SC2236.
If we wanna take a look at what exactly these rules are, try to look at the following page.
https://github.com/koalaman/shellcheck/wiki/Checks
Command-line usage
- To ignore specific rules…
- To adopt only specific rules…
- To specify the output format(like gcc, checkstyle, json)…
- To specify the shell…(the default one is bash)
- To specify the severity level…
To ignore specific rules only once in the code
Put a directive like the following
Bad shell script codes example