@DependedUpon
public List<Metric> generatesMetric() {
- return Arrays.asList(CoreMetrics.NEW_VIOLATIONS,
- CoreMetrics.NEW_BLOCKER_VIOLATIONS, CoreMetrics.NEW_CRITICAL_VIOLATIONS, CoreMetrics.NEW_MAJOR_VIOLATIONS, CoreMetrics.NEW_MINOR_VIOLATIONS, CoreMetrics.NEW_INFO_VIOLATIONS);
+ return Arrays.asList(
+ CoreMetrics.NEW_VIOLATIONS, CoreMetrics.NEW_BLOCKER_VIOLATIONS, CoreMetrics.NEW_CRITICAL_VIOLATIONS,
+ CoreMetrics.NEW_MAJOR_VIOLATIONS, CoreMetrics.NEW_MINOR_VIOLATIONS, CoreMetrics.NEW_INFO_VIOLATIONS);
}
public void decorate(Resource resource, DecoratorContext context) {
import org.sonar.api.measures.Metric;
import org.sonar.api.measures.MetricFinder;
import org.sonar.api.resources.Project;
+import org.sonar.api.resources.Qualifiers;
import org.sonar.api.resources.Resource;
import org.sonar.batch.index.DefaultIndex;
} else {
sb.append("SELECT s.createdAt, m.metricId, m.value ");
}
- sb.append(" FROM " + MeasureModel.class.getSimpleName() + " m, " + Snapshot.class.getSimpleName() + " s WHERE m.snapshotId=s.id AND s.resourceId=:resourceId AND s.status=:status AND m.characteristic IS NULL AND s.qualifier<>:lib");
+ sb.append(" FROM ")
+ .append(MeasureModel.class.getSimpleName())
+ .append(" m, ")
+ .append(Snapshot.class.getSimpleName())
+ .append(" s WHERE m.snapshotId=s.id AND s.resourceId=:resourceId AND s.status=:status AND m.characteristic IS NULL AND s.qualifier<>:lib");
params.put("resourceId", resource.getId());
params.put("status", Snapshot.STATUS_PROCESSED);
- params.put("lib", Project.QUALIFIER_LIB);
+ params.put("lib", Qualifiers.LIBRARY);
sb.append(" AND m.ruleId IS NULL AND m.rulePriority IS NULL ");
if (!metricIds.isEmpty()) {
// Deleting temp directory does not work on MS Windows and Sun JVM because URLClassLoader locks JARs and resources.
// The workaround is that sonar deletes orphans itself.
- rootDir.setLastModified(System.currentTimeMillis() - AGE_BEFORE_DELETION - 60 * 60 * 1000); // older than AGE_BEFORE_DELETION to be sure that the current dir is deleted on mac and linux.
+
+ // older than AGE_BEFORE_DELETION to be sure that the current dir is deleted on mac and linux.
+ rootDir.setLastModified(System.currentTimeMillis() - AGE_BEFORE_DELETION - 60 * 60 * 1000);
File[] directoriesToDelete = rootDir.getParentFile().listFiles((FileFilter) new AndFileFilter(Arrays.asList(
DirectoryFileFilter.DIRECTORY, new PrefixFileFilter(DIR_PREFIX), new AgeFileFilter(System.currentTimeMillis() - AGE_BEFORE_DELETION))));
import org.sonar.api.database.DatabaseSession;
import org.sonar.api.database.model.ResourceModel;
import org.sonar.api.database.model.Snapshot;
-import org.sonar.api.resources.Library;
-import org.sonar.api.resources.Project;
-import org.sonar.api.resources.Resource;
-import org.sonar.api.resources.ResourceUtils;
+import org.sonar.api.resources.*;
import org.sonar.api.utils.SonarException;
import javax.persistence.NonUniqueResultException;
// see http://jira.codehaus.org/browse/SONAR-1850
// The qualifier must be LIB, even if the resource is TRK, because this snapshot has no measures.
- snapshot.setQualifier(Resource.QUALIFIER_LIB);
+ snapshot.setQualifier(Qualifiers.LIBRARY);
snapshot = session.save(snapshot);
}
session.commit();
}
private Snapshot findLibrarySnapshot(Integer resourceId, String version) {
- Query query = session.createQuery("from " + Snapshot.class.getSimpleName() + " s WHERE s.resourceId=:resourceId AND s.version=:version AND s.scope=:scope AND s.qualifier<>:qualifier AND s.last=:last");
+ Query query = session.createQuery("from " + Snapshot.class.getSimpleName() +
+ " s WHERE s.resourceId=:resourceId AND s.version=:version AND s.scope=:scope AND s.qualifier<>:qualifier AND s.last=:last");
query.setParameter("resourceId", resourceId);
query.setParameter("version", version);
query.setParameter("scope", Resource.SCOPE_SET);
query.setParameter("last", Boolean.TRUE);
List<Snapshot> snapshots = query.getResultList();
if (snapshots.isEmpty()) {
- snapshots = session.getResults(Snapshot.class, "resourceId", resourceId, "version", version, "scope", Resource.SCOPE_SET, "qualifier", Resource.QUALIFIER_LIB);
+ snapshots = session.getResults(Snapshot.class, "resourceId", resourceId, "version", version, "scope", Scopes.PROJECT, "qualifier", Qualifiers.LIBRARY);
}
return (snapshots.isEmpty() ? null : snapshots.get(0));
}
* <ol>
* <li>deleteOnExit() only deletes for normal JVM shutdowns, not crashes or killing the JVM process</li>
* <li>deleteOnExit() only deletes on JVM shutdown - not good for long running server processes because 3 :</li>
- * <li>The most evil of all - deleteOnExit() consumes memory for each temp file entry. If your process is running for months, or creates a lot of temp files in a short time, you consume memory and never release it until the JVM shuts down.</li>
+ * <li>The most evil of all - deleteOnExit() consumes memory for each temp file entry. If your process is running for months,
+ * or creates a lot of temp files in a short time, you consume memory and never release it until the JVM
+ * shuts down.</li>
* </ol>
*/
public static File createTempDirectory() throws IOException {