test-negated-empty
What it does
Section titled “What it does”Reports a test that negates -z or -n, as in [ ! -z "$x" ].
Why it matters
Section titled “Why it matters”-n is the opposite of -z, so the negation can be dropped, and a double negative is hard to read.
To fix, write [ -n "$x" ].
Example
Section titled “Example”...[ -a file ][[ -f a && -f b ]][ ! -z "$x" ][ ! -n "$x" ][ -z "$x" ]...Configuration
Section titled “Configuration”shell: lint: rules: test-negated-empty: warn # off (default), warn, errorEnabled by the presets: shell/shellcheck.
Suppress one line with sudsy-disable-next-line test-negated-empty in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| shellcheck | SC2236 |
full |