Skip to content

Commit

Permalink
Add PR Decoration Support for Azure DevOps Server
Browse files Browse the repository at this point in the history
fixing space in url

fix PR URL

SonarCloud fixes

fix spacing issue

Reopen Azure Thread if SQ issue is open

fix enumeration property names for serialization.
remove reactivation of azure threads

filter azure threads without rightFileStart info

Cleanup and add tests

Fix merge conflicts
  • Loading branch information
Jeff Boccuzzi committed Oct 26, 2020
1 parent f665952 commit 6189d19
Show file tree
Hide file tree
Showing 27 changed files with 1,792 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@

#Project libs
/sonarqube-lib/

#VSCode
.project
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ tasks.shadowJar.configure {
classifier = null
}

tasks.withType(JavaCompile) {
options.compilerArgs << '-Xlint:unchecked'
options.deprecation = true
}

assemble.dependsOn('shadowJar')

pitest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PostAnalysisIssueVisitor;
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.PullRequestPostAnalysisTask;
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.azuredevops.AzureDevOpsServerPullRequestDecorator;
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.BitbucketPullRequestDecorator;
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.github.GithubPullRequestDecorator;
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.github.v3.DefaultLinkHeaderReader;
Expand All @@ -41,7 +42,8 @@ public List<Object> getComponents() {
return Arrays.asList(CommunityBranchLoaderDelegate.class, PullRequestPostAnalysisTask.class,
PostAnalysisIssueVisitor.class, GithubPullRequestDecorator.class,
GraphqlCheckRunProvider.class, DefaultLinkHeaderReader.class, RestApplicationAuthenticationProvider.class,
BitbucketPullRequestDecorator.class, GitlabServerPullRequestDecorator.class);
BitbucketPullRequestDecorator.class, GitlabServerPullRequestDecorator.class,
AzureDevOpsServerPullRequestDecorator.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@

public class AnalysisDetails {

public static final String SCANNERROPERTY_PULLREQUEST_BRANCH = "sonar.pullrequest.branch";
public static final String SCANNERROPERTY_PULLREQUEST_BASE = "sonar.pullrequest.base";
public static final String SCANNERROPERTY_PULLREQUEST_KEY = "sonar.pullrequest.key";

private static final List<String> CLOSED_ISSUE_STATUS = Arrays.asList(Issue.STATUS_CLOSED, Issue.STATUS_RESOLVED);

private static final List<BigDecimal> COVERAGE_LEVELS =
Expand Down Expand Up @@ -115,11 +119,27 @@ public String getDashboardUrl() {
public String getIssueUrl(String issueKey) {
return publicRootURL + "/project/issues?id=" + encode(project.getKey()) + "&pullRequest=" + branchDetails.getBranchName() + "&issues=" + issueKey + "&open=" + issueKey;
}

public Optional<String> getPullRequestBase() {
return Optional.ofNullable(scannerContext.getProperties().get(SCANNERROPERTY_PULLREQUEST_BASE));
}

public Optional<String> getPullRequestBranch() {
return Optional.ofNullable(scannerContext.getProperties().get(SCANNERROPERTY_PULLREQUEST_BRANCH));
}

public Optional<String> getPullRequestKey() {
return Optional.ofNullable(scannerContext.getProperties().get(SCANNERROPERTY_PULLREQUEST_KEY));
}

public QualityGate.Status getQualityGateStatus() {
return qualityGate.getStatus();
}

public String getRuleUrlWithRuleKey(String ruleKey) {
return publicRootURL + "/coding_rules?open=" + encode(ruleKey) + "&rule_key=" + encode(ruleKey);
}

public Optional<String> getScannerProperty(String propertyName) {
return Optional.ofNullable(scannerContext.getProperties().get(propertyName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
*/
package com.github.mc1arke.sonarqube.plugin.ce.pullrequest;

import org.sonar.api.rule.RuleKey;
import org.sonar.api.rules.RuleType;
import org.sonar.ce.task.projectanalysis.component.Component;
import org.sonar.ce.task.projectanalysis.issue.IssueVisitor;
import org.sonar.core.issue.DefaultIssue;
import org.sonar.db.protobuf.DbIssues;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -80,16 +82,21 @@ public static class LightIssue {
private final String severity;
private final String status;
private final RuleType type;
private final DbIssues.Locations locations;
private final RuleKey ruleKey;

private LightIssue(DefaultIssue issue) {
this.effortInMinutes = issue.effortInMinutes();
this.key = issue.key();
this.line = issue.getLine();
this.message = issue.getMessage();

this.resolution = issue.resolution();
this.severity = issue.severity();
this.status = issue.status();
this.type = issue.type();
this.locations = issue.getLocations();
this.ruleKey = issue.getRuleKey();
}

@CheckForNull
Expand Down Expand Up @@ -132,6 +139,14 @@ public RuleType type() {
return type;
}

public DbIssues.Locations getLocations() {
return locations;
}

public RuleKey getRuleKey() {
return ruleKey;
}

@Override
public int hashCode() {
return Objects.hash(effortInMinutes, key, line, message, resolution, severity, status, type);
Expand Down
Loading

0 comments on commit 6189d19

Please sign in to comment.