Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static code analysis using ShellCheck for shell script - predefined rules

I am trying to use Shellcheck for doing static code analysis for shell scripts. I want to know the rules used to perform the analysis. Where can I get them?

Below is the sample output I got for simple helloworld program:

In C:\Users\~\Desktop\hello.sh line 1:
#!/bin/sh
         ^-- SC1017: Literal carriage return. Run script through tr -d '\r' .


In C:\Users\~\Desktop\hello.sh line 2:
# This is a comment!
                    ^-- SC1017: Literal carriage return. Run script through tr -d '\r' .
like image 766
Rajeswari Avatar asked Nov 25 '25 20:11

Rajeswari


1 Answers

Here's the list of all the rules used in ShellCheck.

I'd suggest you to use DeepSource to run analysis on Shell scripts. DeepSource detects more than 210 issues and gives you the option to Autofix them.

If you use DeepSource then you won't have to look anywhere for the information of rules as DeepSource gives you the option to see the description of each and every issue it detects and why you should fix that issue.

like image 101
camelcaseguy Avatar answered Nov 27 '25 12:11

camelcaseguy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!