diff options
15 files changed, 42 insertions, 45 deletions
diff --git a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java index 4935390e21d..0c011a05726 100644 --- a/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java +++ b/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/timemachine/ViolationPersisterDecorator.java @@ -25,7 +25,6 @@ import com.google.common.collect.Multimap; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.lang.ObjectUtils; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.math.NumberUtils; import org.sonar.api.batch.*; import org.sonar.api.database.model.RuleFailureModel; import org.sonar.api.database.model.SnapshotSource; diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/ChidamberKemererDistributionBuilder.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/ChidamberKemererDistributionBuilder.java index 0dac2438e65..202395145e9 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/ChidamberKemererDistributionBuilder.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/ChidamberKemererDistributionBuilder.java @@ -34,8 +34,8 @@ import org.sonar.api.resources.Scopes; public final class ChidamberKemererDistributionBuilder implements Decorator { - public static final Integer[] LCOM4_LIMITS = {2, 3, 4, 5, 10};// 1 is excluded - public static final Integer[] RFC_LIMITS = {0, 5, 10, 20, 30, 50, 90, 150}; + private static final Integer[] LCOM4_LIMITS = { 2, 3, 4, 5, 10 }; // 1 is excluded + private static final Integer[] RFC_LIMITS = { 0, 5, 10, 20, 30, 50, 90, 150 }; @DependedUpon public Metric generatesLcom4Distribution() { diff --git a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/FunctionComplexityDistributionBuilder.java b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/FunctionComplexityDistributionBuilder.java index 6b9477ba720..e60ccad8d6e 100644 --- a/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/FunctionComplexityDistributionBuilder.java +++ b/plugins/sonar-squid-java-plugin/src/main/java/org/sonar/plugins/squid/decorators/FunctionComplexityDistributionBuilder.java @@ -35,7 +35,7 @@ import org.sonar.java.api.JavaMethod; */ public final class FunctionComplexityDistributionBuilder implements Decorator { - public static final Number[] LIMITS = {1, 2, 4, 6, 8, 10, 12}; + private static final Number[] LIMITS = { 1, 2, 4, 6, 8, 10, 12 }; @DependsUpon public Metric dependOnComplexity() { @@ -52,7 +52,7 @@ public final class FunctionComplexityDistributionBuilder implements Decorator { RangeDistributionBuilder builder = new RangeDistributionBuilder(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION, LIMITS); for (DecoratorContext childContext : context.getChildren()) { if (childContext.getResource() instanceof JavaMethod) { - JavaMethod javaMethod = (JavaMethod)childContext.getResource(); + JavaMethod javaMethod = (JavaMethod) childContext.getResource(); Measure complexity = childContext.getMeasure(CoreMetrics.COMPLEXITY); if (!javaMethod.isAccessor() && complexity != null) { builder.add(complexity.getValue()); @@ -73,4 +73,3 @@ public final class FunctionComplexityDistributionBuilder implements Decorator { return Java.KEY.equals(project.getLanguageKey()); } } - diff --git a/sonar-channel/src/main/java/org/sonar/channel/CodeBuffer.java b/sonar-channel/src/main/java/org/sonar/channel/CodeBuffer.java index 50359838d72..6373bb0ff40 100644 --- a/sonar-channel/src/main/java/org/sonar/channel/CodeBuffer.java +++ b/sonar-channel/src/main/java/org/sonar/channel/CodeBuffer.java @@ -62,7 +62,7 @@ public class CodeBuffer implements CharSequence { buffer = new char[bufferCapacity]; Reader reader = initialCodeReader; for (CodeReaderFilter<?> codeReaderFilter : configuration.getCodeReaderFilters()) { - reader = new Filter(reader, codeReaderFilter); + reader = new Filter(reader, codeReaderFilter, configuration); } this.code = reader; fillBuffer(); @@ -240,7 +240,7 @@ public class CodeBuffer implements CharSequence { } /** - * Warning : this method returns Integer.MAX_VALUE when the buffer is fully used + * Warning : this method returns Integer.MAX_VALUE when the buffer is fully used * as the length of the stream can't be known before having consumed all characters. * * Integer.MAX_VALUE is returned to prevent regular expression matchers to stop consuming the stream of characters (see @@ -289,14 +289,14 @@ public class CodeBuffer implements CharSequence { /** * Bridge class between CodeBuffer and CodeReaderFilter */ - final class Filter extends FilterReader { + static final class Filter extends FilterReader { private CodeReaderFilter<?> codeReaderFilter; - public Filter(Reader in, CodeReaderFilter<?> codeReaderFilter) { + public Filter(Reader in, CodeReaderFilter<?> codeReaderFilter, CodeReaderConfiguration configuration) { super(in); this.codeReaderFilter = codeReaderFilter; - this.codeReaderFilter.setConfiguration(CodeBuffer.this.configuration.cloneWithoutCodeReaderFilters()); + this.codeReaderFilter.setConfiguration(configuration.cloneWithoutCodeReaderFilters()); this.codeReaderFilter.setReader(in); } diff --git a/sonar-channel/src/main/java/org/sonar/channel/CodeReader.java b/sonar-channel/src/main/java/org/sonar/channel/CodeReader.java index 8d8673edbc1..1033ad20668 100644 --- a/sonar-channel/src/main/java/org/sonar/channel/CodeReader.java +++ b/sonar-channel/src/main/java/org/sonar/channel/CodeReader.java @@ -79,7 +79,7 @@ public class CodeReader extends CodeBuffer { try { appendable.append((char) pop()); } catch (IOException e) { - throw new ChannelException(e.getMessage()); + throw new ChannelException(e.getMessage(), e); } } diff --git a/sonar-colorizer/src/main/java/org/sonar/colorizer/InlineDocTokenizer.java b/sonar-colorizer/src/main/java/org/sonar/colorizer/InlineDocTokenizer.java index 0d6d70fa481..76f1025d712 100644 --- a/sonar-colorizer/src/main/java/org/sonar/colorizer/InlineDocTokenizer.java +++ b/sonar-colorizer/src/main/java/org/sonar/colorizer/InlineDocTokenizer.java @@ -19,11 +19,11 @@ */ package org.sonar.colorizer; -import java.util.Arrays; - import org.sonar.channel.CodeReader; import org.sonar.channel.EndMatcher; +import java.util.Arrays; + public abstract class InlineDocTokenizer extends Tokenizer { private final String tagBefore; @@ -40,12 +40,7 @@ public abstract class InlineDocTokenizer extends Tokenizer { public boolean consume(CodeReader code, HtmlCodeBuilder codeBuilder) { if (code.peek() == startToken[0] && Arrays.equals(code.peek(startToken.length), startToken)) { codeBuilder.appendWithoutTransforming(tagBefore); - code.popTo(new EndMatcher() { - - public boolean match(int endFlag) { - return endFlag == '\r' || endFlag == '\n'; - } - }, codeBuilder); + code.popTo(LINE_END_MATCHER, codeBuilder); codeBuilder.appendWithoutTransforming(tagAfter); return true; } else { @@ -53,4 +48,10 @@ public abstract class InlineDocTokenizer extends Tokenizer { } } + private static final EndMatcher LINE_END_MATCHER = new EndMatcher() { + public boolean match(int endFlag) { + return endFlag == '\r' || endFlag == '\n'; + } + }; + } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java index 2a737ad13ad..771a1f42ebf 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/DecoratorContext.java @@ -109,7 +109,7 @@ public interface DecoratorContext { * the request parameters specified as a {@link ViolationQuery} * @return the list of violations that match those parameters */ - abstract List<Violation> getViolations(ViolationQuery violationQuery); + List<Violation> getViolations(ViolationQuery violationQuery); /** * Returns all the active (= non switched-off) violations found on the current resource. diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/InstantiationStrategy.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/InstantiationStrategy.java index b270d9ce0d9..308fd4357ac 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/InstantiationStrategy.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/InstantiationStrategy.java @@ -35,12 +35,12 @@ public @interface InstantiationStrategy { /** * Shared extension. Lifecycle is the full analysis. */ - public static final String PER_BATCH = "PER_BATCH"; + String PER_BATCH = "PER_BATCH"; /** * Created and initialized for each project and sub-project (a project is a module in Maven terminology). */ - public static final String PER_PROJECT = "PER_PROJECT"; + String PER_PROJECT = "PER_PROJECT"; String value(); } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/DecoratorExecutionHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/DecoratorExecutionHandler.java index 0db117a37de..74645acf36e 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/DecoratorExecutionHandler.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/DecoratorExecutionHandler.java @@ -29,7 +29,7 @@ public interface DecoratorExecutionHandler extends EventHandler { /** * This interface is not intended to be implemented by clients. */ - public interface DecoratorExecutionEvent { + interface DecoratorExecutionEvent { Decorator getDecorator(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/DecoratorsPhaseHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/DecoratorsPhaseHandler.java index c6a218078cb..b6a28d317b5 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/DecoratorsPhaseHandler.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/DecoratorsPhaseHandler.java @@ -31,7 +31,7 @@ public interface DecoratorsPhaseHandler extends EventHandler { /** * This interface is not intended to be implemented by clients. */ - public interface DecoratorsPhaseEvent { + interface DecoratorsPhaseEvent { /** * @return list of Decorators in the order of execution diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/ProjectAnalysisHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/ProjectAnalysisHandler.java index 110a4b5f475..2e0de22daae 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/ProjectAnalysisHandler.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/ProjectAnalysisHandler.java @@ -29,7 +29,7 @@ public interface ProjectAnalysisHandler extends EventHandler { /** * This interface is not intended to be implemented by clients. */ - public interface ProjectAnalysisEvent { + interface ProjectAnalysisEvent { Project getProject(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorExecutionHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorExecutionHandler.java index 26d78596d98..7ff0a38dd02 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorExecutionHandler.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorExecutionHandler.java @@ -29,7 +29,7 @@ public interface SensorExecutionHandler extends EventHandler { /** * This interface is not intended to be implemented by clients. */ - public interface SensorExecutionEvent { + interface SensorExecutionEvent { Sensor getSensor(); diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorsPhaseHandler.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorsPhaseHandler.java index 8a54de8b442..f368e588992 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorsPhaseHandler.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/events/SensorsPhaseHandler.java @@ -31,7 +31,7 @@ public interface SensorsPhaseHandler extends EventHandler { /** * This interface is not intended to be implemented by clients. */ - public interface SensorsPhaseEvent { + interface SensorsPhaseEvent { /** * @return list of Sensors in the order of execution diff --git a/sonar-squid/src/main/java/org/sonar/squid/Squid.java b/sonar-squid/src/main/java/org/sonar/squid/Squid.java index 1702f6f23dd..b2153e25ef0 100644 --- a/sonar-squid/src/main/java/org/sonar/squid/Squid.java +++ b/sonar-squid/src/main/java/org/sonar/squid/Squid.java @@ -20,28 +20,20 @@ package org.sonar.squid; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - import org.picocontainer.MutablePicoContainer; import org.picocontainer.containers.TransientPicoContainer; import org.sonar.graph.DirectedGraph; import org.sonar.graph.DirectedGraphAccessor; -import org.sonar.squid.api.CodeScanner; -import org.sonar.squid.api.CodeVisitor; -import org.sonar.squid.api.Query; -import org.sonar.squid.api.SourceCode; -import org.sonar.squid.api.SourceCodeEdge; -import org.sonar.squid.api.SourceCodeSearchEngine; -import org.sonar.squid.api.SourceCodeTreeDecorator; -import org.sonar.squid.api.SourceProject; -import org.sonar.squid.api.SquidConfiguration; +import org.sonar.squid.api.*; import org.sonar.squid.indexer.SquidIndex; import org.sonar.squid.measures.Metric; import org.sonar.squid.measures.MetricDef; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + public class Squid implements DirectedGraphAccessor<SourceCode, SourceCodeEdge>, SourceCodeSearchEngine { private MutablePicoContainer pico; @@ -79,7 +71,7 @@ public class Squid implements DirectedGraphAccessor<SourceCode, SourceCodeEdge>, SCANNER scanner = pico.getComponent(scannerClass); for (Object clazz : scanner.getVisitorClasses()) { addToPicocontainer((Class) clazz); - scanner.accept(pico.<CodeVisitor>getComponent((Class) clazz)); + scanner.accept(pico.<CodeVisitor> getComponent((Class) clazz)); } for (CodeVisitor externalVisitor : externalCodeVisitors) { scanner.accept(externalVisitor); @@ -87,6 +79,9 @@ public class Squid implements DirectedGraphAccessor<SourceCode, SourceCodeEdge>, return scanner; } + /** + * @deprecated use {@link #decorateSourceCodeTreeWith(MetricDef...)} instead + */ @Deprecated public SourceProject aggregate() { return decorateSourceCodeTreeWith(Metric.values()); diff --git a/sonar-squid/src/main/java/org/sonar/squid/indexer/QueryByMeasure.java b/sonar-squid/src/main/java/org/sonar/squid/indexer/QueryByMeasure.java index 4afdc7196e6..cdc74381c2a 100644 --- a/sonar-squid/src/main/java/org/sonar/squid/indexer/QueryByMeasure.java +++ b/sonar-squid/src/main/java/org/sonar/squid/indexer/QueryByMeasure.java @@ -34,10 +34,13 @@ public class QueryByMeasure implements Query { public enum Operator { GREATER_THAN, EQUALS, GREATER_THAN_EQUALS, LESS_THAN, LESS_THAN_EQUALS } - + + /** + * @deprecated use {@link #QueryByMeasure(MetricDef, Operator, double)} instead + */ @Deprecated public QueryByMeasure(Metric metric, Operator operator, double value) { - this((MetricDef)metric, operator, value); + this((MetricDef) metric, operator, value); } public QueryByMeasure(MetricDef metric, Operator operator, double value) { |