public virtual void HydrateResults(IList <Result> results, DiagnosticRecord diagnosticRecord) { if (results is null) { throw new ArgumentNullException(nameof(results)); } if (diagnosticRecord is null) { throw new ArgumentNullException(nameof(diagnosticRecord)); } var failureLevel = ResolveSeverity(diagnosticRecord?.Severity); var result = new Result() { Level = failureLevel, Message = new Message() { Text = diagnosticRecord.Message }, Locations = new List <Location>() { new Location() { PhysicalLocation = new PhysicalLocation() { ArtifactLocation = new ArtifactLocation() { Uri = new Uri(diagnosticRecord.ScriptPath) }, Region = new Region() { StartLine = diagnosticRecord.Line, EndColumn = 0 } } } }, RuleId = diagnosticRecord.RuleName, Suppressions = new List <Suppression>() }; if (diagnosticRecord.Suppressions != null) { foreach (Suppression suppression in diagnosticRecord.Suppressions) { result.Suppressions.Add ( new Suppression() { Kind = suppression.Kind, Justification = suppression.Justification } ); } } results.Add(result); }
public virtual void HydrateRules(HashSet <ReportingDescriptor> rules, DiagnosticRecord diagnosticRecord) { if (rules is null) { throw new ArgumentNullException(nameof(rules)); } if (diagnosticRecord is null) { throw new ArgumentNullException(nameof(diagnosticRecord)); } var rule = new ReportingDescriptor() { Id = diagnosticRecord?.RuleName, Name = diagnosticRecord?.RuleName, HelpUri = new Uri("https://github.com/PowerShell/Psscriptanalyzer") }; rules?.Add(rule); }
public virtual void HydrateArtifacts(HashSet <Artifact> artifacts, DiagnosticRecord diagnosticRecord) { if (artifacts is null) { throw new ArgumentNullException(nameof(artifacts)); } if (diagnosticRecord is null) { throw new ArgumentNullException(nameof(diagnosticRecord)); } var artifact = new Artifact() { Location = new ArtifactLocation() { Uri = new Uri(diagnosticRecord?.ScriptPath) } }; artifacts?.Add(artifact); }