/**
* A pre-implementation for a sensor that imports sources
- *
+ *
* @since 1.10
*/
@Phase(name = Phase.Name.PRE)
public abstract class AbstractSourceImporter implements Sensor {
/**
- * @deprecated replaced by CoreProperties.CORE_IMPORT_SOURCES_PROPERTY since 1.11
+ * @deprecated in 1.11. Use {@link CoreProperties#CORE_IMPORT_SOURCES_PROPERTY} instead.
*/
@Deprecated
- public static final String KEY_IMPORT_SOURCES = "sonar.importSources";
+ public static final String KEY_IMPORT_SOURCES = CoreProperties.CORE_IMPORT_SOURCES_PROPERTY;
/**
- * @deprecated replaced by CoreProperties.CORE_IMPORT_SOURCES_DEFAULT_VALUE since 1.11
+ * @deprecated in 1.11. Use {@link CoreProperties#CORE_IMPORT_SOURCES_DEFAULT_VALUE} instead.
*/
@Deprecated
- public static final boolean DEFAULT_IMPORT_SOURCES = true;
+ public static final boolean DEFAULT_IMPORT_SOURCES = CoreProperties.CORE_IMPORT_SOURCES_DEFAULT_VALUE;
private Language language;
import org.sonar.api.database.BaseIdentifiable;
import org.sonar.api.database.model.Snapshot;
-import javax.persistence.*;
import java.util.Date;
+import javax.persistence.*;
+
/**
* @since 1.10
*/
this.category = category;
}
+ /**
+ * @deprecated in 2.5
+ */
@Deprecated
public Event(String name, String description, String category, Date date, Integer resourceId) {
this.name = name;
this.resourceId = resourceId;
}
+ /**
+ * @deprecated in 2.5
+ */
@Deprecated
public Event(String name, String description, String category, Snapshot snapshot) {
this.name = name;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.DuplicatedSourceException;
import org.sonar.api.resources.ProjectLink;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Violation;
/**
* Creates an empty metric
+ *
+ * @deprecated in 1.12
*/
@Deprecated
public Metric() {
public static final String DEFAULT_PACKAGE_NAME = "[default]";
/**
- * Defaul constructor
+ * Default constructor
*/
public JavaPackage() {
this(null);
}
/**
- * @return whether the JavaPackage key is the defult key
+ * @return whether the JavaPackage key is the default key
*/
public boolean isDefault() {
return StringUtils.equals(getKey(), DEFAULT_PACKAGE_NAME);
* @return SCOPE_SPACE
*/
public String getScope() {
- return Resource.SCOPE_SPACE;
+ return Scopes.DIRECTORY;
}
/**
* @return the scope of the current object
*/
public String getScope() {
- return SCOPE_SET;
+ return Scopes.PROJECT;
}
/**
* @return the qualifier of the current object
*/
public String getQualifier() {
- return isRoot() ? QUALIFIER_PROJECT : QUALIFIER_MODULE;
+ return isRoot() ? Qualifiers.PROJECT : Qualifiers.MODULE;
}
@Override
* @return whether the resource is a view
*/
public static boolean isView(Resource resource) {
- return isSet(resource) && Resource.QUALIFIER_VIEW.equals(resource.getQualifier());
+ return isSet(resource) && Qualifiers.VIEW.equals(resource.getQualifier());
}
/**
* @return whether the resource is a subview (in the view tree)
*/
public static boolean isSubview(Resource resource) {
- return isSet(resource) && Resource.QUALIFIER_SUBVIEW.equals(resource.getQualifier());
+ return isSet(resource) && Qualifiers.SUBVIEW.equals(resource.getQualifier());
}
/**
* @return whether the resource is the root project
*/
public static boolean isRootProject(Resource resource) {
- return Resource.QUALIFIER_PROJECT.equals(resource.getQualifier());
+ return Qualifiers.PROJECT.equals(resource.getQualifier());
}
/**
* @return whether a resource is a maven module of project
*/
public static boolean isModuleProject(Resource resource) {
- return Resource.QUALIFIER_MODULE.equals(resource.getQualifier());
+ return Qualifiers.MODULE.equals(resource.getQualifier());
}
/**
* @return whether a resource is a package
*/
public static boolean isPackage(Resource resource) {
- return resource != null && Resource.QUALIFIER_PACKAGE.equals(resource.getQualifier());
+ return resource != null && Qualifiers.PACKAGE.equals(resource.getQualifier());
}
/**
* @return whether a resource is a set
*/
public static boolean isSet(Resource resource) {
- return resource != null && Resource.SCOPE_SET.equals(resource.getScope());
+ return resource != null && Scopes.PROJECT.equals(resource.getScope());
}
/**
* @return whether a resource is a space
*/
public static boolean isSpace(Resource resource) {
- return resource != null && Resource.SCOPE_SPACE.equals(resource.getScope());
+ return resource != null && Scopes.DIRECTORY.equals(resource.getScope());
}
/**
* @return whether a resource is an entity.
*/
public static boolean isEntity(Resource resource) {
- return resource != null && Resource.SCOPE_ENTITY.equals(resource.getScope());
+ return resource != null && Scopes.FILE.equals(resource.getScope());
}
/**
* @return whether a resource is a class
*/
public static boolean isClass(Resource resource) {
- return Resource.QUALIFIER_CLASS.equals(resource.getQualifier());
+ return Qualifiers.CLASS.equals(resource.getQualifier());
}
/**
* @return whether a resource is a library
*/
public static boolean isLibrary(Resource resource) {
- return Resource.QUALIFIER_LIB.equals(resource.getQualifier());
+ return Qualifiers.LIBRARY.equals(resource.getQualifier());
}
/**
/**
* Parses and formats ISO 8601 dates. See http://en.wikipedia.org/wiki/ISO_8601.
* This class is thread-safe.
- *
+ *
* @since 2.7
*/
public final class DateUtils {
private static final ThreadSafeDateFormat dateFormat = new ThreadSafeDateFormat(DATE_FORMAT);
private static final ThreadSafeDateFormat dateTimeFormat = new ThreadSafeDateFormat(DATETIME_FORMAT);
+ private DateUtils() {
+ }
+
public static String formatDate(Date d) {
return dateFormat.format(d);
}
private final transient ThreadLocal cache = new ThreadLocal() {
public Object get() {
- Reference softRef = (Reference)super.get();
+ Reference softRef = (Reference) super.get();
if (softRef == null || softRef.get() == null) {
softRef = new SoftReference(new SimpleDateFormat(format));
super.set(softRef);
};
private DateFormat getDateFormat() {
- return (DateFormat) ((Reference)cache.get()).get();
+ return (DateFormat) ((Reference) cache.get()).get();
}
- public StringBuffer format(Date date,StringBuffer toAppendTo, FieldPosition fieldPosition) {
+ public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) {
return getDateFormat().format(date, toAppendTo, fieldPosition);
}
}
}
- public static interface ZipEntryFilter {
+ public interface ZipEntryFilter {
boolean accept(ZipEntry entry);
}
*/
package org.sonar.test;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.CharEncoding;
import org.apache.commons.lang.CharUtils;
import java.io.IOException;
import java.net.URL;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.*;
-
/**
* Utilities for unit tests
*
* @since 2.2
*/
-public class TestUtils {
+public final class TestUtils {
+
+ private TestUtils() {
+ }
/**
* Search for a test resource in the classpath. For example getResource("org/sonar/MyClass/foo.txt");
*/
public static File getResource(String path) {
String resourcePath = path;
- if ( !resourcePath.startsWith("/")) {
+ if (!resourcePath.startsWith("/")) {
resourcePath = "/" + resourcePath;
}
URL url = TestUtils.class.getResource(resourcePath);
*/
public static File getResource(Class baseClass, String path) {
String resourcePath = StringUtils.replaceChars(baseClass.getCanonicalName(), '.', '/');
- if ( !path.startsWith("/")) {
+ if (!path.startsWith("/")) {
resourcePath += "/";
}
resourcePath += path;
/**
* Create a temporary directory for unit tests.
+ *
* @param baseClass the unit test class
* @param testName the test name
* @param clean remove all the sub-directories and files ?
import org.sonar.channel.CodeReader;
-public class ChannelMatchers {
+public final class ChannelMatchers {
+
+ private ChannelMatchers() {
+ }
public static <OUTPUT> ChannelMatcher<OUTPUT> consume(String sourceCode, OUTPUT output) {
return new ChannelMatcher<OUTPUT>(sourceCode, output);
/**
* @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007
*/
+ @Deprecated
private String ruleCategory;
private Double variation1, variation2, variation3, variation4, variation5;