protected virtual void AnalyzeTargets( TOptions options, IEnumerable <Skimmer <TContext> > skimmers, TContext rootContext, IEnumerable <string> targets) { var disabledSkimmers = new SortedSet <string>(); foreach (Skimmer <TContext> skimmer in skimmers) { PerLanguageOption <RuleEnabledState> ruleEnabledProperty = DefaultDriverOptions.CreateRuleSpecificOption(skimmer, DefaultDriverOptions.RuleEnabled); RuleEnabledState ruleEnabled = rootContext.Policy.GetProperty(ruleEnabledProperty); FailureLevel failureLevel = (ruleEnabled == RuleEnabledState.Default || ruleEnabled == RuleEnabledState.Disabled) ? default : (FailureLevel)Enum.Parse(typeof(FailureLevel), ruleEnabled.ToString()); if (ruleEnabled == RuleEnabledState.Disabled) { disabledSkimmers.Add(skimmer.Id); Warnings.LogRuleExplicitlyDisabled(rootContext, skimmer.Id); RuntimeErrors |= RuntimeConditions.RuleWasExplicitlyDisabled; } else if (!skimmer.DefaultConfiguration.Enabled && ruleEnabled == RuleEnabledState.Default) { // This skimmer is disabled by default, and the configuration file didn't mention it. // So disable it, but don't complain that the rule was explicitly disabled. disabledSkimmers.Add(skimmer.Id); } else if (skimmer.DefaultConfiguration.Level != failureLevel && ruleEnabled != RuleEnabledState.Default && ruleEnabled != RuleEnabledState.Disabled) { skimmer.DefaultConfiguration.Level = failureLevel; } } if (disabledSkimmers.Count == skimmers.Count()) { Errors.LogAllRulesExplicitlyDisabled(rootContext); ThrowExitApplicationException(rootContext, ExitReason.NoRulesLoaded); } if ((options.DataToInsert.ToFlags() & OptionallyEmittedData.Hashes) != 0) { // If analysis is persisted to a disk log file, we will have already // computed all file hashes and stored them to _pathToHashDataMap. _pathToHashDataMap = _pathToHashDataMap ?? HashUtilities.MultithreadedComputeTargetFileHashes(targets, options.Quiet); } foreach (string target in targets) { using (TContext context = DetermineApplicabilityAndAnalyze(options, skimmers, rootContext, target, disabledSkimmers)) { RuntimeErrors |= context.RuntimeErrors; } } }
protected virtual void AnalyzeTargets( TOptions options, IEnumerable <Skimmer <TContext> > skimmers, TContext rootContext, IEnumerable <string> targets) { HashSet <string> disabledSkimmers = new HashSet <string>(); foreach (Skimmer <TContext> skimmer in skimmers) { PerLanguageOption <RuleEnabledState> ruleEnabledProperty; ruleEnabledProperty = DefaultDriverOptions.CreateRuleSpecificOption(skimmer, DefaultDriverOptions.RuleEnabled); RuleEnabledState ruleEnabled = rootContext.Policy.GetProperty(ruleEnabledProperty); if (ruleEnabled == RuleEnabledState.Disabled) { disabledSkimmers.Add(skimmer.Id); Warnings.LogRuleExplicitlyDisabled(rootContext, skimmer.Id); RuntimeErrors |= RuntimeConditions.RuleWasExplicitlyDisabled; } } if (disabledSkimmers.Count == skimmers.Count()) { Errors.LogAllRulesExplicitlyDisabled(rootContext); ThrowExitApplicationException(rootContext, ExitReason.NoRulesLoaded); } if (options.ComputeFileHashes) { // If analysis is persisted to a disk log file, we will have already // computed all file hashes and stored them to _pathToHashDataMap. _pathToHashDataMap = _pathToHashDataMap ?? HashUtilities.MultithreadedComputeTargetFileHashes(targets); } foreach (string target in targets) { using (TContext context = DetermineApplicabilityAndAnalyze(options, skimmers, rootContext, target, disabledSkimmers)) { RuntimeErrors |= context.RuntimeErrors; } } }
protected virtual void AnalyzeTargets( TOptions options, IEnumerable <ISkimmer <TContext> > skimmers, TContext rootContext, IEnumerable <string> targets) { HashSet <string> disabledSkimmers = new HashSet <string>(); foreach (ISkimmer <TContext> skimmer in skimmers) { PerLanguageOption <RuleEnabledState> ruleEnabledProperty; ruleEnabledProperty = DefaultDriverOptions.CreateRuleSpecificOption(skimmer, DefaultDriverOptions.RuleEnabled); RuleEnabledState ruleEnabled = rootContext.Policy.GetProperty(ruleEnabledProperty); if (ruleEnabled == RuleEnabledState.Disabled) { disabledSkimmers.Add(skimmer.Id); Warnings.LogRuleExplicitlyDisabled(rootContext, skimmer.Id); RuntimeErrors |= RuntimeConditions.RuleWasExplicitlyDisabled; } } if (disabledSkimmers.Count == skimmers.Count()) { Errors.LogAllRulesExplicitlyDisabled(rootContext); ThrowExitApplicationException(rootContext, ExitReason.NoRulesLoaded); } foreach (string target in targets) { using (TContext context = DetermineApplicabilityAndAnalyze(options, skimmers, rootContext, target, disabledSkimmers)) { RuntimeErrors |= context.RuntimeErrors; } } }
protected virtual void AnalyzeTargets( TOptions options, TContext rootContext, IEnumerable <Skimmer <TContext> > skimmers) { var disabledSkimmers = new SortedSet <string>(); foreach (Skimmer <TContext> skimmer in skimmers) { PerLanguageOption <RuleEnabledState> ruleEnabledProperty = DefaultDriverOptions.CreateRuleSpecificOption(skimmer, DefaultDriverOptions.RuleEnabled); RuleEnabledState ruleEnabled = rootContext.Policy.GetProperty(ruleEnabledProperty); if (ruleEnabled == RuleEnabledState.Disabled) { disabledSkimmers.Add(skimmer.Id); Warnings.LogRuleExplicitlyDisabled(rootContext, skimmer.Id); RuntimeErrors |= RuntimeConditions.RuleWasExplicitlyDisabled; } else if (!skimmer.DefaultConfiguration.Enabled && ruleEnabled == RuleEnabledState.Default) { // This skimmer is disabled by default, and the configuration file didn't mention it. // So disable it, but don't complain that the rule was explicitly disabled. disabledSkimmers.Add(skimmer.Id); } } if (disabledSkimmers.Count == skimmers.Count()) { Errors.LogAllRulesExplicitlyDisabled(rootContext); ThrowExitApplicationException(rootContext, ExitReason.NoRulesLoaded); } MultithreadedAnalyzeTargets(options, rootContext, skimmers, disabledSkimmers); }