facebook pixelCodiga Analysis Shell Rules, category code style
BACK TO LIST

Shell rules

Bash, zsh, ksh: regardless what Shell you use, Codiga got you covered. With hundreds of rules, the Codiga Static Engine checks for any issue in your shell script and surfaces issues in your Shell codebase.

1008

Code style
Informational

This shebang was unrecognized. Note that ShellCheck only handles sh/bash/dash/ksh.

1068

Code style
Informational

Don't put spaces around the = in assignments (or quote to make it literal).

1083

Code style
Informational

This } is literal. Check expression (missing ;/\\n?) or quote it.

1087

Code style
Informational

Use braces when expanding arrays

1090

Code style
Informational

Can't follow non-constant source. Use a directive to specify location.

1097

Code style
Informational

Unexpected ==. For assignment

1114

Code style
Informational

Remove leading spaces before the shebang.

1117

Code style
Informational

Backslash is literal in \\’". Prefer explicit escaping: "\\\\’"."

2001

Code style
Informational

See if you can use ${variable//search/replace} instead.

2002

Code style
Informational

Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead.

2004

Code style
Informational

$/${} is unnecessary on arithmetic variables.

2005

Code style
Informational

Useless echo? Instead of 'echo $(cmd)'

2007

Code style
Informational

Use $((..)) instead of deprecated $[..]

2012

Code style
Informational

Use find instead of ls to better handle non-alphanumeric filenames.

2013

Code style
Informational

To read lines rather than words

2016

Code style
Informational

Expressions don't expand in single quotes

2034

Code style
Informational

START\_OF\_ROOT\_PARTITION appears unused. Verify use (or export if used externally).

2035

Code style
Informational

Use ./*glob* or -- *glob* so names with dashes won't become options.

2038

Code style
Informational

Use -print0/-0 or -exec + to allow for non-alphanumeric filenames.

2039

Code style
Informational

Undefined keyword for POSIX sh

2043

Code style
Informational

This loop will only ever run once for a constant value. Did you perhaps mean to loop over dir/*

2044

Code style
Informational

For loops over find output are fragile. Use find -exec or a while read loop.

2045

Code style
Informational

Iterating over ls output is fragile. Use globs.

2048

Code style
Informational

Use $@" (with quotes) to prevent whitespace problems."

2053

Code style
Informational

Quote the right-hand side of != in [[ ]] to prevent glob matching.

2059

Code style
Informational

Don't use variables in the printf format string. Use printf ..\%s.." "$foo"."

2061

Code style
Informational

Quote the parameter to -iname so the shell won't interpret it.

2064

Code style
Informational

Use single quotes

2068

Code style
Informational

Double quote array expansions to avoid re-splitting elements.

2071

Code style
Informational

> is for string comparisons. Use -gt instead.

2089

Code style
Informational

Quotes/backslashes will be treated literally. Use an array.

2090

Code style
Informational

Quotes/backslashes in this variable will not be respected.

2091

Code style
Informational

Remove surrounding $() to avoid executing output.

2094

Code style
Informational

Make sure not to read and write the same file in the same pipeline.

2103

Code style
Informational

Use a ( subshell ) to avoid having to cd back.

2112

Code style
Informational

function' keyword is non-standard. Delete it.

2116

Code style
Informational

Useless echo? Instead of 'cmd $(echo foo)'

2119

Code style
Informational

Use start\_mysql $@" if function's $1 should mean script's $1."

2120

Code style
Informational

A function references arguments but no argument is passed

2121

Code style
Informational

To assign a variable, do not use set

2128

Code style
Informational

Expanding an array without an index only gives the first element.

2129

Code style
Informational

Consider using { cmd1; cmd2; } >> file instead of individual redirects.

2140

Code style
Informational

Word is of the form A"B"C" (B indicated). Did you mean "ABC" or "A\\"B\\"C"?"

2145

Code style
Informational

Argument mixes string and array. Use * or separate argument.

2148

Code style
Informational

Tips depend on target shell and yours is unknown. Add a shebang.

2153

Code style
Informational

Possible misspelling: FGREP may not be assigned

2154

Code style
Informational

xtra is referenced but not assigned.

2155

Code style
Informational

Declare and assign separately to avoid masking return values.

2162

Code style
Informational

read without -r will mangle backslashes.

2163

Code style
Informational

This does not export 'atom\_env\_pair'. Remove $/${} for that

2164

Code style
Informational

Use 'cd ... || exit' or 'cd ... || return' in case cd fails.

2181

Code style
Informational

Check exit code directly with e.g. 'if mycmd;'

2185

Code style
Informational

Some finds don't have a default path. Specify '.' explicitly.

2186

Code style
Informational

tempfile is deprecated. Use mktemp instead.

2191

Code style
Informational

The = here is literal. To assign by index

2198

Code style
Informational

Arrays don't work as operands in [ ]. Use a loop (or concatenate with * instead of @).

2206

Code style
Informational

Quote to prevent word splitting/globbing

2207

Code style
Informational

Prefer mapfile or read -a to split command output (or quote to avoid splitting).

2209

Code style
Informational

Use var=$(command) to assign output (or quote to assign string).

2219

Code style
Informational

Instead of 'let expr'

2223

Code style
Informational

This default assignment may cause DoS due to globbing. Quote it.

2230

Code style
Informational

which is a non-standard tool. Use builtin 'command -v' instead.

2231

Code style
Informational

Quote expansions in this for loop glob to prevent wordsplitting

1133

Code style
Warning

Unexpected start of line. If breaking lines, |/||/&& should be at the end of the previous one.

Learn more

1039

Code style
Informational

Remove indentation before end token

1108

Code style
Error

You need a space before and after the =

1130

Code style
Warning

Need a space before :