From 88c56ecd5312a61ab6af827bea91580a58e96c39 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Fri, 14 Oct 2016 12:14:20 -0700 Subject: [PATCH] Allow unrecognized directives with warnings. --- ShellCheck/Parser.hs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ShellCheck/Parser.hs b/ShellCheck/Parser.hs index 889ab50..05f8356 100644 --- a/ShellCheck/Parser.hs +++ b/ShellCheck/Parser.hs @@ -869,10 +869,11 @@ readAnnotationPrefix = do prop_readAnnotation1 = isOk readAnnotation "# shellcheck disable=1234,5678\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_readAnnotation4 = isWarning readAnnotation "# shellcheck cats=dogs disable=SC1234\n" readAnnotation = called "shellcheck annotation" $ do try readAnnotationPrefix many1 linewhitespace - values <- many1 (readDisable <|> readSourceOverride <|> readShellOverride) + values <- many1 (readDisable <|> readSourceOverride <|> readShellOverride <|> anyKey) linefeed many linewhitespace return $ concat values @@ -904,6 +905,13 @@ readAnnotation = called "shellcheck annotation" $ do many linewhitespace 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 annotations <- many (readAnnotation `thenSkip` allspacing) return $ concat annotations