Do not suggest `grep -c` as a replacement for `grep -l/-L | wc -l`
This commit is contained in:
parent
747bd8fd6a
commit
40216487d6
|
@ -508,6 +508,8 @@ prop_checkPipePitfalls13 = verifyNot checkPipePitfalls "foo | grep bar | wc -c"
|
||||||
prop_checkPipePitfalls14 = verifyNot checkPipePitfalls "foo | grep -o bar | wc -cmwL"
|
prop_checkPipePitfalls14 = verifyNot checkPipePitfalls "foo | grep -o bar | wc -cmwL"
|
||||||
prop_checkPipePitfalls15 = verifyNot checkPipePitfalls "foo | grep bar | wc -cmwL"
|
prop_checkPipePitfalls15 = verifyNot checkPipePitfalls "foo | grep bar | wc -cmwL"
|
||||||
prop_checkPipePitfalls16 = verifyNot checkPipePitfalls "foo | grep -r bar | wc -l"
|
prop_checkPipePitfalls16 = verifyNot checkPipePitfalls "foo | grep -r bar | wc -l"
|
||||||
|
prop_checkPipePitfalls17 = verifyNot checkPipePitfalls "foo | grep -l bar | wc -l"
|
||||||
|
prop_checkPipePitfalls18 = verifyNot checkPipePitfalls "foo | grep -L bar | wc -l"
|
||||||
checkPipePitfalls _ (T_Pipeline id _ commands) = do
|
checkPipePitfalls _ (T_Pipeline id _ commands) = do
|
||||||
for ["find", "xargs"] $
|
for ["find", "xargs"] $
|
||||||
\(find:xargs:_) ->
|
\(find:xargs:_) ->
|
||||||
|
@ -529,7 +531,9 @@ checkPipePitfalls _ (T_Pipeline id _ commands) = do
|
||||||
let flagsGrep = maybe [] (map snd . getAllFlags) $ getCommand grep
|
let flagsGrep = maybe [] (map snd . getAllFlags) $ getCommand grep
|
||||||
flagsWc = maybe [] (map snd . getAllFlags) $ getCommand wc
|
flagsWc = maybe [] (map snd . getAllFlags) $ getCommand wc
|
||||||
in
|
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) $
|
unless (any (`elem` ["l", "files-with-matches", "L", "files-without-matches", "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."
|
style (getId grep) 2126 "Consider using grep -c instead of grep|wc -l."
|
||||||
|
|
||||||
didLs <- fmap or . sequence $ [
|
didLs <- fmap or . sequence $ [
|
||||||
|
|
Loading…
Reference in New Issue