private Hotspot ConvertToHotspot(SonarQubeHotspot sonarQubeHotspot) { var localFilePath = absoluteFilePathLocator.Locate(sonarQubeHotspot.FilePath); var priority = GetPriority(sonarQubeHotspot.Rule.VulnerabilityProbability); var sqRule = sonarQubeHotspot.Rule; var rule = new HotspotRule( sqRule.RuleKey, sqRule.RuleName, sqRule.SecurityCategory, priority, sqRule.RiskDescription, sqRule.VulnerabilityDescription, sqRule.FixRecommendations ); var hotspot = new Hotspot( hotspotKey: sonarQubeHotspot.HotspotKey, filePath: localFilePath, serverFilePath: sonarQubeHotspot.FilePath, message: sonarQubeHotspot.Message, startLine: sonarQubeHotspot.TextRange.StartLine, endLine: sonarQubeHotspot.TextRange.EndLine, startLineOffset: sonarQubeHotspot.TextRange.StartOffset, endLineOffset: sonarQubeHotspot.TextRange.EndOffset, lineHash: sonarQubeHotspot.LineHash, rule: rule, createTimestamp: sonarQubeHotspot.CreationTimestamp, lastUpdateTimestamp: sonarQubeHotspot.LastUpdateTimestamp, flows: null); return(hotspot); }
public IAnalysisIssueVisualization Convert(SonarQubeHotspot sonarQubeHotspot) { var hotspot = ConvertToHotspot(sonarQubeHotspot); var issueViz = issueVisualizationConverter.Convert(hotspot); return(issueViz); }
private IAnalysisIssueVisualization TryCreateIssueViz(SonarQubeHotspot hotspot) { try { return(converter.Convert(hotspot)); } catch (Exception ex) when(!Microsoft.VisualStudio.ErrorHandler.IsCriticalException(ex)) { logger.WriteLine(OpenInIDEResources.ApiHandler_UnableToConvertHotspotData, ex.Message); } return(null); }
private void SetConverterToThrow(SonarQubeHotspot expected, Exception ex) => converterMock.Setup(x => x.Convert(expected)).Throws(ex);
private void SetConversionResponse(SonarQubeHotspot expected, IAnalysisIssueVisualization response) => converterMock.Setup(x => x.Convert(expected)).Returns(response);
private void SetServerResponse(IShowHotspotRequest expected, SonarQubeHotspot response) => serverMock.Setup(x => x.GetHotspotAsync(expected.HotspotKey, It.IsAny <CancellationToken>())) .Returns(Task <SonarQubeHotspot> .FromResult(response));