1
1
mirror of https://github.com/github/semantic.git synced 2025-01-03 13:02:37 +03:00

Merge pull request #1730 from github/fail-on-warning

New flag to fail on warning so that `script/parse-examples` actually fails the build
This commit is contained in:
Timothy Clem 2018-04-09 14:05:36 -07:00 committed by GitHub
commit acb4607c43
4 changed files with 13 additions and 8 deletions

View File

@ -307,7 +307,7 @@ methodCall = makeTerm' <$> symbol MethodCall <*> children (require <|> load <|>
nameExpression = (symbol ArgumentList <|> symbol ArgumentListWithParens) *> children expression
call :: Assignment
call = makeTerm <$> symbol Call <*> children (Expression.MemberAccess <$> expression <*> (expressions <|> args))
call = makeTerm <$> symbol Call <*> children (Expression.MemberAccess <$> expression <*> (args <|> expressions))
where
args = (symbol ArgumentList <|> symbol ArgumentListWithParens) *> children expressions

View File

@ -53,6 +53,7 @@ arguments = info (version <*> helper <*> ((,) <$> optionsParser <*> argumentsPar
<*> pure False -- PrintSource
<*> pure Log.logfmtFormatter -- Formatter
<*> pure 0 -- ProcessID
<*> switch (long "fail-on-warning" <> help "Fail on assignment warnings.")
argumentsParser = (. Task.writeToOutput) . (>>=)
<$> hsubparser (diffCommand <> parseCommand)
<*> ( Right <$> strOption (long "output" <> short 'o' <> help "Output path, defaults to stdout")

View File

@ -90,6 +90,7 @@ data Options = Options
, optionsPrintSource :: Bool -- ^ Whether to print the source reference when logging errors (set automatically at runtime).
, optionsFormatter :: Options -> Message -> String -- ^ Log formatter to use (set automaticaly at runtime).
, optionsProcessID :: CPid -- ^ ProcessID (set automaticaly at runtime).
, optionsFailOnWarning :: Bool
}
defaultOptions :: Options
@ -101,6 +102,7 @@ defaultOptions = Options
, optionsPrintSource = False
, optionsFormatter = logfmtFormatter
, optionsProcessID = 0
, optionsFailOnWarning = False
}
configureOptionsForHandle :: MonadIO io => Handle -> Options -> io Options

View File

@ -51,6 +51,7 @@ import Analysis.Decorator (decoratorWithAlgebra)
import qualified Assigning.Assignment as Assignment
import qualified Control.Abstract.Analysis as Analysis
import qualified Control.Exception as Exc
import Control.Monad
import Control.Monad.Effect.Exception
import Control.Monad.Effect.Internal as Eff hiding (run)
import Control.Monad.Effect.Reader
@ -215,6 +216,7 @@ runParser blob@Blob{..} parser = case parser of
_ -> do
writeStat (Stat.increment "parse.assign_warnings" languageTag)
logError options Warning blob err (("task", "assign") : blobFields)
when (optionsFailOnWarning options) $ throwError (toException err)
writeStat (Stat.count "parse.nodes" (length term) languageTag)
pure term
MarkdownParser ->