{-# LANGUAGE TemplateHaskell #-}
module ShellCheck.Checker (checkScript, ShellCheck.Checker.runTests) where
import ShellCheck.Analyzer
import ShellCheck.ASTLib
import ShellCheck.Interface
import ShellCheck.Parser
import Data.Either
import Data.Functor
import Data.List
import Data.Maybe
import Data.Ord
import Control.Monad.Identity
import qualified Data.Map as Map
import qualified System.IO
import Prelude hiding (readFile)
import Control.Monad
import Test.QuickCheck.All
tokenToPosition :: Map Id (Position, Position) -> TokenComment -> PositionedComment
tokenToPosition Map Id (Position, Position)
startMap TokenComment
t = forall a. a -> Maybe a -> a
fromMaybe forall {a}. a
fail forall a b. (a -> b) -> a -> b
$ do
(Position, Position)
span <- forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup (TokenComment -> Id
tcId TokenComment
t) Map Id (Position, Position)
startMap
forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ PositionedComment
newPositionedComment {
pcStartPos :: Position
pcStartPos = forall a b. (a, b) -> a
fst (Position, Position)
span,
pcEndPos :: Position
pcEndPos = forall a b. (a, b) -> b
snd (Position, Position)
span,
pcComment :: Comment
pcComment = TokenComment -> Comment
tcComment TokenComment
t,
pcFix :: Maybe Fix
pcFix = TokenComment -> Maybe Fix
tcFix TokenComment
t
}
where
fail :: a
fail = forall a. HasCallStack => [Char] -> a
error [Char]
"Internal shellcheck error: id doesn't exist. Please report!"
shellFromFilename :: [Char] -> Maybe Shell
shellFromFilename [Char]
filename = forall a. [a] -> Maybe a
listToMaybe [Shell]
candidates
where
shellExtensions :: [([Char], Shell)]
shellExtensions = [([Char]
".ksh", Shell
Ksh)
,([Char]
".bash", Shell
Bash)
,([Char]
".bats", Shell
Bash)
,([Char]
".dash", Shell
Dash)]
candidates :: [Shell]
candidates =
[Shell
sh | ([Char]
ext,Shell
sh) <- [([Char], Shell)]
shellExtensions, [Char]
ext forall a. Eq a => [a] -> [a] -> Bool
`isSuffixOf` [Char]
filename]
checkScript :: Monad m => SystemInterface m -> CheckSpec -> m CheckResult
checkScript :: forall (m :: * -> *).
Monad m =>
SystemInterface m -> CheckSpec -> m CheckResult
checkScript SystemInterface m
sys CheckSpec
spec = do
[PositionedComment]
results <- [Char] -> m [PositionedComment]
checkScript (CheckSpec -> [Char]
csScript CheckSpec
spec)
forall (m :: * -> *) a. Monad m => a -> m a
return CheckResult
emptyCheckResult {
crFilename :: [Char]
crFilename = CheckSpec -> [Char]
csFilename CheckSpec
spec,
crComments :: [PositionedComment]
crComments = [PositionedComment]
results
}
where
checkScript :: [Char] -> m [PositionedComment]
checkScript [Char]
contents = do
ParseResult
result <- forall (m :: * -> *).
Monad m =>
SystemInterface m -> ParseSpec -> m ParseResult
parseScript SystemInterface m
sys ParseSpec
newParseSpec {
psFilename :: [Char]
psFilename = CheckSpec -> [Char]
csFilename CheckSpec
spec,
psScript :: [Char]
psScript = [Char]
contents,
psCheckSourced :: Bool
psCheckSourced = CheckSpec -> Bool
csCheckSourced CheckSpec
spec,
psIgnoreRC :: Bool
psIgnoreRC = CheckSpec -> Bool
csIgnoreRC CheckSpec
spec,
psShellTypeOverride :: Maybe Shell
psShellTypeOverride = CheckSpec -> Maybe Shell
csShellTypeOverride CheckSpec
spec
}
let parseMessages :: [PositionedComment]
parseMessages = ParseResult -> [PositionedComment]
prComments ParseResult
result
let tokenPositions :: Map Id (Position, Position)
tokenPositions = ParseResult -> Map Id (Position, Position)
prTokenPositions ParseResult
result
let analysisSpec :: Token -> AnalysisSpec
analysisSpec Token
root =
AnalysisSpec
as {
asScript :: Token
asScript = Token
root,
asShellType :: Maybe Shell
asShellType = CheckSpec -> Maybe Shell
csShellTypeOverride CheckSpec
spec,
asFallbackShell :: Maybe Shell
asFallbackShell = [Char] -> Maybe Shell
shellFromFilename forall a b. (a -> b) -> a -> b
$ CheckSpec -> [Char]
csFilename CheckSpec
spec,
asCheckSourced :: Bool
asCheckSourced = CheckSpec -> Bool
csCheckSourced CheckSpec
spec,
asExecutionMode :: ExecutionMode
asExecutionMode = ExecutionMode
Executed,
asTokenPositions :: Map Id (Position, Position)
asTokenPositions = Map Id (Position, Position)
tokenPositions,
asOptionalChecks :: [[Char]]
asOptionalChecks = Token -> [[Char]]
getEnableDirectives Token
root forall a. [a] -> [a] -> [a]
++ CheckSpec -> [[Char]]
csOptionalChecks CheckSpec
spec
} where as :: AnalysisSpec
as = Token -> AnalysisSpec
newAnalysisSpec Token
root
let analysisMessages :: [TokenComment]
analysisMessages =
forall b a. b -> (a -> b) -> Maybe a -> b
maybe []
(AnalysisResult -> [TokenComment]
arComments forall b c a. (b -> c) -> (a -> b) -> a -> c
. AnalysisSpec -> AnalysisResult
analyzeScript forall b c a. (b -> c) -> (a -> b) -> a -> c
. Token -> AnalysisSpec
analysisSpec)
forall a b. (a -> b) -> a -> b
$ ParseResult -> Maybe Token
prRoot ParseResult
result
let translator :: TokenComment -> PositionedComment
translator = Map Id (Position, Position) -> TokenComment -> PositionedComment
tokenToPosition Map Id (Position, Position)
tokenPositions
forall (m :: * -> *) a. Monad m => a -> m a
return forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Eq a => [a] -> [a]
nub forall b c a. (b -> c) -> (a -> b) -> a -> c
. [PositionedComment] -> [PositionedComment]
sortMessages forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. (a -> Bool) -> [a] -> [a]
filter PositionedComment -> Bool
shouldInclude forall a b. (a -> b) -> a -> b
$
([PositionedComment]
parseMessages forall a. [a] -> [a] -> [a]
++ forall a b. (a -> b) -> [a] -> [b]
map TokenComment -> PositionedComment
translator [TokenComment]
analysisMessages)
shouldInclude :: PositionedComment -> Bool
shouldInclude PositionedComment
pc =
Severity
severity forall a. Ord a => a -> a -> Bool
<= CheckSpec -> Severity
csMinSeverity CheckSpec
spec Bool -> Bool -> Bool
&&
case CheckSpec -> Maybe [Code]
csIncludedWarnings CheckSpec
spec of
Maybe [Code]
Nothing -> Code
code forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` CheckSpec -> [Code]
csExcludedWarnings CheckSpec
spec
Just [Code]
includedWarnings -> Code
code forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Code]
includedWarnings
where
code :: Code
code = Comment -> Code
cCode (PositionedComment -> Comment
pcComment PositionedComment
pc)
severity :: Severity
severity = Comment -> Severity
cSeverity (PositionedComment -> Comment
pcComment PositionedComment
pc)
sortMessages :: [PositionedComment] -> [PositionedComment]
sortMessages = forall b a. Ord b => (a -> b) -> [a] -> [a]
sortOn PositionedComment -> ([Char], Code, Code, Severity, Code, [Char])
order
order :: PositionedComment -> ([Char], Code, Code, Severity, Code, [Char])
order PositionedComment
pc =
let pos :: Position
pos = PositionedComment -> Position
pcStartPos PositionedComment
pc
comment :: Comment
comment = PositionedComment -> Comment
pcComment PositionedComment
pc in
(Position -> [Char]
posFile Position
pos,
Position -> Code
posLine Position
pos,
Position -> Code
posColumn Position
pos,
Comment -> Severity
cSeverity Comment
comment,
Comment -> Code
cCode Comment
comment,
Comment -> [Char]
cMessage Comment
comment)
getPosition :: PositionedComment -> Position
getPosition = PositionedComment -> Position
pcStartPos
getErrors :: SystemInterface Identity -> CheckSpec -> [Code]
getErrors SystemInterface Identity
sys CheckSpec
spec =
forall a. Ord a => [a] -> [a]
sort forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a b. (a -> b) -> [a] -> [b]
map PositionedComment -> Code
getCode forall b c a. (b -> c) -> (a -> b) -> a -> c
. CheckResult -> [PositionedComment]
crComments forall a b. (a -> b) -> a -> b
$
forall a. Identity a -> a
runIdentity (forall (m :: * -> *).
Monad m =>
SystemInterface m -> CheckSpec -> m CheckResult
checkScript SystemInterface Identity
sys CheckSpec
spec)
where
getCode :: PositionedComment -> Code
getCode = Comment -> Code
cCode forall b c a. (b -> c) -> (a -> b) -> a -> c
. PositionedComment -> Comment
pcComment
check :: [Char] -> [Code]
check = [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes []
checkWithSpec :: [([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [([Char], [Char])]
includes =
SystemInterface Identity -> CheckSpec -> [Code]
getErrors ([([Char], [Char])] -> SystemInterface Identity
mockedSystemInterface [([Char], [Char])]
includes)
checkWithIncludes :: [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char], [Char])]
includes [Char]
src =
[([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [([Char], [Char])]
includes CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
src,
csExcludedWarnings :: [Code]
csExcludedWarnings = [Code
2148]
}
checkRecursive :: [([Char], [Char])] -> [Char] -> [Code]
checkRecursive [([Char], [Char])]
includes [Char]
src =
[([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [([Char], [Char])]
includes CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
src,
csExcludedWarnings :: [Code]
csExcludedWarnings = [Code
2148],
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
checkOptionIncludes :: Maybe [Code] -> [Char] -> [Code]
checkOptionIncludes Maybe [Code]
includes [Char]
src =
[([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [] CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
src,
csIncludedWarnings :: Maybe [Code]
csIncludedWarnings = Maybe [Code]
includes,
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
checkWithRc :: [Char] -> CheckSpec -> [Code]
checkWithRc [Char]
rc = SystemInterface Identity -> CheckSpec -> [Code]
getErrors
(forall {m :: * -> *}.
Monad m =>
[Char] -> SystemInterface m -> SystemInterface m
mockRcFile [Char]
rc forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> SystemInterface Identity
mockedSystemInterface [])
checkWithIncludesAndSourcePath :: [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithIncludesAndSourcePath [([Char], [Char])]
includes [Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char]
mapper = SystemInterface Identity -> CheckSpec -> [Code]
getErrors
([([Char], [Char])] -> SystemInterface Identity
mockedSystemInterface [([Char], [Char])]
includes) {
siFindSource :: [Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char]
siFindSource = [Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char]
mapper
}
checkWithRcIncludesAndSourcePath :: [Char]
-> [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithRcIncludesAndSourcePath [Char]
rc [([Char], [Char])]
includes [Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char]
mapper = SystemInterface Identity -> CheckSpec -> [Code]
getErrors
(forall {m :: * -> *}.
Monad m =>
[Char] -> SystemInterface m -> SystemInterface m
mockRcFile [Char]
rc forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> SystemInterface Identity
mockedSystemInterface [([Char], [Char])]
includes) {
siFindSource :: [Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char]
siFindSource = [Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char]
mapper
}
prop_findsParseIssue :: Bool
prop_findsParseIssue = [Char] -> [Code]
check [Char]
"echo \"$12\"" forall a. Eq a => a -> a -> Bool
== [Code
1037]
=
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [Char] -> [Code]
check [Char]
"#shellcheck disable=SC1037\necho \"$12\""
=
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [Char] -> [Code]
check [Char]
"#shellcheck disable=SC1037\n#lol\necho \"$12\""
prop_findsAnalysisIssue :: Bool
prop_findsAnalysisIssue =
[Char] -> [Code]
check [Char]
"echo $1" forall a. Eq a => a -> a -> Bool
== [Code
2086]
=
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [Char] -> [Code]
check [Char]
"#shellcheck disable=SC2086\necho $1"
=
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [Char] -> [Code]
check [Char]
"#shellcheck disable=SC2086\n#lol\necho $1"
prop_optionDisablesIssue1 :: Bool
prop_optionDisablesIssue1 =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ SystemInterface Identity -> CheckSpec -> [Code]
getErrors
([([Char], [Char])] -> SystemInterface Identity
mockedSystemInterface [])
CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"echo $1",
csExcludedWarnings :: [Code]
csExcludedWarnings = [Code
2148, Code
2086]
}
prop_optionDisablesIssue2 :: Bool
prop_optionDisablesIssue2 =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ SystemInterface Identity -> CheckSpec -> [Code]
getErrors
([([Char], [Char])] -> SystemInterface Identity
mockedSystemInterface [])
CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"echo \"$10\"",
csExcludedWarnings :: [Code]
csExcludedWarnings = [Code
2148, Code
1037]
}
prop_wontParseBadShell :: Bool
prop_wontParseBadShell =
[Code
1071] forall a. Eq a => a -> a -> Bool
== [Char] -> [Code]
check [Char]
"#!/usr/bin/python\ntrue $1\n"
prop_optionDisablesBadShebang :: Bool
prop_optionDisablesBadShebang =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ SystemInterface Identity -> CheckSpec -> [Code]
getErrors
([([Char], [Char])] -> SystemInterface Identity
mockedSystemInterface [])
CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/usr/bin/python\ntrue\n",
csShellTypeOverride :: Maybe Shell
csShellTypeOverride = forall a. a -> Maybe a
Just Shell
Sh
}
prop_annotationDisablesBadShebang :: Bool
prop_annotationDisablesBadShebang =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [Char] -> [Code]
check [Char]
"#!/usr/bin/python\n# shellcheck shell=sh\ntrue\n"
prop_canParseDevNull :: Bool
prop_canParseDevNull =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [Char] -> [Code]
check [Char]
"source /dev/null"
prop_failsWhenNotSourcing :: Bool
prop_failsWhenNotSourcing =
[Code
1091, Code
2154] forall a. Eq a => a -> a -> Bool
== [Char] -> [Code]
check [Char]
"source lol; echo \"$bar\""
prop_worksWhenSourcing :: Bool
prop_worksWhenSourcing =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"lib", [Char]
"bar=1")] [Char]
"source lib; echo \"$bar\""
prop_worksWhenSourcingWithDashDash :: Bool
prop_worksWhenSourcingWithDashDash =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"lib", [Char]
"bar=1")] [Char]
"source -- lib; echo \"$bar\""
prop_worksWhenDotting :: Bool
prop_worksWhenDotting =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"lib", [Char]
"bar=1")] [Char]
". lib; echo \"$bar\""
prop_noInfiniteSourcing :: Bool
prop_noInfiniteSourcing =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"lib", [Char]
"source lib")] [Char]
"source lib"
prop_canSourceBadSyntax :: Bool
prop_canSourceBadSyntax =
[Code
1094, Code
2086] forall a. Eq a => a -> a -> Bool
== [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"lib", [Char]
"for f; do")] [Char]
"source lib; echo $1"
prop_cantSourceDynamic :: Bool
prop_cantSourceDynamic =
[Code
1090] forall a. Eq a => a -> a -> Bool
== [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"lib", [Char]
"")] [Char]
". \"$1\""
prop_cantSourceDynamic2 :: Bool
prop_cantSourceDynamic2 =
[Code
1090] forall a. Eq a => a -> a -> Bool
== [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"lib", [Char]
"")] [Char]
"source ~/foo"
prop_canStripPrefixAndSource :: Bool
prop_canStripPrefixAndSource =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"./lib", [Char]
"")] [Char]
"source \"$MYDIR/lib\""
prop_canStripPrefixAndSource2 :: Bool
prop_canStripPrefixAndSource2 =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"./utils.sh", [Char]
"")] [Char]
"source \"$(dirname \"${BASH_SOURCE[0]}\")/utils.sh\""
prop_canSourceDynamicWhenRedirected :: Bool
prop_canSourceDynamicWhenRedirected =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"lib", [Char]
"")] [Char]
"#shellcheck source=lib\n. \"$1\""
prop_canRedirectWithSpaces :: Bool
prop_canRedirectWithSpaces =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"my file", [Char]
"")] [Char]
"#shellcheck source=\"my file\"\n. \"$1\""
prop_recursiveAnalysis :: Bool
prop_recursiveAnalysis =
[Code
2086] forall a. Eq a => a -> a -> Bool
== [([Char], [Char])] -> [Char] -> [Code]
checkRecursive [([Char]
"lib", [Char]
"echo $1")] [Char]
"source lib"
prop_recursiveParsing :: Bool
prop_recursiveParsing =
[Code
1037] forall a. Eq a => a -> a -> Bool
== [([Char], [Char])] -> [Char] -> [Code]
checkRecursive [([Char]
"lib", [Char]
"echo \"$10\"")] [Char]
"source lib"
prop_nonRecursiveAnalysis :: Bool
prop_nonRecursiveAnalysis =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"lib", [Char]
"echo $1")] [Char]
"source lib"
prop_nonRecursiveParsing :: Bool
prop_nonRecursiveParsing =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"lib", [Char]
"echo \"$10\"")] [Char]
"source lib"
prop_sourceDirectiveDoesntFollowFile :: Bool
prop_sourceDirectiveDoesntFollowFile =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes
[([Char]
"foo", [Char]
"source bar"), ([Char]
"bar", [Char]
"baz=3")]
[Char]
"#shellcheck source=foo\n. \"$1\"; echo \"$baz\""
prop_filewideAnnotationBase :: Bool
prop_filewideAnnotationBase = [Code
2086] forall a. Eq a => a -> a -> Bool
== [Char] -> [Code]
check [Char]
"#!/bin/sh\necho $1"
prop_filewideAnnotation1 :: Bool
prop_filewideAnnotation1 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$
[Char] -> [Code]
check [Char]
"#!/bin/sh\n# shellcheck disable=2086\necho $1"
prop_filewideAnnotation2 :: Bool
prop_filewideAnnotation2 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$
[Char] -> [Code]
check [Char]
"#!/bin/sh\n# shellcheck disable=2086\ntrue\necho $1"
prop_filewideAnnotation3 :: Bool
prop_filewideAnnotation3 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$
[Char] -> [Code]
check [Char]
"#!/bin/sh\n#unrelated\n# shellcheck disable=2086\ntrue\necho $1"
prop_filewideAnnotation4 :: Bool
prop_filewideAnnotation4 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$
[Char] -> [Code]
check [Char]
"#!/bin/sh\n# shellcheck disable=2086\n#unrelated\ntrue\necho $1"
prop_filewideAnnotation5 :: Bool
prop_filewideAnnotation5 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$
[Char] -> [Code]
check [Char]
"#!/bin/sh\n\n\n\n#shellcheck disable=2086\ntrue\necho $1"
prop_filewideAnnotation6 :: Bool
prop_filewideAnnotation6 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$
[Char] -> [Code]
check [Char]
"#shellcheck shell=sh\n#unrelated\n#shellcheck disable=2086\ntrue\necho $1"
prop_filewideAnnotation7 :: Bool
prop_filewideAnnotation7 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$
[Char] -> [Code]
check [Char]
"#!/bin/sh\n# shellcheck disable=2086\n#unrelated\ntrue\necho $1"
prop_filewideAnnotationBase2 :: Bool
prop_filewideAnnotationBase2 = [Code
2086, Code
2181] forall a. Eq a => a -> a -> Bool
== [Char] -> [Code]
check [Char]
"true\n[ $? == 0 ] && echo $1"
prop_filewideAnnotation8 :: Bool
prop_filewideAnnotation8 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$
[Char] -> [Code]
check [Char]
"# Disable $? warning\n#shellcheck disable=SC2181\n# Disable quoting warning\n#shellcheck disable=2086\ntrue\n[ $? == 0 ] && echo $1"
prop_sourcePartOfOriginalScript :: Bool
prop_sourcePartOfOriginalScript =
Code
3046 forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [([Char], [Char])] -> [Char] -> [Code]
checkWithIncludes [([Char]
"./saywhat.sh", [Char]
"echo foo")] [Char]
"#!/bin/sh\nsource ./saywhat.sh"
prop_spinBug1413 :: Bool
prop_spinBug1413 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [Char] -> [Code]
check [Char]
"fun() {\n# shellcheck disable=SC2188\n> /dev/null\n}\n"
prop_deducesTypeFromExtension :: Bool
prop_deducesTypeFromExtension = forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Code]
result
where
result :: [Code]
result = [([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [] CheckSpec
emptyCheckSpec {
csFilename :: [Char]
csFilename = [Char]
"file.ksh",
csScript :: [Char]
csScript = [Char]
"(( 3.14 ))"
}
prop_deducesTypeFromExtension2 :: Bool
prop_deducesTypeFromExtension2 = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2079]
where
result :: [Code]
result = [([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [] CheckSpec
emptyCheckSpec {
csFilename :: [Char]
csFilename = [Char]
"file.bash",
csScript :: [Char]
csScript = [Char]
"(( 3.14 ))"
}
prop_canDisableShebangWarning :: Bool
prop_canDisableShebangWarning = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [Code]
result
where
result :: [Code]
result = [([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [] CheckSpec
emptyCheckSpec {
csFilename :: [Char]
csFilename = [Char]
"file.sh",
csScript :: [Char]
csScript = [Char]
"#shellcheck disable=SC2148\nfoo"
}
prop_canDisableAllWarnings :: Bool
prop_canDisableAllWarnings = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2086]
where
result :: [Code]
result = [([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [] CheckSpec
emptyCheckSpec {
csFilename :: [Char]
csFilename = [Char]
"file.sh",
csScript :: [Char]
csScript = [Char]
"#!/bin/sh\necho $1\n#shellcheck disable=all\necho `echo $1`"
}
prop_canDisableParseErrors :: Bool
prop_canDisableParseErrors = forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ [Code]
result
where
result :: [Code]
result = [([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [] CheckSpec
emptyCheckSpec {
csFilename :: [Char]
csFilename = [Char]
"file.sh",
csScript :: [Char]
csScript = [Char]
"#shellcheck disable=SC1073,SC1072,SC2148\n()"
}
prop_shExtensionDoesntMatter :: Bool
prop_shExtensionDoesntMatter = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2148]
where
result :: [Code]
result = [([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [] CheckSpec
emptyCheckSpec {
csFilename :: [Char]
csFilename = [Char]
"file.sh",
csScript :: [Char]
csScript = [Char]
"echo 'hello world'"
}
prop_sourcedFileUsesOriginalShellExtension :: Bool
prop_sourcedFileUsesOriginalShellExtension = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2079]
where
result :: [Code]
result = [([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [([Char]
"file.ksh", [Char]
"(( 3.14 ))")] CheckSpec
emptyCheckSpec {
csFilename :: [Char]
csFilename = [Char]
"file.bash",
csScript :: [Char]
csScript = [Char]
"source file.ksh",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_canEnableOptionalsWithSpec :: Bool
prop_canEnableOptionalsWithSpec = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2244]
where
result :: [Code]
result = [([Char], [Char])] -> CheckSpec -> [Code]
checkWithSpec [] CheckSpec
emptyCheckSpec {
csFilename :: [Char]
csFilename = [Char]
"file.sh",
csScript :: [Char]
csScript = [Char]
"#!/bin/sh\n[ \"$1\" ]",
csOptionalChecks :: [[Char]]
csOptionalChecks = [[Char]
"avoid-nullary-conditions"]
}
prop_optionIncludes1 :: Bool
prop_optionIncludes1 =
forall (t :: * -> *) a. Foldable t => t a -> Bool
null forall a b. (a -> b) -> a -> b
$ Maybe [Code] -> [Char] -> [Code]
checkOptionIncludes (forall a. a -> Maybe a
Just [Code
2080]) [Char]
"#!/bin/sh\n var='a b'\n echo $var"
prop_optionIncludes2 :: Bool
prop_optionIncludes2 =
[Code
2086] forall a. Eq a => a -> a -> Bool
== Maybe [Code] -> [Char] -> [Code]
checkOptionIncludes (forall a. a -> Maybe a
Just [Code
2086]) [Char]
"#!/bin/sh\n var='a b'\n echo $var"
prop_optionIncludes3 :: Bool
prop_optionIncludes3 =
[Code
2086] forall a. Eq a => a -> a -> Bool
== Maybe [Code] -> [Char] -> [Code]
checkOptionIncludes forall a. Maybe a
Nothing [Char]
"#!/bin/sh\n var='a b'\n echo $var"
prop_optionIncludes4 :: Bool
prop_optionIncludes4 =
[Code
2154] forall a. Eq a => a -> a -> Bool
== Maybe [Code] -> [Char] -> [Code]
checkOptionIncludes (forall a. a -> Maybe a
Just [Code
2154]) [Char]
"#!/bin/sh\n var='a b'\n echo $var\n echo $bar"
prop_readsRcFile :: Bool
prop_readsRcFile = forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Code]
result
where
result :: [Code]
result = [Char] -> CheckSpec -> [Code]
checkWithRc [Char]
"disable=2086" CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/sh\necho $1",
csIgnoreRC :: Bool
csIgnoreRC = Bool
False
}
prop_canUseNoRC :: Bool
prop_canUseNoRC = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2086]
where
result :: [Code]
result = [Char] -> CheckSpec -> [Code]
checkWithRc [Char]
"disable=2086" CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/sh\necho $1",
csIgnoreRC :: Bool
csIgnoreRC = Bool
True
}
prop_NoRCWontLookAtFile :: Bool
prop_NoRCWontLookAtFile = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2086]
where
result :: [Code]
result = [Char] -> CheckSpec -> [Code]
checkWithRc (forall a. HasCallStack => [Char] -> a
error [Char]
"Fail") CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/sh\necho $1",
csIgnoreRC :: Bool
csIgnoreRC = Bool
True
}
prop_brokenRcGetsWarning :: Bool
prop_brokenRcGetsWarning = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
1134, Code
2086]
where
result :: [Code]
result = [Char] -> CheckSpec -> [Code]
checkWithRc [Char]
"rofl" CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/sh\necho $1",
csIgnoreRC :: Bool
csIgnoreRC = Bool
False
}
prop_canEnableOptionalsWithRc :: Bool
prop_canEnableOptionalsWithRc = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2244]
where
result :: [Code]
result = [Char] -> CheckSpec -> [Code]
checkWithRc [Char]
"enable=avoid-nullary-conditions" CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/sh\n[ \"$1\" ]"
}
prop_sourcePathRedirectsName :: Bool
prop_sourcePathRedirectsName = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2086]
where
f :: [Char] -> p -> p -> [Char] -> m [Char]
f [Char]
"dir/myscript" p
_ p
_ [Char]
"lib" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"foo/lib"
result :: [Code]
result = [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithIncludesAndSourcePath [([Char]
"foo/lib", [Char]
"echo $1")] forall {m :: * -> *} {p} {p}.
Monad m =>
[Char] -> p -> p -> [Char] -> m [Char]
f CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/bash\nsource lib",
csFilename :: [Char]
csFilename = [Char]
"dir/myscript",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_sourcePathAddsAnnotation :: Bool
prop_sourcePathAddsAnnotation = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2086]
where
f :: [Char] -> p -> [[Char]] -> [Char] -> m [Char]
f [Char]
"dir/myscript" p
_ [[Char]
"mypath"] [Char]
"lib" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"foo/lib"
result :: [Code]
result = [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithIncludesAndSourcePath [([Char]
"foo/lib", [Char]
"echo $1")] forall {m :: * -> *} {p}.
Monad m =>
[Char] -> p -> [[Char]] -> [Char] -> m [Char]
f CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/bash\n# shellcheck source-path=mypath\nsource lib",
csFilename :: [Char]
csFilename = [Char]
"dir/myscript",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_sourcePathWorksWithSpaces :: Bool
prop_sourcePathWorksWithSpaces = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2086]
where
f :: [Char] -> p -> [[Char]] -> [Char] -> m [Char]
f [Char]
"dir/myscript" p
_ [[Char]
"my path"] [Char]
"lib" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"foo/lib"
result :: [Code]
result = [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithIncludesAndSourcePath [([Char]
"foo/lib", [Char]
"echo $1")] forall {m :: * -> *} {p}.
Monad m =>
[Char] -> p -> [[Char]] -> [Char] -> m [Char]
f CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/bash\n# shellcheck source-path='my path'\nsource lib",
csFilename :: [Char]
csFilename = [Char]
"dir/myscript",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_sourcePathRedirectsDirective :: Bool
prop_sourcePathRedirectsDirective = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2086]
where
f :: [Char] -> p -> p -> [Char] -> m [Char]
f [Char]
"dir/myscript" p
_ p
_ [Char]
"lib" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"foo/lib"
f [Char]
_ p
_ p
_ [Char]
_ = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"/dev/null"
result :: [Code]
result = [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithIncludesAndSourcePath [([Char]
"foo/lib", [Char]
"echo $1")] forall {m :: * -> *} {p} {p}.
Monad m =>
[Char] -> p -> p -> [Char] -> m [Char]
f CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/bash\n# shellcheck source=lib\nsource kittens",
csFilename :: [Char]
csFilename = [Char]
"dir/myscript",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_rcCanAllowExternalSources :: Bool
prop_rcCanAllowExternalSources = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2086]
where
f :: [Char] -> Maybe Bool -> d -> [Char] -> m [Char]
f [Char]
"dir/myscript" (Just Bool
True) d
_ [Char]
"mylib" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"resolved/mylib"
f [Char]
a Maybe Bool
b d
c [Char]
d = forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> [Char]
show ([Char]
"Unexpected", [Char]
a, Maybe Bool
b, d
c, [Char]
d)
result :: [Code]
result = [Char]
-> [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithRcIncludesAndSourcePath [Char]
"external-sources=true" [([Char]
"resolved/mylib", [Char]
"echo $1")] forall {m :: * -> *} {d}.
(Monad m, Show d) =>
[Char] -> Maybe Bool -> d -> [Char] -> m [Char]
f CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/bash\nsource mylib",
csFilename :: [Char]
csFilename = [Char]
"dir/myscript",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_rcCanDenyExternalSources :: Bool
prop_rcCanDenyExternalSources = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2086]
where
f :: [Char] -> Maybe Bool -> d -> [Char] -> m [Char]
f [Char]
"dir/myscript" (Just Bool
False) d
_ [Char]
"mylib" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"resolved/mylib"
f [Char]
a Maybe Bool
b d
c [Char]
d = forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> [Char]
show ([Char]
"Unexpected", [Char]
a, Maybe Bool
b, d
c, [Char]
d)
result :: [Code]
result = [Char]
-> [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithRcIncludesAndSourcePath [Char]
"external-sources=false" [([Char]
"resolved/mylib", [Char]
"echo $1")] forall {m :: * -> *} {d}.
(Monad m, Show d) =>
[Char] -> Maybe Bool -> d -> [Char] -> m [Char]
f CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/bash\nsource mylib",
csFilename :: [Char]
csFilename = [Char]
"dir/myscript",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_rcCanLeaveExternalSourcesUnspecified :: Bool
prop_rcCanLeaveExternalSourcesUnspecified = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2086]
where
f :: [Char] -> Maybe a -> d -> [Char] -> m [Char]
f [Char]
"dir/myscript" Maybe a
Nothing d
_ [Char]
"mylib" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"resolved/mylib"
f [Char]
a Maybe a
b d
c [Char]
d = forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> [Char]
show ([Char]
"Unexpected", [Char]
a, Maybe a
b, d
c, [Char]
d)
result :: [Code]
result = [Char]
-> [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithRcIncludesAndSourcePath [Char]
"" [([Char]
"resolved/mylib", [Char]
"echo $1")] forall {m :: * -> *} {a} {d}.
(Monad m, Show a, Show d) =>
[Char] -> Maybe a -> d -> [Char] -> m [Char]
f CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/bash\nsource mylib",
csFilename :: [Char]
csFilename = [Char]
"dir/myscript",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_fileCanDisableExternalSources :: Bool
prop_fileCanDisableExternalSources = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
2006, Code
2086]
where
f :: [Char] -> Maybe Bool -> d -> [Char] -> m [Char]
f [Char]
"dir/myscript" (Just Bool
True) d
_ [Char]
"withExternal" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"withExternal"
f [Char]
"dir/myscript" (Just Bool
False) d
_ [Char]
"withoutExternal" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"withoutExternal"
f [Char]
a Maybe Bool
b d
c [Char]
d = forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> [Char]
show ([Char]
"Unexpected", [Char]
a, Maybe Bool
b, d
c, [Char]
d)
result :: [Code]
result = [Char]
-> [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithRcIncludesAndSourcePath [Char]
"external-sources=true" [([Char]
"withExternal", [Char]
"echo $1"), ([Char]
"withoutExternal", [Char]
"_=`foo`")] forall {m :: * -> *} {d}.
(Monad m, Show d) =>
[Char] -> Maybe Bool -> d -> [Char] -> m [Char]
f CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/bash\ntrue\nsource withExternal\n# shellcheck external-sources=false\nsource withoutExternal",
csFilename :: [Char]
csFilename = [Char]
"dir/myscript",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_fileCannotEnableExternalSources :: Bool
prop_fileCannotEnableExternalSources = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
1144]
where
f :: [Char] -> Maybe a -> d -> [Char] -> m [Char]
f [Char]
"dir/myscript" Maybe a
Nothing d
_ [Char]
"foo" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"foo"
f [Char]
a Maybe a
b d
c [Char]
d = forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> [Char]
show ([Char]
"Unexpected", [Char]
a, Maybe a
b, d
c, [Char]
d)
result :: [Code]
result = [Char]
-> [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithRcIncludesAndSourcePath [Char]
"" [([Char]
"foo", [Char]
"true")] forall {m :: * -> *} {a} {d}.
(Monad m, Show a, Show d) =>
[Char] -> Maybe a -> d -> [Char] -> m [Char]
f CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/bash\n# shellcheck external-sources=true\nsource foo",
csFilename :: [Char]
csFilename = [Char]
"dir/myscript",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_fileCannotEnableExternalSources2 :: Bool
prop_fileCannotEnableExternalSources2 = [Code]
result forall a. Eq a => a -> a -> Bool
== [Code
1144]
where
f :: [Char] -> Maybe Bool -> d -> [Char] -> m [Char]
f [Char]
"dir/myscript" (Just Bool
False) d
_ [Char]
"foo" = forall (m :: * -> *) a. Monad m => a -> m a
return [Char]
"foo"
f [Char]
a Maybe Bool
b d
c [Char]
d = forall a. HasCallStack => [Char] -> a
error forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> [Char]
show ([Char]
"Unexpected", [Char]
a, Maybe Bool
b, d
c, [Char]
d)
result :: [Code]
result = [Char]
-> [([Char], [Char])]
-> ([Char] -> Maybe Bool -> [[Char]] -> [Char] -> Identity [Char])
-> CheckSpec
-> [Code]
checkWithRcIncludesAndSourcePath [Char]
"external-sources=false" [([Char]
"foo", [Char]
"true")] forall {m :: * -> *} {d}.
(Monad m, Show d) =>
[Char] -> Maybe Bool -> d -> [Char] -> m [Char]
f CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/bash\n# shellcheck external-sources=true\nsource foo",
csFilename :: [Char]
csFilename = [Char]
"dir/myscript",
csCheckSourced :: Bool
csCheckSourced = Bool
True
}
prop_rcCanSuppressEarlyProblems1 :: Bool
prop_rcCanSuppressEarlyProblems1 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Code]
result
where
result :: [Code]
result = [Char] -> CheckSpec -> [Code]
checkWithRc [Char]
"disable=1071" CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"#!/bin/zsh\necho $1"
}
prop_rcCanSuppressEarlyProblems2 :: Bool
prop_rcCanSuppressEarlyProblems2 = forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Code]
result
where
result :: [Code]
result = [Char] -> CheckSpec -> [Code]
checkWithRc [Char]
"disable=1104" CheckSpec
emptyCheckSpec {
csScript :: [Char]
csScript = [Char]
"!/bin/bash\necho 'hello world'"
}
return []
runTests :: IO Bool
runTests = $Bool
[Char]
[([Char], Property)]
[([Char], Property)] -> (Property -> IO Result) -> IO Bool
forall prop. Testable prop => prop -> IO Result
forall prop. Testable prop => prop -> Property
runQuickCheckAll :: [([Char], Property)] -> (Property -> IO Result) -> IO Bool
property :: forall prop. Testable prop => prop -> Property
quickCheckResult :: forall prop. Testable prop => prop -> IO Result
prop_rcCanSuppressEarlyProblems2 :: Bool
prop_rcCanSuppressEarlyProblems1 :: Bool
prop_fileCannotEnableExternalSources2 :: Bool
prop_fileCannotEnableExternalSources :: Bool
prop_fileCanDisableExternalSources :: Bool
prop_rcCanLeaveExternalSourcesUnspecified :: Bool
prop_rcCanDenyExternalSources :: Bool
prop_rcCanAllowExternalSources :: Bool
prop_sourcePathRedirectsDirective :: Bool
prop_sourcePathWorksWithSpaces :: Bool
prop_sourcePathAddsAnnotation :: Bool
prop_sourcePathRedirectsName :: Bool
prop_canEnableOptionalsWithRc :: Bool
prop_brokenRcGetsWarning :: Bool
prop_NoRCWontLookAtFile :: Bool
prop_canUseNoRC :: Bool
prop_readsRcFile :: Bool
prop_optionIncludes4 :: Bool
prop_optionIncludes3 :: Bool
prop_optionIncludes2 :: Bool
prop_optionIncludes1 :: Bool
prop_canEnableOptionalsWithSpec :: Bool
prop_sourcedFileUsesOriginalShellExtension :: Bool
prop_shExtensionDoesntMatter :: Bool
prop_canDisableParseErrors :: Bool
prop_canDisableAllWarnings :: Bool
prop_canDisableShebangWarning :: Bool
prop_deducesTypeFromExtension2 :: Bool
prop_deducesTypeFromExtension :: Bool
prop_spinBug1413 :: Bool
prop_sourcePartOfOriginalScript :: Bool
prop_filewideAnnotation8 :: Bool
prop_filewideAnnotationBase2 :: Bool
prop_filewideAnnotation7 :: Bool
prop_filewideAnnotation6 :: Bool
prop_filewideAnnotation5 :: Bool
prop_filewideAnnotation4 :: Bool
prop_filewideAnnotation3 :: Bool
prop_filewideAnnotation2 :: Bool
prop_filewideAnnotation1 :: Bool
prop_filewideAnnotationBase :: Bool
prop_sourceDirectiveDoesntFollowFile :: Bool
prop_nonRecursiveParsing :: Bool
prop_nonRecursiveAnalysis :: Bool
prop_recursiveParsing :: Bool
prop_recursiveAnalysis :: Bool
prop_canRedirectWithSpaces :: Bool
prop_canSourceDynamicWhenRedirected :: Bool
prop_canStripPrefixAndSource2 :: Bool
prop_canStripPrefixAndSource :: Bool
prop_cantSourceDynamic2 :: Bool
prop_cantSourceDynamic :: Bool
prop_canSourceBadSyntax :: Bool
prop_noInfiniteSourcing :: Bool
prop_worksWhenDotting :: Bool
prop_worksWhenSourcingWithDashDash :: Bool
prop_worksWhenSourcing :: Bool
prop_failsWhenNotSourcing :: Bool
prop_canParseDevNull :: Bool
prop_annotationDisablesBadShebang :: Bool
prop_optionDisablesBadShebang :: Bool
prop_wontParseBadShell :: Bool
prop_optionDisablesIssue2 :: Bool
prop_optionDisablesIssue1 :: Bool
prop_commentDisablesAnalysisIssue2 :: Bool
prop_commentDisablesAnalysisIssue1 :: Bool
prop_findsAnalysisIssue :: Bool
prop_commentDisablesParseIssue2 :: Bool
prop_commentDisablesParseIssue1 :: Bool
prop_findsParseIssue :: Bool
quickCheckAll