Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
Fixed problem with not finding new issues in SonarQube 5.4/5.5 and
Browse files Browse the repository at this point in the history
Gradle build
  • Loading branch information
mrueegg committed May 13, 2016
1 parent a042e0a commit 452dad3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

mvn clean install || exit 1

PLUGIN_VERSION=1.1.2
PLUGIN_VERSION=1.1.4-SNAPSHOT
PLUGIN_FILE="./target/sonar-bitbucket-plugin-$PLUGIN_VERSION.jar"

[ ! -f $PLUGIN_FILE ] && { echo "Plug-in JAR file not found: $PLUGIN_FILE"; exit 1; }
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>ch.mibex.bitbucket</groupId>
<artifactId>sonar-bitbucket-plugin</artifactId>
<version>1.1.2</version>
<version>1.1.4-SNAPSHOT</version>
<packaging>sonar-plugin</packaging>
<name>Sonar Bitbucket Cloud Plugin</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,9 @@ class BitbucketClient(config: SonarBBPluginConfig) extends BatchComponent {
.accept(MediaType.APPLICATION_JSON)
.`type`(MediaType.APPLICATION_JSON)
.get(classOf[String])

val page = JsonUtils.mapFromJson(response)
val nextPageStart = page.get("next").map(p => pageNr + 1)
val nextPageStart = page.get("next").map(_ => pageNr + 1)
(nextPageStart, f(page))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ class ReviewCommentsCreator(projectIssues: ProjectIssues,
}

private def processIssues(pullRequest: PullRequest, reviewResults: PullRequestReviewResults) = {
val newIssues = collectNewIssuesInProject()
val issuesOnChangedLines = issuesOnChangedLinesFilter.filter(pullRequest, newIssues)
debugLogIssueStatistics(newIssues, issuesOnChangedLines)
val issues = collectIssuesInProject() // we have to
val issuesOnChangedLines = issuesOnChangedLinesFilter.filter(pullRequest, issues)
debugLogIssueStatistics(issues, issuesOnChangedLines)
val onlyIssuesWithMinSeverity = issuesOnChangedLines
.filter(i => SonarUtils.isSeverityGreaterOrEqual(i, pluginConfig.minSeverity()))
val commentsToBeAdded = new mutable.HashMap[String, mutable.Map[Int, StringBuilder]]()
Expand Down Expand Up @@ -112,10 +112,10 @@ class ReviewCommentsCreator(projectIssues: ProjectIssues,
commentsToBeAdded.toMap
}

private def debugLogIssueStatistics(newIssues: Seq[Issue], issuesOnChangedLines: Seq[Issue]) {
private def debugLogIssueStatistics(issues: Seq[Issue], issuesOnChangedLines: Seq[Issue]) {
if (logger.isDebugEnabled) {
logger.debug(LogUtils.f(s"Found ${newIssues.size} new issues:"))
newIssues foreach { i =>
logger.debug(LogUtils.f(s"Found ${issues.size} issues and ${issues.filter(_.isNew)} of them are new:"))
issues foreach { i =>
logger.debug(LogUtils.f(s" - ${i.componentKey()}:${i.line()}: ${i.message()}"))
}
logger.debug(LogUtils.f(s"And ${issuesOnChangedLines.size} of these are on changed or new lines:"))
Expand Down Expand Up @@ -145,14 +145,14 @@ class ReviewCommentsCreator(projectIssues: ProjectIssues,
)
}

private def collectNewIssuesInProject() =
private def collectIssuesInProject() =
// with sonar.analysis.mode=preview and sonar.analysis.mode=issues I always get all issues here
// although I only request new ones; this should be changed with SonarQube 5.4; until then, we still have to filter
// issues on changed lines only by using the diff from Bitbucket
// UPDATE: SonarQube 5.5 does not report any issues at all when filtering for new issues with issues.filter(_.isNew)
projectIssues
.issues()
.asScala
.filter(_.isNew)
.toSeq

}

0 comments on commit 452dad3

Please sign in to comment.