From c860b74505bdc38850384bd56bf2fdb7021a33ac Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 13 Apr 2019 13:40:18 -0700 Subject: [PATCH] Set SC2243/SC2244 level to "verbose" --- CHANGELOG.md | 2 +- src/ShellCheck/Analytics.hs | 4 ++-- src/ShellCheck/AnalyzerLib.hs | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 00faafc..71db82c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ - SC2247: Warn about $"(cmd)" and $"{var}" - SC2246: Warn if a shebang's interpreter ends with / - SC2245: Warn that Ksh ignores all but the first glob result in `[` -- SC2243/SC2244: Suggest using explicit -n for `[ $foo ]` +- SC2243/SC2244: Suggest using explicit -n for `[ $foo ]` (verbose) ### Changed - If a directive or shebang is not specified, a `.bash/.bats/.dash/.ksh` diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index 00842c1..bd7146a 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -3159,11 +3159,11 @@ checkNullaryExpansionTest params t = TC_Nullary _ _ word -> case getWordParts word of [t] | isCommandSubstitution t -> - styleWithFix id 2243 "Prefer explicit -n to check for output (or run command without [/[[ to check for success)." fix + verboseWithFix id 2243 "Prefer explicit -n to check for output (or run command without [/[[ to check for success)." fix -- If they're constant, you get SC2157 &co x | all (not . isConstant) x -> - styleWithFix id 2244 "Prefer explicit -n to check non-empty string (or use =/-ne to check boolean/integer)." fix + verboseWithFix id 2244 "Prefer explicit -n to check non-empty string (or use =/-ne to check boolean/integer)." fix _ -> return () where id = getId word diff --git a/src/ShellCheck/AnalyzerLib.hs b/src/ShellCheck/AnalyzerLib.hs index 01c87e4..e52f4e3 100644 --- a/src/ShellCheck/AnalyzerLib.hs +++ b/src/ShellCheck/AnalyzerLib.hs @@ -159,6 +159,8 @@ warnWithFix :: MonadWriter [TokenComment] m => Id -> Code -> String -> Fix -> m warnWithFix = addCommentWithFix WarningC styleWithFix :: MonadWriter [TokenComment] m => Id -> Code -> String -> Fix -> m () styleWithFix = addCommentWithFix StyleC +verboseWithFix :: MonadWriter [TokenComment] m => Id -> Code -> String -> Fix -> m () +verboseWithFix = addCommentWithFix VerboseC addCommentWithFix :: MonadWriter [TokenComment] m => Severity -> Id -> Code -> String -> Fix -> m () addCommentWithFix severity id code str fix =