mirror of
https://github.com/koalaman/shellcheck
synced 2025-07-10 23:32:57 -07:00
Merge pull request #1918 from josephcsible/getsuspiciousregexwildcard
Clean up and optimize getSuspiciousRegexWildcard
This commit is contained in:
commit
75863a887e
1 changed files with 5 additions and 11 deletions
|
@ -283,15 +283,9 @@ 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
|
|
||||||
str <- match !!! 0
|
|
||||||
str !!! 0
|
|
||||||
else
|
|
||||||
fail "looks good"
|
|
||||||
where
|
|
||||||
suspicious = mkRegex "([A-Za-z1-9])\\*"
|
suspicious = mkRegex "([A-Za-z1-9])\\*"
|
||||||
contra = mkRegex "[^a-zA-Z1-9]\\*|[][^$+\\\\]"
|
contra = mkRegex "[^a-zA-Z1-9]\\*|[][^$+\\\\]"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue