Clean up and optimize getSuspiciousRegexWildcard
This commit is contained in:
parent
ab1610b004
commit
163c710ba7
|
@ -283,17 +283,11 @@ checkGrepRe = CommandCheck (Basename "grep") check where
|
||||||
candidates =
|
candidates =
|
||||||
sampleWords ++ map (\(x:r) -> toUpper x : r) sampleWords
|
sampleWords ++ map (\(x:r) -> toUpper x : r) sampleWords
|
||||||
|
|
||||||
getSuspiciousRegexWildcard str =
|
getSuspiciousRegexWildcard str = case matchRegex suspicious str of
|
||||||
if not $ str `matches` contra
|
Just [[c]] | not (str `matches` contra) -> Just c
|
||||||
then do
|
_ -> fail "looks good"
|
||||||
match <- matchRegex suspicious str
|
suspicious = mkRegex "([A-Za-z1-9])\\*"
|
||||||
str <- match !!! 0
|
contra = mkRegex "[^a-zA-Z1-9]\\*|[][^$+\\\\]"
|
||||||
str !!! 0
|
|
||||||
else
|
|
||||||
fail "looks good"
|
|
||||||
where
|
|
||||||
suspicious = mkRegex "([A-Za-z1-9])\\*"
|
|
||||||
contra = mkRegex "[^a-zA-Z1-9]\\*|[][^$+\\\\]"
|
|
||||||
|
|
||||||
|
|
||||||
prop_checkTrapQuotes1 = verify checkTrapQuotes "trap \"echo $num\" INT"
|
prop_checkTrapQuotes1 = verify checkTrapQuotes "trap \"echo $num\" INT"
|
||||||
|
|
Loading…
Reference in New Issue