diff options
author | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2013-10-22 13:03:40 +0200 |
---|---|---|
committer | Jean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com> | 2013-10-22 13:03:40 +0200 |
commit | 8116d7d1593519112e427c1dde41ffad9dca82e7 (patch) | |
tree | 5be4e6e829dbbd5f6950d2e826376fbdfbd04eb8 /plugins/sonar-core-plugin | |
parent | d15a689afb2463a19959930f0f2d9f226ed5b4fb (diff) | |
download | sonarqube-8116d7d1593519112e427c1dde41ffad9dca82e7.tar.gz sonarqube-8116d7d1593519112e427c1dde41ffad9dca82e7.zip |
Fix quality flaws
Diffstat (limited to 'plugins/sonar-core-plugin')
3 files changed, 24 insertions, 18 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java index 0d668bc8d54..a72c178e9cf 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/IssueTrackingDecorator.java @@ -25,7 +25,12 @@ import com.google.common.collect.Lists; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonar.api.batch.*; +import org.sonar.api.batch.Decorator; +import org.sonar.api.batch.DecoratorBarriers; +import org.sonar.api.batch.DecoratorContext; +import org.sonar.api.batch.DependedUpon; +import org.sonar.api.batch.DependsUpon; +import org.sonar.api.batch.SonarIndex; import org.sonar.api.component.ResourcePerspectives; import org.sonar.api.issue.Issuable; import org.sonar.api.issue.Issue; @@ -52,6 +57,8 @@ import java.util.Collection; @DependedUpon(DecoratorBarriers.ISSUES_TRACKED) public class IssueTrackingDecorator implements Decorator { + private static final Logger LOG = LoggerFactory.getLogger(IssueTrackingDecorator.class); + private final IssueCache issueCache; private final InitialOpenIssuesStack initialOpenIssues; private final IssueTracking tracking; @@ -212,20 +219,19 @@ public class IssueTrackingDecorator implements Decorator { } private void relocateManualIssue(DefaultIssue newIssue, IssueDto oldIssue, SourceHashHolder sourceHashHolder) { - Logger logger = LoggerFactory.getLogger(IssueTrackingDecorator.class); - logger.debug("Trying to relocate manual issue {}", oldIssue.getKee()); + LOG.debug("Trying to relocate manual issue {}", oldIssue.getKee()); Integer previousLine = oldIssue.getLine(); if (previousLine == null) { - logger.debug("Cannot relocate issue at resource level"); + LOG.debug("Cannot relocate issue at resource level"); return; } Collection<Integer> newLinesWithSameHash = sourceHashHolder.getNewLinesMatching(previousLine); - logger.debug("Found the following lines with same hash: {}", newLinesWithSameHash); + LOG.debug("Found the following lines with same hash: {}", newLinesWithSameHash); if (newLinesWithSameHash.isEmpty()) { if (previousLine > sourceHashHolder.getHashedSource().length()) { - logger.debug("Old issue line {} is out of new source, closing and removing line number", previousLine); + LOG.debug("Old issue line {} is out of new source, closing and removing line number", previousLine); newIssue.setLine(null); updater.setStatus(newIssue, Issue.STATUS_CLOSED, changeContext); updater.setResolution(newIssue, Issue.RESOLUTION_REMOVED, changeContext); @@ -235,7 +241,7 @@ public class IssueTrackingDecorator implements Decorator { } } else if (newLinesWithSameHash.size() == 1) { Integer newLine = newLinesWithSameHash.iterator().next(); - logger.debug("Relocating issue to line {}", newLine); + LOG.debug("Relocating issue to line {}", newLine); newIssue.setLine(newLine); updater.setPastLine(newIssue, previousLine); diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/IgnoreIssuesConfiguration.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/IgnoreIssuesConfiguration.java index 5efe3b462a5..2f85575c379 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/IgnoreIssuesConfiguration.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/ignore/IgnoreIssuesConfiguration.java @@ -53,13 +53,13 @@ public final class IgnoreIssuesConfiguration { public static final String PATTERNS_ALLFILE_KEY = EXCLUSION_KEY_PREFIX + ALLFILE_SUFFIX; public static final String FILE_REGEXP = "fileRegexp"; + static final int LARGE_SIZE = 40; + static final int SMALL_SIZE = 10; + private IgnoreIssuesConfiguration() { // static configuration declaration only } - static final int LARGE_SIZE = 40; - static final int SMALL_SIZE = 10; - public static List<PropertyDefinition> getPropertyDefinitions() { return ImmutableList.of( PropertyDefinition.builder(PATTERNS_MULTICRITERIA_EXCLUSION_KEY) diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/tracking/HashedSequence.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/tracking/HashedSequence.java index d8a19ca5997..246a677c0eb 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/tracking/HashedSequence.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/tracking/HashedSequence.java @@ -19,11 +19,11 @@ */ package org.sonar.plugins.core.issue.tracking; -import java.util.Collection; - import com.google.common.collect.LinkedHashMultimap; import com.google.common.collect.Multimap; +import java.util.Collection; + /** * Wraps a {@link Sequence} to assign hash codes to elements. */ @@ -33,6 +33,12 @@ public final class HashedSequence<S extends Sequence> implements Sequence { final int[] hashes; final Multimap<Integer, Integer> linesByHash; + private HashedSequence(S base, int[] hashes, Multimap<Integer, Integer> linesByHash) { + this.base = base; + this.hashes = hashes; + this.linesByHash = linesByHash; + } + public static <S extends Sequence> HashedSequence<S> wrap(S base, SequenceComparator<S> cmp) { int size = base.length(); int[] hashes = new int[size]; @@ -45,12 +51,6 @@ public final class HashedSequence<S extends Sequence> implements Sequence { return new HashedSequence<S>(base, hashes, linesByHash); } - private HashedSequence(S base, int[] hashes, Multimap<Integer, Integer> linesByHash) { - this.base = base; - this.hashes = hashes; - this.linesByHash = linesByHash; - } - public int length() { return base.length(); } |