Skip to content

Commit 5669eb2

Browse files
committed
Make x-comparison warning default
1 parent b68df18 commit 5669eb2

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- SC2264: Warn about wrapper functions that blatantly recurse
99
- SC2265/SC2266: Warn when using & or | with test statements
1010
- SC2267: Warn when using xargs -i instead of -I
11-
- Optional avoid-x-comparisons: Style warning SC2268 for `[ x$var = xval ]`
11+
- SC2268: Warn about unnecessary x-comparisons like `[ x$var = xval ]`
1212

1313
### Fixed
1414
- SC1072/SC1073 now respond to disable annotations, though ignoring parse errors

src/ShellCheck/Analytics.hs

+2-8
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ nodeChecks = [
196196
,checkAssignToSelf
197197
,checkEqualsInCommand
198198
,checkSecondArgIsComparison
199+
,checkComparisonWithLeadingX
199200
]
200201

201202
optionalChecks = map fst optionalTreeChecks
@@ -243,13 +244,6 @@ optionalTreeChecks = [
243244
cdPositive = "echo $VAR",
244245
cdNegative = "VAR=hello; echo $VAR"
245246
}, checkUnassignedReferences' True)
246-
247-
,(newCheckDescription {
248-
cdName = "avoid-x-comparisons",
249-
cdDescription = "Warn about 'x'-prefix in comparisons",
250-
cdPositive = "[ \"x$var\" = xval ]",
251-
cdNegative = "[ \"$var\" = val ]"
252-
}, nodeChecksToTreeCheck [checkComparisonWithLeadingX])
253247
]
254248

255249
optionalCheckMap :: Map.Map String (Parameters -> Token -> [TokenComment])
@@ -4006,7 +4000,7 @@ checkComparisonWithLeadingX params t =
40064000
check lhs rhs
40074001
_ -> return ()
40084002
where
4009-
msg = "Avoid outdated x-prefix in comparisons as it no longer serves a purpose."
4003+
msg = "Avoid x-prefix in comparisons as it no longer serves a purpose."
40104004
check lhs rhs = sequence_ $ do
40114005
l <- fixLeadingX lhs
40124006
r <- fixLeadingX rhs

0 commit comments

Comments
 (0)