/// <inheritdoc /> protected override IEnumerable <ICodeAnalysisIssue> InternalReadIssues(PrcaCommentFormat format) { // Determine path of the doc root. var docRootPath = this.settings.DocRootPath; if (docRootPath.IsRelative) { docRootPath = docRootPath.MakeAbsolute(this.PrcaSettings.RepositoryRoot); } return (from logEntry in this.settings.LogFileContent.Split(new[] { '{', '}' }, StringSplitOptions.RemoveEmptyEntries).Select(x => "{" + x + "}") let logEntryObject = JsonConvert.DeserializeObject <JToken>(logEntry) let severity = (string)logEntryObject.SelectToken("message_severity") let file = this.TryGetFile(logEntryObject, docRootPath) let line = (int?)logEntryObject.SelectToken("line") let message = (string)logEntryObject.SelectToken("message") let source = (string)logEntryObject.SelectToken("source") ?? "DocFx" where severity == "warning" && !string.IsNullOrWhiteSpace(message) select new CodeAnalysisIssue <DocFxIssuesProvider>( file, line, message, 0, source)); }
/// <summary> /// Read issues from issue providers. /// </summary> /// <param name="format">Preferred format for comments.</param> /// <returns>List of issues.</returns> public IEnumerable <ICodeAnalysisIssue> ReadIssues(PrcaCommentFormat format) { // Initialize issue providers and read issues. var issues = new List <ICodeAnalysisIssue>(); foreach (var codeAnalysisProvider in this.issueProviders) { var providerName = codeAnalysisProvider.GetType().Name; this.log.Verbose("Initialize code analysis provider {0}...", providerName); if (codeAnalysisProvider.Initialize(this.settings)) { this.log.Verbose("Reading issues from {0}...", providerName); var currentIssues = codeAnalysisProvider.ReadIssues(format).ToList(); this.log.Verbose( "Found {0} issues using issue provider {1}...", currentIssues.Count, providerName); issues.AddRange(currentIssues); } else { this.log.Warning("Error initializing issue provider {0}.", providerName); } } return(issues); }
/// <inheritdoc /> protected override IEnumerable <ICodeAnalysisIssue> InternalReadIssues(PrcaCommentFormat format) { var result = new List <ICodeAnalysisIssue>(); var logDocument = XDocument.Parse(this.settings.LogFileContent); var solutionPath = Path.GetDirectoryName(logDocument.Descendants("Solution").Single().Value); // Read all issue types var issueTypes = logDocument.Descendants("IssueType").ToDictionary( x => x.Attribute("Id")?.Value, x => new IssueType { WikiUrl = x.Attribute("WikiUrl")?.Value.ToUri() }); // Loop through all issue tags. foreach (var issue in logDocument.Descendants("Issue")) { // Read affected file from the issue. string fileName; if (!TryGetFile(issue, solutionPath, out fileName)) { continue; } // Read affected line from the issue. int line; if (!TryGetLine(issue, out line)) { continue; } // Read rule code from the issue. string rule; if (!TryGetRule(issue, out rule)) { continue; } // Read message from the issue. string message; if (!TryGetMessage(issue, out message)) { continue; } result.Add(new CodeAnalysisIssue <InspectCodeIssuesProvider>( fileName, line, message, 0, // TODO Set based on severity of issueType rule, issueTypes[rule].WikiUrl)); } return(result); }
/// <inheritdoc/> public IEnumerable <ICodeAnalysisIssue> ReadIssues(PrcaCommentFormat format) { if (this.PrcaSettings == null) { throw new InvalidOperationException("Initialize needs to be called first."); } return(this.InternalReadIssues(format)); }
/// <inheritdoc /> protected override IEnumerable <ICodeAnalysisIssue> InternalReadIssues(PrcaCommentFormat format) { var logFileEntries = JsonConvert.DeserializeObject <Dictionary <string, IEnumerable <JToken> > >(this.settings.LogFileContent); return (from file in logFileEntries from entry in file.Value let rule = (string)entry.SelectToken("ruleName") select new CodeAnalysisIssue <MarkdownlintProvider>( file.Key, (int)entry.SelectToken("lineNumber"), (string)entry.SelectToken("ruleDescription"), 0, rule, MarkdownlintRuleUrlResolver.Instance.ResolveRuleUrl(rule))); }
public void Should_Use_The_Correct_Comment_Format(PrcaCommentFormat format) { // Given var fixture = new PrcaFixture(); fixture.PullRequestSystem = new FakePullRequestSystem( fixture.Log, new List <IPrcaDiscussionThread>(), new List <FilePath>()) { CommentFormat = format }; // When fixture.RunOrchestrator(); // Then fixture.CodeAnalysisProviders.ShouldAllBe(x => x.Format == format); }
protected override IEnumerable <ICodeAnalysisIssue> InternalReadIssues(PrcaCommentFormat format) { this.Format = format; return(this.issues); }
public IEnumerable <ICodeAnalysisIssue> ReadIssues(PrcaCommentFormat format) { var issueReader = new IssueReader(this.Log, this.CodeAnalysisProviders, this.Settings); return(issueReader.ReadIssues(format)); }
/// <inheritdoc /> protected override IEnumerable <ICodeAnalysisIssue> InternalReadIssues(PrcaCommentFormat format) { return(this.settings.Format.ReadIssues(this.PrcaSettings, this.settings)); }
/// <summary> /// Gets all code analysis issues. /// Compared to <see cref="ReadIssues"/> it is safe to access <see cref="PrcaSettings"/> from this method. /// </summary> /// <param name="format">Preferred format of the comments.</param> /// <returns>List of code analysis issues</returns> protected abstract IEnumerable <ICodeAnalysisIssue> InternalReadIssues(PrcaCommentFormat format);