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 nameExpression = (symbol ArgumentList <|> symbol ArgumentListWithParens) *> children expression
call :: Assignment call :: Assignment
call = makeTerm <$> symbol Call <*> children (Expression.MemberAccess <$> expression <*> (expressions <|> args)) call = makeTerm <$> symbol Call <*> children (Expression.MemberAccess <$> expression <*> (args <|> expressions))
where where
args = (symbol ArgumentList <|> symbol ArgumentListWithParens) *> children expressions args = (symbol ArgumentList <|> symbol ArgumentListWithParens) *> children expressions

View File

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

View File

@ -83,13 +83,14 @@ terminalFormatter Options{..} (Message level message pairs time) =
-- | Options controlling logging, error handling, &c. -- | Options controlling logging, error handling, &c.
data Options = Options data Options = Options
{ optionsEnableColour :: Bool -- ^ Whether to enable colour formatting for logging (Only works when logging to a terminal that supports ANSI colors). { optionsEnableColour :: Bool -- ^ Whether to enable colour formatting for logging (Only works when logging to a terminal that supports ANSI colors).
, optionsLevel :: Maybe Level -- ^ What level of messages to log. 'Nothing' disabled logging. , optionsLevel :: Maybe Level -- ^ What level of messages to log. 'Nothing' disabled logging.
, optionsRequestID :: Maybe String -- ^ Optional request id for tracing across systems. , optionsRequestID :: Maybe String -- ^ Optional request id for tracing across systems.
, optionsIsTerminal :: Bool -- ^ Whether a terminal is attached (set automaticaly at runtime). , optionsIsTerminal :: Bool -- ^ Whether a terminal is attached (set automaticaly at runtime).
, optionsPrintSource :: Bool -- ^ Whether to print the source reference when logging errors (set automatically at runtime). , 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). , optionsFormatter :: Options -> Message -> String -- ^ Log formatter to use (set automaticaly at runtime).
, optionsProcessID :: CPid -- ^ ProcessID (set automaticaly at runtime). , optionsProcessID :: CPid -- ^ ProcessID (set automaticaly at runtime).
, optionsFailOnWarning :: Bool
} }
defaultOptions :: Options defaultOptions :: Options
@ -101,6 +102,7 @@ defaultOptions = Options
, optionsPrintSource = False , optionsPrintSource = False
, optionsFormatter = logfmtFormatter , optionsFormatter = logfmtFormatter
, optionsProcessID = 0 , optionsProcessID = 0
, optionsFailOnWarning = False
} }
configureOptionsForHandle :: MonadIO io => Handle -> Options -> io Options 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 Assigning.Assignment as Assignment
import qualified Control.Abstract.Analysis as Analysis import qualified Control.Abstract.Analysis as Analysis
import qualified Control.Exception as Exc import qualified Control.Exception as Exc
import Control.Monad
import Control.Monad.Effect.Exception import Control.Monad.Effect.Exception
import Control.Monad.Effect.Internal as Eff hiding (run) import Control.Monad.Effect.Internal as Eff hiding (run)
import Control.Monad.Effect.Reader import Control.Monad.Effect.Reader
@ -215,6 +216,7 @@ runParser blob@Blob{..} parser = case parser of
_ -> do _ -> do
writeStat (Stat.increment "parse.assign_warnings" languageTag) writeStat (Stat.increment "parse.assign_warnings" languageTag)
logError options Warning blob err (("task", "assign") : blobFields) logError options Warning blob err (("task", "assign") : blobFields)
when (optionsFailOnWarning options) $ throwError (toException err)
writeStat (Stat.count "parse.nodes" (length term) languageTag) writeStat (Stat.count "parse.nodes" (length term) languageTag)
pure term pure term
MarkdownParser -> MarkdownParser ->