Don't warn about unused variables starting with _ (fixes #1498)
This commit is contained in:
parent
c85ce2cb06
commit
81b7ee5598
|
@ -23,6 +23,7 @@
|
||||||
- SC2048: Warning about $\* now also applies to ${array[\*]}
|
- SC2048: Warning about $\* now also applies to ${array[\*]}
|
||||||
- SC2181 now only triggers on single condition tests like `[ $? = 0 ]`.
|
- SC2181 now only triggers on single condition tests like `[ $? = 0 ]`.
|
||||||
- Quote warnings are now emitted for declaration utilities in sh
|
- Quote warnings are now emitted for declaration utilities in sh
|
||||||
|
- Leading `_` can now be used to suppress warnings about unused variables
|
||||||
|
|
||||||
|
|
||||||
## v0.7.2 - 2021-04-19
|
## v0.7.2 - 2021-04-19
|
||||||
|
|
|
@ -2310,6 +2310,7 @@ prop_checkUnused44= verifyNotTree checkUnusedAssignments "DEFINE_string \"foo$ib
|
||||||
prop_checkUnused45= verifyTree checkUnusedAssignments "readonly foo=bar"
|
prop_checkUnused45= verifyTree checkUnusedAssignments "readonly foo=bar"
|
||||||
prop_checkUnused46= verifyTree checkUnusedAssignments "readonly foo=(bar)"
|
prop_checkUnused46= verifyTree checkUnusedAssignments "readonly foo=(bar)"
|
||||||
prop_checkUnused47= verifyNotTree checkUnusedAssignments "a=1; alias hello='echo $a'"
|
prop_checkUnused47= verifyNotTree checkUnusedAssignments "a=1; alias hello='echo $a'"
|
||||||
|
prop_checkUnused48= verifyNotTree checkUnusedAssignments "_a=1"
|
||||||
checkUnusedAssignments params t = execWriter (mapM_ warnFor unused)
|
checkUnusedAssignments params t = execWriter (mapM_ warnFor unused)
|
||||||
where
|
where
|
||||||
flow = variableFlow params
|
flow = variableFlow params
|
||||||
|
@ -2326,6 +2327,7 @@ checkUnusedAssignments params t = execWriter (mapM_ warnFor unused)
|
||||||
unused = Map.assocs $ Map.difference assignments references
|
unused = Map.assocs $ Map.difference assignments references
|
||||||
|
|
||||||
warnFor (name, token) =
|
warnFor (name, token) =
|
||||||
|
unless ("_" `isPrefixOf` name) $
|
||||||
warn (getId token) 2034 $
|
warn (getId token) 2034 $
|
||||||
name ++ " appears unused. Verify use (or export if used externally)."
|
name ++ " appears unused. Verify use (or export if used externally)."
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue