mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-09-17 00:57:10 +08:00
Allow unrecognized directives with warnings.
This commit is contained in:
@@ -869,10 +869,11 @@ readAnnotationPrefix = do
|
|||||||
prop_readAnnotation1 = isOk readAnnotation "# shellcheck disable=1234,5678\n"
|
prop_readAnnotation1 = isOk readAnnotation "# shellcheck disable=1234,5678\n"
|
||||||
prop_readAnnotation2 = isOk readAnnotation "# shellcheck disable=SC1234 disable=SC5678\n"
|
prop_readAnnotation2 = isOk readAnnotation "# shellcheck disable=SC1234 disable=SC5678\n"
|
||||||
prop_readAnnotation3 = isOk readAnnotation "# shellcheck disable=SC1234 source=/dev/null disable=SC5678\n"
|
prop_readAnnotation3 = isOk readAnnotation "# shellcheck disable=SC1234 source=/dev/null disable=SC5678\n"
|
||||||
|
prop_readAnnotation4 = isWarning readAnnotation "# shellcheck cats=dogs disable=SC1234\n"
|
||||||
readAnnotation = called "shellcheck annotation" $ do
|
readAnnotation = called "shellcheck annotation" $ do
|
||||||
try readAnnotationPrefix
|
try readAnnotationPrefix
|
||||||
many1 linewhitespace
|
many1 linewhitespace
|
||||||
values <- many1 (readDisable <|> readSourceOverride <|> readShellOverride)
|
values <- many1 (readDisable <|> readSourceOverride <|> readShellOverride <|> anyKey)
|
||||||
linefeed
|
linefeed
|
||||||
many linewhitespace
|
many linewhitespace
|
||||||
return $ concat values
|
return $ concat values
|
||||||
@@ -904,6 +905,13 @@ readAnnotation = called "shellcheck annotation" $ do
|
|||||||
many linewhitespace
|
many linewhitespace
|
||||||
return value
|
return value
|
||||||
|
|
||||||
|
anyKey = do
|
||||||
|
pos <- getPosition
|
||||||
|
anyChar `reluctantlyTill1` whitespace
|
||||||
|
many linewhitespace
|
||||||
|
parseNoteAt pos WarningC 1107 "This directive is unknown. It will be ignored."
|
||||||
|
return []
|
||||||
|
|
||||||
readAnnotations = do
|
readAnnotations = do
|
||||||
annotations <- many (readAnnotation `thenSkip` allspacing)
|
annotations <- many (readAnnotation `thenSkip` allspacing)
|
||||||
return $ concat annotations
|
return $ concat annotations
|
||||||
|
Reference in New Issue
Block a user