public override void Record()

in src/Analyzer.PowerShellRuleEngine/PSRuleHostContext.cs [84:118]


        public override void Record(IResultRecord record)
        {
            var ruleRecord = (RuleRecord)record;

            var ruleId = ruleRecord.Ref;
            var ruleName = ruleRecord.RuleName;
            var ruleShortDescription = ruleRecord.Info.DisplayName;
            var ruleFullDescription = ruleRecord.Info.Description.Text;
            var recommendation = ruleRecord.Recommendation;
            var helpUri = ruleRecord?.Info?.GetOnlineHelpUrl();
            var severity = ruleRecord.Level switch
            {
                PSRule.Definitions.Rules.SeverityLevel.Error => Severity.High,
                PSRule.Definitions.Rules.SeverityLevel.Warning => Severity.Medium,
                _ => Severity.Low
            };

            foreach (var reason in ruleRecord.Detail.Reason)
            {
                SourceLocation sourceLocation;

                // Temporary try/catch because not all rule evaluations return a proper path yet:
                try
                {
                    sourceLocation = this.sourceLocationResolver.ResolveSourceLocation(reason.FullPath);
                }
                catch
                {
                    sourceLocation = new SourceLocation(templateContext.TemplateIdentifier, 1);
                }
               
                this.Evaluations.Add(new PowerShellRuleEvaluation(ruleId, ruleName, helpUri, ruleShortDescription, ruleFullDescription, recommendation,
                    templateContext.TemplateIdentifier, false, severity, new Result(false, sourceLocation))); 
            }
        }