From c9863df6828342adab79de3b26553a932c308518 Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Mon, 8 Dec 2014 11:50:52 +0100 Subject: [PATCH] Fix some quality flaws --- .../java/org/sonar/plugins/core/issue/IssueTracking.java | 7 +++++-- .../java/org/sonar/batch/maven/MavenProjectConverter.java | 3 ++- .../main/java/org/sonar/batch/scan/ProjectSettings.java | 2 +- .../org/sonar/api/batch/bootstrap/ProjectDefinition.java | 5 +---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTracking.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTracking.java index 884e298bd68..da4059eeb0d 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTracking.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTracking.java @@ -82,8 +82,11 @@ public class IssueTracking implements BatchExtension { // If each new issue matches an old one we can stop the matching mechanism if (result.matched().size() != newIssues.size()) { - if (sourceHashHolder != null && sourceHashHolder.getHashedReference() != null && hasLastScan) { - mapNewissues(sourceHashHolder.getHashedReference(), sourceHashHolder.getHashedSource(), newIssues, result); + if (sourceHashHolder != null && hasLastScan) { + FileHashes hashedReference = sourceHashHolder.getHashedReference(); + if (hashedReference != null) { + mapNewissues(hashedReference, sourceHashHolder.getHashedSource(), newIssues, result); + } } mapIssuesOnSameRule(newIssues, result); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/maven/MavenProjectConverter.java b/sonar-batch/src/main/java/org/sonar/batch/maven/MavenProjectConverter.java index 2ef3fe6fa54..6109b645421 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/maven/MavenProjectConverter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/maven/MavenProjectConverter.java @@ -40,6 +40,7 @@ import org.sonar.batch.scan.filesystem.DefaultModuleFileSystem; import org.sonar.java.api.JavaUtils; import javax.annotation.Nullable; + import java.io.File; import java.io.IOException; import java.util.Arrays; @@ -190,7 +191,7 @@ public class MavenProjectConverter implements TaskExtension { } private static void setPropertyIfNotAlreadyExists(ProjectDefinition definition, String propertyKey, String propertyValue) { - if (StringUtils.isBlank(definition.getProperties().getProperty(propertyKey))) { + if (StringUtils.isBlank(definition.properties().get(propertyKey))) { definition.setProperty(propertyKey, StringUtils.defaultString(propertyValue)); } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java index c2749ba0099..72218e95ce3 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectSettings.java @@ -55,7 +55,7 @@ public class ProjectSettings extends Settings { addProperties(projectReferentials.settings(reactor.getRoot().getKeyWithBranch())); - addProperties(reactor.getRoot().getProperties()); + addProperties(reactor.getRoot().properties()); } @Override diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java index e527f649b7b..4822a4a89aa 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/bootstrap/ProjectDefinition.java @@ -86,10 +86,6 @@ public class ProjectDefinition { private List subProjects = Lists.newArrayList(); private List containerExtensions = Lists.newArrayList(); - private ProjectDefinition(Map p) { - this.properties = p; - } - private ProjectDefinition(Properties p) { for (Entry entry : p.entrySet()) { this.properties.put(entry.getKey().toString(), entry.getValue().toString()); @@ -162,6 +158,7 @@ public class ProjectDefinition { * @since 2.12 * @deprecated since 5.0 use {@link #setProperties(Map)} */ + @Deprecated public ProjectDefinition setProperties(Properties properties) { for (Entry entry : properties.entrySet()) { this.properties.put(entry.getKey().toString(), entry.getValue().toString()); -- 2.39.5