in src/Analyzer.Cli/CommandLineParser.cs [248:279]
private ExitCode AnalyzeTemplate(TemplateAndParams templateAndParameters)
{
try
{
(string template, string parameters) = TemplateDiscovery.GetTemplateAndParameterContents(templateAndParameters);
IEnumerable<IEvaluation> evaluations = this.templateAnalyzer.AnalyzeTemplate(template, templateAndParameters.Template.FullName, parameters);
this.reportWriter.WriteResults(evaluations, (FileInfoBase)templateAndParameters.Template, (FileInfoBase)templateAndParameters.ParametersFile);
return evaluations.Any(e => !e.Passed) ? ExitCode.Violation : ExitCode.Success;
}
catch (Exception exception)
{
// Keeping separate LogError calls so formatting can use the recommended templating.
// https://learn.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2254
if (templateAndParameters.ParametersFile != null)
{
logger.LogError(exception, "An exception occurred while analyzing template {TemplatePath} with parameters file {ParametersPath}",
templateAndParameters.Template.FullName, templateAndParameters.ParametersFile.FullName);
}
else
{
logger.LogError(exception, "An exception occurred while analyzing template {TemplatePath}", templateAndParameters.Template.FullName);
}
return (exception.Message == TemplateAnalyzer.BicepCompileErrorMessage)
? ExitCode.ErrorInvalidBicepTemplate
: ExitCode.ErrorAnalysis;
}
}