private ExitCode SetupAnalysis()

in src/Analyzer.Cli/CommandLineParser.cs [281:315]


        private ExitCode SetupAnalysis(
            FileInfo configurationFile,
            DirectoryInfo directoryToAnalyze,
            ReportFormat reportFormat,
            FileInfo outputFilePath,
            bool includeNonSecurityRules,
            bool verbose,
            FileInfo customJsonRulesPath)
        {
            // Output file path must be specified if SARIF was chosen as the report format
            if (reportFormat == ReportFormat.Sarif && outputFilePath == null)
            {
                Console.Error.WriteLine("When using --report-format sarif flag, --output-file-path flag is required.");
                return ExitCode.ErrorMissingPath;
            }

            this.reportWriter = GetReportWriter(reportFormat, outputFilePath, directoryToAnalyze?.FullName);
            CreateLoggers(verbose);

            this.templateAnalyzer = TemplateAnalyzer.Create(includeNonSecurityRules, this.logger, customJsonRulesPath);

            if (!TryReadConfigurationFile(configurationFile, out var config))
            {
                return ExitCode.ErrorInvalidConfiguration;
            }

            // Success from TryReadConfigurationFile means there wasn't an error looking for the config.
            // config could still be null if no path was specified in the command and no default exists.
            if (config != null)
            {
                this.templateAnalyzer.FilterRules(config);
            }

            return ExitCode.Success;
        }