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;
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() {
*/
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() {
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());
return Java.KEY.equals(project.getLanguageKey());
}
}
-
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();
}
/**
- * 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
/**
* 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);
}
try {
appendable.append((char) pop());
} catch (IOException e) {
- throw new ChannelException(e.getMessage());
+ throw new ChannelException(e.getMessage(), e);
}
}
*/
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;
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 {
}
}
+ private static final EndMatcher LINE_END_MATCHER = new EndMatcher() {
+ public boolean match(int endFlag) {
+ return endFlag == '\r' || endFlag == '\n';
+ }
+ };
+
}
* 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.
/**
* 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();
}
/**
* This interface is not intended to be implemented by clients.
*/
- public interface DecoratorExecutionEvent {
+ interface DecoratorExecutionEvent {
Decorator getDecorator();
/**
* This interface is not intended to be implemented by clients.
*/
- public interface DecoratorsPhaseEvent {
+ interface DecoratorsPhaseEvent {
/**
* @return list of Decorators in the order of execution
/**
* This interface is not intended to be implemented by clients.
*/
- public interface ProjectAnalysisEvent {
+ interface ProjectAnalysisEvent {
Project getProject();
/**
* This interface is not intended to be implemented by clients.
*/
- public interface SensorExecutionEvent {
+ interface SensorExecutionEvent {
Sensor getSensor();
/**
* This interface is not intended to be implemented by clients.
*/
- public interface SensorsPhaseEvent {
+ interface SensorsPhaseEvent {
/**
* @return list of Sensors in the order of execution
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;
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);
return scanner;
}
+ /**
+ * @deprecated use {@link #decorateSourceCodeTreeWith(MetricDef...)} instead
+ */
@Deprecated
public SourceProject aggregate() {
return decorateSourceCodeTreeWith(Metric.values());
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) {