diff --git a/src/ShellCheck/Analytics.hs b/src/ShellCheck/Analytics.hs index e33d873..8d10a02 100644 --- a/src/ShellCheck/Analytics.hs +++ b/src/ShellCheck/Analytics.hs @@ -409,7 +409,7 @@ prop_checkArithmeticOpCommand1 = verify checkArithmeticOpCommand "i=i + 1" prop_checkArithmeticOpCommand2 = verify checkArithmeticOpCommand "foo=bar * 2" prop_checkArithmeticOpCommand3 = verifyNot checkArithmeticOpCommand "foo + opts" checkArithmeticOpCommand _ (T_SimpleCommand id [T_Assignment {}] (firstWord:_)) = - fromMaybe (return ()) $ check <$> getGlobOrLiteralString firstWord + maybe (return ()) check $ getGlobOrLiteralString firstWord where check op = when (op `elem` ["+", "-", "*", "/"]) $ @@ -493,8 +493,8 @@ checkPipePitfalls _ (T_Pipeline id _ commands) = do for ["grep", "wc"] $ \(grep:wc:_) -> - let flagsGrep = fromMaybe [] $ map snd . getAllFlags <$> getCommand grep - flagsWc = fromMaybe [] $ map snd . getAllFlags <$> getCommand wc + let flagsGrep = maybe [] (map snd . getAllFlags) $ getCommand grep + flagsWc = maybe [] (map snd . getAllFlags) $ getCommand wc in unless (any (`elem` ["o", "only-matching", "r", "R", "recursive"]) flagsGrep || any (`elem` ["m", "chars", "w", "words", "c", "bytes", "L", "max-line-length"]) flagsWc || null flagsWc) $ style (getId grep) 2126 "Consider using grep -c instead of grep|wc -l." @@ -3140,9 +3140,9 @@ checkSubshellAsTest _ t = checkParams id first second = do - when (fromMaybe False $ (`elem` unaryTestOps) <$> getLiteralString first) $ + when (maybe False (`elem` unaryTestOps) $ getLiteralString first) $ err id 2204 "(..) is a subshell. Did you mean [ .. ], a test expression?" - when (fromMaybe False $ (`elem` binaryTestOps) <$> getLiteralString second) $ + when (maybe False (`elem` binaryTestOps) $ getLiteralString second) $ warn id 2205 "(..) is a subshell. Did you mean [ .. ], a test expression?" diff --git a/src/ShellCheck/AnalyzerLib.hs b/src/ShellCheck/AnalyzerLib.hs index 563f8ea..4dd3f9d 100644 --- a/src/ShellCheck/AnalyzerLib.hs +++ b/src/ShellCheck/AnalyzerLib.hs @@ -784,8 +784,8 @@ isCommand token str = isCommandMatch token (\cmd -> cmd == str || ('/' : str) ` -- Compare a command to a literal. Like above, but checks full path. isUnqualifiedCommand token str = isCommandMatch token (== str) -isCommandMatch token matcher = fromMaybe False $ - fmap matcher (getCommandName token) +isCommandMatch token matcher = maybe False + matcher (getCommandName token) -- Does this regex look like it was intended as a glob? -- True: *foo* diff --git a/src/ShellCheck/Checker.hs b/src/ShellCheck/Checker.hs index 2ea950d..2837d9a 100644 --- a/src/ShellCheck/Checker.hs +++ b/src/ShellCheck/Checker.hs @@ -88,9 +88,9 @@ checkScript sys spec = do asOptionalChecks = csOptionalChecks spec } where as = newAnalysisSpec root let analysisMessages = - fromMaybe [] $ + maybe [] (arComments . analyzeScript . analysisSpec) - <$> prRoot result + $ prRoot result let translator = tokenToPosition tokenPositions return . nub . sortMessages . filter shouldInclude $ (parseMessages ++ map translator analysisMessages)