Improve SC2283 message and position
This commit is contained in:
parent
2e5c56b270
commit
dff8f9492a
|
@ -4236,16 +4236,22 @@ checkSecondArgIsComparison _ t =
|
||||||
case argString of
|
case argString of
|
||||||
'=':'=':'=':'=':_ -> Nothing -- Don't warn about `echo ======` and such
|
'=':'=':'=':'=':_ -> Nothing -- Don't warn about `echo ======` and such
|
||||||
'+':'=':_ ->
|
'+':'=':_ ->
|
||||||
return $ err (getId t) 2285 $
|
return $ err (headId t) 2285 $
|
||||||
"Remove spaces around += to assign (or quote '+=' if literal)."
|
"Remove spaces around += to assign (or quote '+=' if literal)."
|
||||||
'=':'=':_ ->
|
'=':'=':_ ->
|
||||||
return $ err (getId t) 2284 $
|
return $ err (getId t) 2284 $
|
||||||
"Use [ x = y ] to compare values (or quote '==' if literal)."
|
"Use [ x = y ] to compare values (or quote '==' if literal)."
|
||||||
'=':_ ->
|
'=':_ ->
|
||||||
return $ err (getId t) 2283 $
|
return $ err (headId arg) 2283 $
|
||||||
"Use [ ] to compare values, or remove spaces around = to assign (or quote '=' if literal)."
|
"Remove spaces around = to assign (or use [ ] to compare, or quote '=' if literal)."
|
||||||
_ -> Nothing
|
_ -> Nothing
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
|
where
|
||||||
|
-- We don't pinpoint exactly, but this helps cases like foo =$bar
|
||||||
|
headId t =
|
||||||
|
case t of
|
||||||
|
T_NormalWord _ (x:_) -> getId x
|
||||||
|
_ -> getId t
|
||||||
|
|
||||||
return []
|
return []
|
||||||
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
runTests = $( [| $(forAllProperties) (quickCheckWithResult (stdArgs { maxSuccess = 1 }) ) |])
|
||||||
|
|
Loading…
Reference in New Issue