public class TendencyAnalyser {
- public final static Integer TENDENCY_BIG_UP = 2;
- public final static Integer TENDENCY_UP = 1;
- public final static Integer TENDENCY_NEUTRAL = 0;
- public final static Integer TENDENCY_DOWN = -1;
- public final static Integer TENDENCY_BIG_DOWN = -2;
+ public static final Integer TENDENCY_BIG_UP = 2;
+ public static final Integer TENDENCY_UP = 1;
+ public static final Integer TENDENCY_NEUTRAL = 0;
+ public static final Integer TENDENCY_DOWN = -1;
+ public static final Integer TENDENCY_BIG_DOWN = -2;
public Integer analyseLevel(List<Double> values) {
TendencyAnalyser.SlopeData slopeData = analyse(values);
import java.util.Map;
public final class FindbugsCategory {
- private final static Map<String, String> FINDBUGS_TO_SONAR = new HashMap<String, String>();
+ private static final Map<String, String> FINDBUGS_TO_SONAR = new HashMap<String, String>();
static {
FINDBUGS_TO_SONAR.put("BAD_PRACTICE", "Bad practice");
}
- private static abstract class TaskEnhancer {
+ private abstract static class TaskEnhancer {
/**
* @param task Task instance to enhance
* @return <code>true</code> if this enhancer is capable of enhancing the requested task
*/
package org.sonar.java.ast.visitor;
-import java.util.Arrays;
-import java.util.List;
-
+import com.puppycrawl.tools.checkstyle.api.*;
import org.sonar.squid.api.SourceCode;
import org.sonar.squid.measures.Metric;
-import com.puppycrawl.tools.checkstyle.api.AnnotationUtility;
-import com.puppycrawl.tools.checkstyle.api.DetailAST;
-import com.puppycrawl.tools.checkstyle.api.FileContents;
-import com.puppycrawl.tools.checkstyle.api.Scope;
-import com.puppycrawl.tools.checkstyle.api.TokenTypes;
+import java.util.Arrays;
+import java.util.List;
public class PublicApiVisitor extends JavaAstVisitor {
- final static String OVERRIDE_ANNOTATION_KEYWORD = "Override";
+ static final String OVERRIDE_ANNOTATION_KEYWORD = "Override";
public static final List<Integer> TOKENS = Arrays.asList(TokenTypes.CLASS_DEF, TokenTypes.INTERFACE_DEF, TokenTypes.METHOD_DEF,
TokenTypes.CTOR_DEF, TokenTypes.ANNOTATION_DEF, TokenTypes.ANNOTATION_FIELD_DEF, TokenTypes.VARIABLE_DEF);
*/
public final class SuppressWarningsAnnotationUtils {
- private final static String SUPPRESS_WARNINGS_ANNOTATION_NAME = "SuppressWarnings";
- private final static String SUPPRESS_WARNINGS_ANNOTATION_FQ_NAME = "java.lang." + SUPPRESS_WARNINGS_ANNOTATION_NAME;
- private final static String VALUE = "\"all\"";
+ private static final String SUPPRESS_WARNINGS_ANNOTATION_NAME = "SuppressWarnings";
+ private static final String SUPPRESS_WARNINGS_ANNOTATION_FQ_NAME = "java.lang." + SUPPRESS_WARNINGS_ANNOTATION_NAME;
+ private static final String VALUE = "\"all\"";
public static boolean isSuppressAllWarnings(DetailAST ast) {
DetailAST suppressWarningsAnnotation = getSuppressWarningsAnnotation(ast);
import org.apache.commons.lang.StringEscapeUtils;
public final class UnitTestResult {
- public final static String STATUS_OK = "ok";
- public final static String STATUS_ERROR = "error";
- public final static String STATUS_FAILURE = "failure";
- public final static String STATUS_SKIPPED = "skipped";
+ public static final String STATUS_OK = "ok";
+ public static final String STATUS_ERROR = "error";
+ public static final String STATUS_FAILURE = "failure";
+ public static final String STATUS_SKIPPED = "skipped";
private String name, status, stackTrace, message;
private long durationMilliseconds = 0L;
* Configuration parameters used by a CodeReader to handle some specificities.
*/
public class CodeReaderConfiguration {
-
+
/**
* @deprecated in 2.12, do not use anymore.
*/
@Deprecated
- public final static int DEFAULT_BUFFER_CAPACITY = 8000;
+ public static final int DEFAULT_BUFFER_CAPACITY = 8000;
- public final static int DEFAULT_TAB_WIDTH = 1;
+ public static final int DEFAULT_TAB_WIDTH = 1;
private int tabWidth = DEFAULT_TAB_WIDTH;
@Deprecated
public void setBufferCapacity(int bufferCapacity) {
}
-
+
/**
* @return the tabWidth
*/
/**
* Adds a code reader filter
- *
+ *
* @param codeReaderFilter
* the codeReaderFilter to add
*/
private final String tagBefore;
private final String tagAfter;
- private final static int DOT = '.';
+ private static final int DOT = '.';
public JavaConstantTokenizer(String tagBefore, String tagAfter) {
this.tagBefore = tagBefore;
*/
package org.sonar.colorizer;
+import org.sonar.channel.CodeReader;
+
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.sonar.channel.CodeReader;
-
/**
* Detect case-sensitive keywords
*/
private boolean caseInsensitive = false;
private Matcher matcher;
private final StringBuilder tmpBuilder = new StringBuilder();
- private final static String DEFAULT_REGEX = "[a-zA-Z_][a-zA-Z0-9_]*+";
+ private static final String DEFAULT_REGEX = "[a-zA-Z_][a-zA-Z0-9_]*+";
private Set<String> keywords = new HashSet<String>();
import org.apache.commons.lang.builder.ToStringStyle;
import javax.persistence.*;
+
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
@Table(name = SchemaMigration.TABLE_NAME, uniqueConstraints = {@UniqueConstraint(columnNames = {"version"})})
public class SchemaMigration {
- public final static int VERSION_UNKNOWN = -1;
+ public static final int VERSION_UNKNOWN = -1;
public static final int LAST_VERSION = 263;
public static final int VERSION_2_13 = 241;
- public final static String TABLE_NAME = "schema_migrations";
+ public static final String TABLE_NAME = "schema_migrations";
@Id
@Column(name = "version", updatable = true)
public static final String EOL = System.getProperty("line.separator", "\n");
- public static abstract class CodeLoader {
+ public abstract static class CodeLoader {
private SoftReference<List<String>> code;
public List<String> getCode() {
*/
public class TokenEntry implements Comparable<TokenEntry> {
- private final static Map<String, Integer> TOKENS = new HashMap<String, Integer>();
+ private static final Map<String, Integer> TOKENS = new HashMap<String, Integer>();
private static int tokenCount = 0;
/**
public class MatchAlgorithm {
- private final static int MOD = 37;
+ private static final int MOD = 37;
private int lastHash;
private int lastMod = 1;
cpdListener.phaseUpdate(CPDListener.DONE);
}
- @SuppressWarnings("PMD.JumbledIncrementer")
private Map<TokenEntry, Object> hash() {
Map<TokenEntry, Object> markGroups = new HashMap<TokenEntry, Object>(tokens.size());
for (int i = code.size() - 1; i >= 0; i--) {
*/
package org.sonar.duplications.detector.suffixtree;
-import java.util.*;
-
import com.google.common.collect.Lists;
+import java.util.*;
+
public final class Search {
private final SuffixTree tree;
reporter.endOfGroup();
}
- public static abstract class Collector {
+ public abstract static class Collector {
/**
* Invoked at the beginning of processing for current node.
* thus we guaranty that length will not increase between two sequential calls of this method
* (can be equal or less than previous value).
* </p>
- *
+ *
* @param size number of parts in group
* @param length length of each part in group
*/
/**
* Invoked as many times as leafs in the subtree, where current node is root.
- *
+ *
* @param start start position in generalised text
* @param end end position in generalised text
*/
import org.sonar.api.database.DatabaseSession;
import javax.persistence.*;
+
import java.util.Date;
/**
/**
* This status is set on the snapshot at the beginning of the batch
*/
- public final static String STATUS_UNPROCESSED = "U";
+ public static final String STATUS_UNPROCESSED = "U";
/**
* This status is set on the snapshot at the end of the batch
*/
- public final static String STATUS_PROCESSED = "P";
+ public static final String STATUS_PROCESSED = "P";
@Column(name = "project_id", updatable = true, nullable = true)
private Integer resourceId;
/**
* Default precision when saving a float type metric
*/
- public final static int DEFAULT_PRECISION = 1;
+ public static final int DEFAULT_PRECISION = 1;
private Long id; // for internal use
protected String metricKey;
/**
* Used for internal optimizations.
*/
- public static abstract class MetricFilter<M> implements MeasuresFilter<M> {
+ public abstract static class MetricFilter<M> implements MeasuresFilter<M> {
private final String metricKey;
protected MetricFilter(Metric metric) {
*/
package org.sonar.api.measures;
-import javax.persistence.Column;
-import javax.persistence.Entity;
-import javax.persistence.EnumType;
-import javax.persistence.Enumerated;
-import javax.persistence.GeneratedValue;
-import javax.persistence.Id;
-import javax.persistence.Table;
-import javax.persistence.Transient;
-
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.sonar.api.BatchExtension;
import org.sonar.api.ServerExtension;
+import javax.persistence.*;
+
/**
* This class represents the definition of a metric in Sonar.
- *
+ *
* @since 1.10
*/
@Table(name = "metrics")
/**
* A metric bigger value means a degradation
*/
- public final static int DIRECTION_WORST = -1;
+ public static final int DIRECTION_WORST = -1;
/**
* A metric bigger value means an improvement
*/
- public final static int DIRECTION_BETTER = 1;
+ public static final int DIRECTION_BETTER = 1;
/**
* The metric direction has no meaning
*/
- public final static int DIRECTION_NONE = 0;
+ public static final int DIRECTION_NONE = 0;
public enum ValueType {
INT, FLOAT, PERCENT, BOOL, STRING, MILLISEC, DATA, LEVEL, DISTRIB, RATING
}
/**
- * Metric.Builder is used to create metric definitions. It must be preferred to creating new instances of the Metric class directly.
- *
+ * Metric.Builder is used to create metric definitions. It must be preferred to creating new instances of the Metric class directly.
+ *
* @since 2.7
*/
public static final class Builder {
/**
* Creates a new {@link Builder} object.
- *
+ *
* @param key the metric key, should be unique among all metrics
* @param name the metric name
* @param type the metric type
/**
* Sets the metric description.
- *
+ *
* @param d the description
* @return the builder
*/
* @see Metric#DIRECTION_WORST
* @see Metric#DIRECTION_BETTER
* @see Metric#DIRECTION_NONE
- *
+ *
* @param d the direction
* @return the builder
*/
* Sets whether the metric is qualitative or not. Default value is false.
* <br/>
* If set to true, then variations of this metric will be highlighted in the Web UI (for instance, trend icons will be red or green instead of default grey).
- *
+ *
* @param b Boolean.TRUE if the metric is qualitative
* @return the builder
*/
* Sets the domain for the metric (General, Complexity...). This is used to group metrics in the Web UI.
* <br/>
* By default, the metric belongs to no specific domain.
- *
+ *
* @param d the domain
* @return the builder
*/
* <br/>
* When a formula is set, sensors/decorators just need to store measures at a specific level and let Sonar run the formula to store
* measures on the remaining levels.
- *
- * @see {@link SumChildDistributionFormula}, {@link SumChildValuesFormula}, {@link AverageComplexityFormula}, {@link MeanAggregationFormula},
+ *
+ * @see {@link SumChildDistributionFormula}, {@link SumChildValuesFormula}, {@link AverageComplexityFormula}, {@link MeanAggregationFormula},
* {@link WeightedMeanAggregationFormula}
- *
+ *
* @param f the formula
* @return the builder
*/
/**
* Sets the worst value that the metric can get (example: 0.0 for code coverage). No worst value is set by default.
- *
+ *
* @param d the worst value
* @return the builder
*/
* Sets the best value that the metric can get (example: 100.0 for code coverage). No best value is set by default.
* <br/>
* Resources would be hidden on drilldown page, if the value of measure equals to best value.
- *
+ *
* @param d the best value
* @return the builder
*/
/**
* Specifies whether file-level measures that equal to the defined best value are stored or not. Default is false.
* <br/>
- * Example with the metric that stores the number of violation ({@link CoreMetrics#VIOLATIONS}):
+ * Example with the metric that stores the number of violation ({@link CoreMetrics#VIOLATIONS}):
* if a file has no violation, then the value '0' won't be stored in the database.
- *
+ *
* @param b true if the measures must not be stored when they equal to the best value
* @return the builder
*/
/**
* Sets whether the metric should be hidden in Web UI (e.g. in Time Machine). Default is false.
- *
+ *
* @param b true if the metric should be hidden.
* @return the builder
*/
* Specifies whether this metric can be edited online in the "Manual measures" page. Default is false.
*
* @since 2.10
- *
+ *
* @param b true if the metric can be edited online.
- * @return the builder
+ * @return the builder
*/
public Builder setUserManaged(boolean b) {
this.userManaged = b;
* By default, historical data are kept.
*
* @since 2.14
- *
+ *
* @param b true if measures from the past can be deleted automatically.
* @return the builder
*/
/**
* Creates a new metric definition based on the properties set on this metric builder.
- *
+ *
* @return a new {@link Metric} object
*/
public Metric create() {
import org.sonar.check.Cardinality;
import javax.persistence.*;
+
import java.util.ArrayList;
import java.util.List;
@Table(name = "rules")
public final class Rule {
- private final static RulesCategory NONE = new RulesCategory("none");
+ private static final RulesCategory NONE = new RulesCategory("none");
@Id
@Column(name = "id")
// only static methods
}
- public static abstract class Converter<TYPE> {
+ public abstract static class Converter<TYPE> {
abstract String format(TYPE type);
abstract TYPE parse(String s);
class Line implements Measurable<Metric> {
+ private static final String NOSONAR_TAG = "NOSONAR";
+
private final int lineIndex;
private int blankLine = 0;
private int line = 1;
private boolean isBlank;
private boolean isThereJavadoc;
private boolean isThereLicenseHeaderComment;
- private final static String NOSONAR_TAG = "NOSONAR";
Line() {
this.lineIndex = 0;
public class ResourceQuery extends Query<Resource> {
public static final String BASE_URL = "/api/resources";
- public final static int DEPTH_UNLIMITED = -1;
+ public static final int DEPTH_UNLIMITED = -1;
private Integer depth;
private String resourceKeyOrId;