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:
commit
acb4607c43
@ -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
|
||||
|
||||
|
@ -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")
|
||||
|
@ -83,13 +83,14 @@ terminalFormatter Options{..} (Message level message pairs time) =
|
||||
|
||||
-- | Options controlling logging, error handling, &c.
|
||||
data Options = Options
|
||||
{ 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.
|
||||
, optionsRequestID :: Maybe String -- ^ Optional request id for tracing across systems.
|
||||
, 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).
|
||||
, optionsFormatter :: Options -> Message -> String -- ^ Log formatter to use (set automaticaly at runtime).
|
||||
, optionsProcessID :: CPid -- ^ ProcessID (set automaticaly at runtime).
|
||||
{ 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.
|
||||
, optionsRequestID :: Maybe String -- ^ Optional request id for tracing across systems.
|
||||
, 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).
|
||||
, 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
|
||||
|
@ -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 ->
|
||||
|
Loading…
Reference in New Issue
Block a user