private SonarQubeRule ToSonarQubeRule(RuleResponse response,
                                              IEnumerable <QualityProfileResponse> activeQualityProfiles)
        {
            var isActive = activeQualityProfiles.Any();

            SonarQubeIssueSeverity      severity;
            Dictionary <string, string> parameters;

            if (isActive)
            {
                var activeQP = activeQualityProfiles.First();
                severity = SonarQubeIssueSeverityConverter.Convert(activeQP.Severity);

                // Optimisation: avoid creating objects if there are no parameters
                parameters = activeQP.Parameters.Length > 0 ?
                             activeQP.Parameters.ToDictionary(p => p.Key, p => p.Value) : null;
            }
            else
            {
                severity   = SonarQubeIssueSeverity.Unknown;
                parameters = null;
            }

            var issueType = SonarQubeIssueTypeConverter.Convert(response.Type);

            return(new SonarQubeRule(GetRuleKey(response.Key), response.RepositoryKey, isActive, severity, parameters, issueType));
        }
Ejemplo n.º 2
0
 private SonarQubeIssue ToSonarQubeIssue(ServerIssue issue) =>
 new SonarQubeIssue(issue.IssueKey, ComputePath(issue.Component), issue.Hash, issue.Message, ComputeModuleKey(issue),
                    GetRuleKey(issue.CompositeRuleKey), issue.Status == "RESOLVED",
                    SonarQubeIssueSeverityConverter.Convert(issue.Severity),
                    issue.CreationDate,
                    issue.UpdateDate,
                    ToIssueTextRange(issue.TextRange),
                    ToIssueFlows(issue.Flows));
 public void SeverityConversion(string inputData, SonarQubeIssueSeverity expectedResult)
 {
     SonarQubeIssueSeverityConverter.Convert(inputData).Should().Be(expectedResult);
 }