Make x-comparison warning default
This commit is contained in:
parent
b68df1882d
commit
5669eb2203
|
@ -8,7 +8,7 @@
|
||||||
- SC2264: Warn about wrapper functions that blatantly recurse
|
- SC2264: Warn about wrapper functions that blatantly recurse
|
||||||
- SC2265/SC2266: Warn when using & or | with test statements
|
- SC2265/SC2266: Warn when using & or | with test statements
|
||||||
- SC2267: Warn when using xargs -i instead of -I
|
- SC2267: Warn when using xargs -i instead of -I
|
||||||
- Optional avoid-x-comparisons: Style warning SC2268 for `[ x$var = xval ]`
|
- SC2268: Warn about unnecessary x-comparisons like `[ x$var = xval ]`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- SC1072/SC1073 now respond to disable annotations, though ignoring parse errors
|
- SC1072/SC1073 now respond to disable annotations, though ignoring parse errors
|
||||||
|
|
|
@ -196,6 +196,7 @@ nodeChecks = [
|
||||||
,checkAssignToSelf
|
,checkAssignToSelf
|
||||||
,checkEqualsInCommand
|
,checkEqualsInCommand
|
||||||
,checkSecondArgIsComparison
|
,checkSecondArgIsComparison
|
||||||
|
,checkComparisonWithLeadingX
|
||||||
]
|
]
|
||||||
|
|
||||||
optionalChecks = map fst optionalTreeChecks
|
optionalChecks = map fst optionalTreeChecks
|
||||||
|
@ -243,13 +244,6 @@ optionalTreeChecks = [
|
||||||
cdPositive = "echo $VAR",
|
cdPositive = "echo $VAR",
|
||||||
cdNegative = "VAR=hello; echo $VAR"
|
cdNegative = "VAR=hello; echo $VAR"
|
||||||
}, checkUnassignedReferences' True)
|
}, checkUnassignedReferences' True)
|
||||||
|
|
||||||
,(newCheckDescription {
|
|
||||||
cdName = "avoid-x-comparisons",
|
|
||||||
cdDescription = "Warn about 'x'-prefix in comparisons",
|
|
||||||
cdPositive = "[ \"x$var\" = xval ]",
|
|
||||||
cdNegative = "[ \"$var\" = val ]"
|
|
||||||
}, nodeChecksToTreeCheck [checkComparisonWithLeadingX])
|
|
||||||
]
|
]
|
||||||
|
|
||||||
optionalCheckMap :: Map.Map String (Parameters -> Token -> [TokenComment])
|
optionalCheckMap :: Map.Map String (Parameters -> Token -> [TokenComment])
|
||||||
|
@ -4006,7 +4000,7 @@ checkComparisonWithLeadingX params t =
|
||||||
check lhs rhs
|
check lhs rhs
|
||||||
_ -> return ()
|
_ -> return ()
|
||||||
where
|
where
|
||||||
msg = "Avoid outdated x-prefix in comparisons as it no longer serves a purpose."
|
msg = "Avoid x-prefix in comparisons as it no longer serves a purpose."
|
||||||
check lhs rhs = sequence_ $ do
|
check lhs rhs = sequence_ $ do
|
||||||
l <- fixLeadingX lhs
|
l <- fixLeadingX lhs
|
||||||
r <- fixLeadingX rhs
|
r <- fixLeadingX rhs
|
||||||
|
|
Loading…
Reference in New Issue