@@ -280,6 +280,7 @@ import java.util.List; | |||
public final class CorePlugin extends SonarPlugin { | |||
@SuppressWarnings("rawtypes") | |||
@Override | |||
public List getExtensions() { | |||
ImmutableList.Builder<Object> extensions = ImmutableList.builder(); | |||
@@ -28,6 +28,7 @@ import java.util.List; | |||
public final class UserManagedMetrics implements Metrics { | |||
private static final String DOMAIN = "Management"; | |||
@Override | |||
public List<Metric> getMetrics() { | |||
return ImmutableList.<Metric>of( | |||
new Metric.Builder("burned_budget", "Burned budget", Metric.ValueType.FLOAT) |
@@ -36,6 +36,7 @@ public class IndexProjectPostJob implements PostJob { | |||
this.indexer = indexer; | |||
} | |||
@Override | |||
public void executeOn(Project project, SensorContext context) { | |||
if (project.getId() != null) { | |||
indexer.indexProject(project.getId()); |
@@ -34,6 +34,7 @@ import java.text.NumberFormat; | |||
public class DistributionAreaChart extends AbstractChart { | |||
private static final String PARAM_COLORS = "c"; | |||
@Override | |||
public String getKey() { | |||
return "distarea"; | |||
} |
@@ -41,6 +41,7 @@ public class DistributionBarChart extends AbstractChart { | |||
public static final String PARAM_X_SUFFIX = "xsuf"; | |||
public static final String PARAM_FONT_SIZE = "fs"; | |||
@Override | |||
public String getKey() { | |||
return "distbar"; | |||
} |
@@ -41,6 +41,7 @@ public class XradarChart extends AbstractChart { | |||
public static final String PARAM_LABELS = "l"; | |||
public static final String PARAM_VALUES = "v"; | |||
@Override | |||
public String getKey() { | |||
return "xradar"; | |||
} |
@@ -43,6 +43,7 @@ public class CountFalsePositivesDecorator implements Decorator { | |||
this.perspectives = perspectives; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -52,6 +53,7 @@ public class CountFalsePositivesDecorator implements Decorator { | |||
return CoreMetrics.FALSE_POSITIVE_ISSUES; | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
Issuable issuable = perspectives.as(Issuable.class, resource); | |||
if (issuable != null) { |
@@ -78,6 +78,7 @@ public class CountUnresolvedIssuesDecorator implements Decorator { | |||
this.timeMachineConfiguration = timeMachineConfiguration; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -103,6 +104,7 @@ public class CountUnresolvedIssuesDecorator implements Decorator { | |||
); | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
Issuable issuable = perspectives.as(Issuable.class, resource); | |||
if (issuable != null) { |
@@ -336,6 +336,7 @@ public class IssueTracking implements BatchExtension { | |||
} | |||
private static final Comparator<LinePair> LINE_PAIR_COMPARATOR = new Comparator<LinePair>() { | |||
@Override | |||
public int compare(LinePair o1, LinePair o2) { | |||
int weightDiff = o2.weight - o1.weight; | |||
if (weightDiff != 0) { |
@@ -90,10 +90,12 @@ public class IssueTrackingDecorator implements Decorator { | |||
this.ruleFinder = ruleFinder; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
Issuable issuable = perspectives.as(Issuable.class, resource); | |||
if (issuable != null) { |
@@ -51,6 +51,7 @@ public final class HashedSequence<S extends Sequence> implements Sequence { | |||
return new HashedSequence<S>(base, hashes, linesByHash); | |||
} | |||
@Override | |||
public int length() { | |||
return base.length(); | |||
} |
@@ -30,6 +30,7 @@ public class HashedSequenceComparator<S extends Sequence> implements SequenceCom | |||
this.cmp = cmp; | |||
} | |||
@Override | |||
public boolean equals(HashedSequence<S> a, int ai, HashedSequence<S> b, int bi) { | |||
if (a.hashes[ai] == b.hashes[bi]) { | |||
return cmp.equals(a.base, ai, b.base, bi); | |||
@@ -37,6 +38,7 @@ public class HashedSequenceComparator<S extends Sequence> implements SequenceCom | |||
return false; | |||
} | |||
@Override | |||
public int hash(HashedSequence<S> seq, int i) { | |||
return seq.hashes[i]; | |||
} |
@@ -55,6 +55,7 @@ public class RollingHashSequence<S extends Sequence> implements Sequence { | |||
this.hashes = hashes; | |||
} | |||
@Override | |||
public int length() { | |||
return base.length(); | |||
} |
@@ -30,6 +30,7 @@ public class RollingHashSequenceComparator<S extends Sequence> implements Sequen | |||
this.cmp = cmp; | |||
} | |||
@Override | |||
public boolean equals(RollingHashSequence<S> a, int ai, RollingHashSequence<S> b, int bi) { | |||
if (a.hashes[ai] == b.hashes[bi]) { | |||
return cmp.equals(a.base, ai, b.base, bi); | |||
@@ -37,6 +38,7 @@ public class RollingHashSequenceComparator<S extends Sequence> implements Sequen | |||
return false; | |||
} | |||
@Override | |||
public int hash(RollingHashSequence<S> seq, int i) { | |||
return seq.hashes[i]; | |||
} |
@@ -40,6 +40,7 @@ public class StringText implements Sequence { | |||
this.lines = lineMap(content, 0, content.length()); | |||
} | |||
@Override | |||
public int length() { | |||
return lines.size() - 2; | |||
} |
@@ -29,6 +29,7 @@ public abstract class StringTextComparator implements SequenceComparator<StringT | |||
*/ | |||
public static final StringTextComparator IGNORE_WHITESPACE = new StringTextComparator() { | |||
@Override | |||
public boolean equals(StringText a, int ai, StringText b, int bi) { | |||
ai++; | |||
bi++; | |||
@@ -72,6 +73,7 @@ public abstract class StringTextComparator implements SequenceComparator<StringT | |||
}; | |||
@Override | |||
public int hash(StringText seq, int line) { | |||
final int begin = seq.lines.get(line + 1); | |||
final int end = seq.lines.get(line + 2); |
@@ -41,10 +41,12 @@ public class ApplyProjectRolesDecorator implements Decorator { | |||
this.resourcePermissions = resourcePermissions; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (shouldDecorateResource(resource)) { | |||
LoggerFactory.getLogger(ApplyProjectRolesDecorator.class).info("Grant default permissions to {}", resource.getKey()); |
@@ -33,6 +33,7 @@ import java.util.Collection; | |||
public abstract class AbstractCoverageDecorator implements Decorator { | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -42,6 +43,7 @@ public abstract class AbstractCoverageDecorator implements Decorator { | |||
return Arrays.asList(getGeneratedMetric(), getGeneratedMetricForNewCode()); | |||
} | |||
@Override | |||
public void decorate(final Resource resource, final DecoratorContext context) { | |||
if (shouldDecorate(resource)) { | |||
computeMeasure(context); |
@@ -45,10 +45,12 @@ public class CommentDensityDecorator implements Decorator { | |||
return Arrays.<Metric>asList(CoreMetrics.COMMENT_LINES_DENSITY, CoreMetrics.PUBLIC_DOCUMENTED_API_DENSITY); | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
saveCommentsDensity(context); | |||
savePublicApiDensity(context); |
@@ -37,6 +37,7 @@ import java.util.Collection; | |||
*/ | |||
public final class DirectoriesDecorator implements Decorator { | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -49,6 +50,7 @@ public final class DirectoriesDecorator implements Decorator { | |||
/** | |||
* {@inheritDoc} | |||
*/ | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (MeasureUtils.hasValue(context.getMeasure(CoreMetrics.DIRECTORIES))) { | |||
return; |
@@ -51,6 +51,7 @@ public final class FileHashSensor implements Sensor { | |||
this.componentDataCache = componentDataCache; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} |
@@ -36,6 +36,7 @@ import java.util.Collection; | |||
*/ | |||
public final class FilesDecorator implements Decorator { | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -45,6 +46,7 @@ public final class FilesDecorator implements Decorator { | |||
return CoreMetrics.FILES; | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (MeasureUtils.hasValue(context.getMeasure(CoreMetrics.FILES))) { | |||
return; |
@@ -43,10 +43,12 @@ public class ManualMeasureDecorator implements Decorator { | |||
this.metricFinder = metricFinder; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (resource.getId() != null) { | |||
List<ManualMeasure> manualMeasures = session.getResults(ManualMeasure.class, "resourceId", resource.getId()); |
@@ -40,10 +40,12 @@ public class ProjectLinksSensor implements Sensor { | |||
this.defaultI18n = defaultI18n; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@Override | |||
public void analyse(Project project, SensorContext context) { | |||
handleLink(context, CoreProperties.LINKS_HOME_PAGE); | |||
handleLink(context, CoreProperties.LINKS_CI); |
@@ -41,6 +41,7 @@ public class UnitTestDecorator implements Decorator { | |||
return Arrays.<Metric>asList(CoreMetrics.TEST_EXECUTION_TIME, CoreMetrics.TESTS, CoreMetrics.TEST_ERRORS, CoreMetrics.TEST_FAILURES, CoreMetrics.TEST_SUCCESS_DENSITY); | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return !Project.AnalysisType.STATIC.equals(project.getAnalysisType()); | |||
} | |||
@@ -49,6 +50,7 @@ public class UnitTestDecorator implements Decorator { | |||
return ResourceUtils.isUnitTestClass(resource) || !ResourceUtils.isEntity(resource); | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (shouldDecorateResource(resource)) { | |||
sumChildren(context, CoreMetrics.TEST_EXECUTION_TIME); |
@@ -31,10 +31,12 @@ import java.util.Iterator; | |||
@DryRunIncompatible | |||
public class VersionEventsSensor implements Sensor { | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@Override | |||
public void analyse(Project project, SensorContext context) { | |||
if (StringUtils.isBlank(project.getAnalysisVersion())) { | |||
return; |
@@ -76,6 +76,7 @@ public abstract class AbstractNewCoverageFileAnalyzer implements Decorator { | |||
public abstract Metric getNewUncoveredConditionsMetric(); | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return !structs.isEmpty(); | |||
} | |||
@@ -96,6 +97,7 @@ public abstract class AbstractNewCoverageFileAnalyzer implements Decorator { | |||
return Arrays.asList(getNewLinesToCoverMetric(), getNewUncoveredLinesMetric(), getNewConditionsToCoverMetric(), getNewUncoveredConditionsMetric()); | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (shouldDecorate(resource)) { | |||
doDecorate(context); |
@@ -38,6 +38,7 @@ import java.util.List; | |||
@DependedUpon(DecoratorBarriers.END_OF_TIME_MACHINE) | |||
public final class NewCoverageAggregator implements Decorator { | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -50,6 +51,7 @@ public final class NewCoverageAggregator implements Decorator { | |||
CoreMetrics.NEW_OVERALL_LINES_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_LINES, CoreMetrics.NEW_OVERALL_CONDITIONS_TO_COVER, CoreMetrics.NEW_OVERALL_UNCOVERED_CONDITIONS); | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (shouldDecorate(resource)) { | |||
int maxPeriods = Qualifiers.isView(resource, true) ? 3 : 5; |
@@ -94,10 +94,12 @@ public class TendencyDecorator implements Decorator { | |||
return query; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (shouldDecorateResource(resource)) { | |||
resetQuery(context.getProject(), resource); |
@@ -46,6 +46,7 @@ public final class TimeMachineConfigurationPersister implements Decorator { | |||
this.session = session; | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (ResourceUtils.isProject(resource)) { | |||
persistConfiguration(); | |||
@@ -63,6 +64,7 @@ public final class TimeMachineConfigurationPersister implements Decorator { | |||
session.commit(); | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} |
@@ -67,6 +67,7 @@ public class VariationDecorator implements Decorator { | |||
this.ruleFinder = ruleFinder; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -76,6 +77,7 @@ public class VariationDecorator implements Decorator { | |||
return pastMeasuresLoader.getMetrics(); | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
for (PastSnapshot projectPastSnapshot : projectPastSnapshots) { | |||
if (shouldComputeVariation(resource)) { |
@@ -31,10 +31,12 @@ public abstract class CoreWidget extends AbstractRubyTemplate implements RubyRai | |||
this.templatePath = templatePath; | |||
} | |||
@Override | |||
public String getId() { | |||
return id; | |||
} | |||
@Override | |||
public String getTitle() { | |||
return title; | |||
} |
@@ -33,6 +33,7 @@ import java.util.List; | |||
public final class CpdPlugin extends SonarPlugin { | |||
@Override | |||
public List getExtensions() { | |||
return ImmutableList.of( | |||
PropertyDefinition.builder(CoreProperties.CPD_CROSS_PROJECT) |
@@ -183,6 +183,7 @@ public class JavaCpdEngine extends CpdEngine { | |||
this.fileBlocks = fileBlocks; | |||
} | |||
@Override | |||
public List<CloneGroup> call() { | |||
return SuffixTreeCloneDetectionAlgorithm.detect(index, fileBlocks); | |||
} |
@@ -48,10 +48,12 @@ public class DuplicationDensityDecorator implements Decorator { | |||
return CoreMetrics.DUPLICATED_LINES_DENSITY; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
Measure nbDuplicatedLines = context.getMeasure(CoreMetrics.DUPLICATED_LINES); | |||
if (nbDuplicatedLines == null) { |
@@ -59,6 +59,7 @@ public class SonarDuplicationsIndex extends AbstractCloneIndex { | |||
return mem.getByResourceId(resourceKey); | |||
} | |||
@Override | |||
public Collection<Block> getBySequenceHash(ByteArray hash) { | |||
if (db == null) { | |||
return mem.getBySequenceHash(hash); | |||
@@ -69,10 +70,12 @@ public class SonarDuplicationsIndex extends AbstractCloneIndex { | |||
} | |||
} | |||
@Override | |||
public Collection<Block> getByResourceId(String resourceId) { | |||
throw new UnsupportedOperationException(); | |||
} | |||
@Override | |||
public void insert(Block block) { | |||
throw new UnsupportedOperationException(); | |||
} |
@@ -33,6 +33,7 @@ import java.util.List; | |||
public final class DbCleanerPlugin extends SonarPlugin { | |||
@Override | |||
public List getExtensions() { | |||
return ImmutableList.builder().add(DefaultPeriodCleaner.class, DefaultPurgeTask.class, ProjectPurgePostJob.class) | |||
.addAll(propertyDefinitions()).build(); |
@@ -50,11 +50,13 @@ public class DefaultPurgeTask implements PurgeTask { | |||
this.profiler = profiler; | |||
} | |||
@Override | |||
public PurgeTask delete(long resourceId) { | |||
purgeDao.deleteResourceTree(resourceId); | |||
return this; | |||
} | |||
@Override | |||
public PurgeTask purge(long resourceId) { | |||
long start = System.currentTimeMillis(); | |||
profiler.reset(); |
@@ -34,6 +34,7 @@ public class ProjectPurgePostJob implements PostJob { | |||
this.purgeTask = purgeTask; | |||
} | |||
@Override | |||
public void executeOn(final Project project, SensorContext context) { | |||
purgeTask.purge(project.getId()); | |||
} |
@@ -25,6 +25,7 @@ import org.sonar.api.SonarPlugin; | |||
import java.util.List; | |||
public class EmailNotificationsPlugin extends SonarPlugin { | |||
@Override | |||
public List getExtensions() { | |||
return ImmutableList.of( | |||
EmailNotificationChannel.class, |
@@ -63,6 +63,7 @@ public class GitBlameConsumer implements StreamConsumer { | |||
this.filename = filename; | |||
} | |||
@Override | |||
public void consumeLine(String line) { | |||
if (line == null) { | |||
return; |
@@ -34,6 +34,7 @@ public final class GitPlugin extends SonarPlugin { | |||
static final String JGIT = "jgit"; | |||
static final String EXE = "exe"; | |||
@Override | |||
public List getExtensions() { | |||
return ImmutableList.of( | |||
GitScmProvider.class, |
@@ -27,6 +27,7 @@ import java.util.List; | |||
public final class EnglishPackPlugin extends SonarPlugin { | |||
@Override | |||
public List getExtensions() { | |||
return Collections.emptyList(); | |||
} |
@@ -83,6 +83,7 @@ public class SvnBlameCommand implements BlameCommand, BatchComponent { | |||
private Future<Void> submitTask(final FileSystem fs, final BlameResult result, ExecutorService executorService, final InputFile inputFile) { | |||
return executorService.submit(new Callable<Void>() { | |||
@Override | |||
public Void call() { | |||
blame(fs, inputFile, result); | |||
return null; |
@@ -27,6 +27,7 @@ import java.util.List; | |||
public final class SvnPlugin extends SonarPlugin { | |||
@Override | |||
public List getExtensions() { | |||
List result = new ArrayList(); | |||
result.addAll(ImmutableList.of( |
@@ -70,6 +70,7 @@ class ComponentsFinderSort { | |||
@Override | |||
Function sortFieldFunction() { | |||
return new Function<Component, String>() { | |||
@Override | |||
public String apply(Component component) { | |||
return sortField(component); | |||
} |
@@ -110,6 +110,7 @@ public class ComponentDao extends BaseDao<ComponentMapper, ComponentDto, String> | |||
return components; | |||
} | |||
@Override | |||
protected List<ComponentDto> doGetByKeys(DbSession session, Collection<String> keys) { | |||
return mapper(session).findByKeys(keys); | |||
} |
@@ -152,11 +152,13 @@ public abstract class BaseDao<MAPPER, DTO extends Dto<KEY>, KEY extends Serializ | |||
return session.getMapper(mapperClass); | |||
} | |||
@Override | |||
@CheckForNull | |||
public DTO getNullableByKey(DbSession session, KEY key) { | |||
return doGetNullableByKey(session, key); | |||
} | |||
@Override | |||
public DTO getByKey(DbSession session, KEY key) { | |||
DTO value = doGetNullableByKey(session, key); | |||
if (value == null) { |
@@ -45,10 +45,12 @@ public class DebtModelService implements DebtModel { | |||
this.debtModelBackup = debtModelBackup; | |||
} | |||
@Override | |||
public List<DebtCharacteristic> characteristics() { | |||
return debtModelLookup.rootCharacteristics(); | |||
} | |||
@Override | |||
public List<DebtCharacteristic> allCharacteristics() { | |||
return debtModelLookup.allCharacteristics(); | |||
} | |||
@@ -58,6 +60,7 @@ public class DebtModelService implements DebtModel { | |||
return debtModelLookup.characteristicById(id); | |||
} | |||
@Override | |||
@CheckForNull | |||
public DebtCharacteristic characteristicByKey(String key) { | |||
return debtModelLookup.characteristicByKey(key); |
@@ -239,6 +239,7 @@ public class DebtModelXMLExporter implements ServerComponent { | |||
private List<DebtCharacteristic> sortByOrder(List<DebtCharacteristic> characteristics) { | |||
Collections.sort(characteristics, new Ordering<DebtCharacteristic>() { | |||
@Override | |||
public int compare(@Nullable DebtCharacteristic left, @Nullable DebtCharacteristic right) { | |||
if (left == null || left.order() == null || right == null || right.order() == null) { | |||
return -1; | |||
@@ -251,6 +252,7 @@ public class DebtModelXMLExporter implements ServerComponent { | |||
private List<DebtCharacteristic> sortByName(List<DebtCharacteristic> characteristics) { | |||
Collections.sort(characteristics, new Ordering<DebtCharacteristic>() { | |||
@Override | |||
public int compare(@Nullable DebtCharacteristic left, @Nullable DebtCharacteristic right) { | |||
if (left == null || right == null) { | |||
return -1; |
@@ -28,10 +28,12 @@ import org.sonar.api.web.WidgetCategory; | |||
@WidgetCategory({"Design"}) | |||
public final class FileDesignWidget extends AbstractRubyTemplate implements RubyRailsWidget { | |||
@Override | |||
public String getId() { | |||
return "file_design"; | |||
} | |||
@Override | |||
public String getTitle() { | |||
return "File design"; | |||
} |
@@ -28,10 +28,12 @@ import org.sonar.api.web.WidgetCategory; | |||
@WidgetCategory({"Design"}) | |||
public final class PackageDesignWidget extends AbstractRubyTemplate implements RubyRailsWidget { | |||
@Override | |||
public String getId() { | |||
return "package_design"; | |||
} | |||
@Override | |||
public String getTitle() { | |||
return "File design"; | |||
} |
@@ -87,6 +87,7 @@ class IssuesFinderSort { | |||
@Override | |||
Function sortFieldFunction() { | |||
return new Function<IssueDto, String>() { | |||
@Override | |||
public String apply(IssueDto issueDto) { | |||
return sortField(issueDto); | |||
} | |||
@@ -123,6 +124,7 @@ class IssuesFinderSort { | |||
@Override | |||
Function sortFieldFunction() { | |||
return new Function<IssueDto, Integer>() { | |||
@Override | |||
public Integer apply(IssueDto issueDto) { | |||
return Severity.ALL.indexOf(issueDto.getSeverity()); | |||
} | |||
@@ -143,6 +145,7 @@ class IssuesFinderSort { | |||
@Override | |||
Function sortFieldFunction() { | |||
return new Function<IssueDto, Date>() { | |||
@Override | |||
public Date apply(IssueDto issueDto) { | |||
return sortField(issueDto); | |||
} |
@@ -42,6 +42,7 @@ public class ServerIssueStorage extends IssueStorage implements ServerComponent | |||
this.dbClient = dbClient; | |||
} | |||
@Override | |||
protected void doInsert(DbSession session, Date now, DefaultIssue issue) { | |||
long componentId = componentId(session, issue); | |||
long projectId = projectId(session, issue); | |||
@@ -51,6 +52,7 @@ public class ServerIssueStorage extends IssueStorage implements ServerComponent | |||
dbClient.issueDao().insert(session, dto); | |||
} | |||
@Override | |||
protected void doUpdate(DbSession session, Date now, DefaultIssue issue) { | |||
IssueDto dto = IssueDto.toDtoForUpdate(issue, projectId(session, issue), now); | |||
@@ -52,6 +52,7 @@ public class IssueDao extends BaseDao<IssueMapper, IssueDto, String> implements | |||
return mapper(session).selectByKey(key); | |||
} | |||
@Override | |||
protected List<IssueDto> doGetByKeys(DbSession session, Collection<String> keys) { | |||
return mapper(session).selectByKeys(keys); | |||
} |
@@ -244,20 +244,24 @@ class MeasureFilterSql { | |||
} | |||
static class TextSortRowProcessor extends RowProcessor { | |||
@Override | |||
MeasureFilterRow fetch(ResultSet rs) throws SQLException { | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); | |||
row.setSortText(rs.getString(4)); | |||
return row; | |||
} | |||
@Override | |||
Function sortFieldFunction() { | |||
return new Function<MeasureFilterRow, String>() { | |||
@Override | |||
public String apply(MeasureFilterRow row) { | |||
return row.getSortText(); | |||
} | |||
}; | |||
} | |||
@Override | |||
Ordering sortFieldOrdering(boolean ascending) { | |||
Ordering<String> ordering = Ordering.from(String.CASE_INSENSITIVE_ORDER); | |||
if (!ascending) { | |||
@@ -268,8 +272,10 @@ class MeasureFilterSql { | |||
} | |||
static class AlertSortRowProcessor extends TextSortRowProcessor { | |||
@Override | |||
Function sortFieldFunction() { | |||
return new Function<MeasureFilterRow, Integer>() { | |||
@Override | |||
public Integer apply(MeasureFilterRow row) { | |||
return ImmutableList.of("OK", "WARN", "ERROR").indexOf(row.getSortText()); | |||
} | |||
@@ -287,6 +293,7 @@ class MeasureFilterSql { | |||
} | |||
static class NumericSortRowProcessor extends RowProcessor { | |||
@Override | |||
MeasureFilterRow fetch(ResultSet rs) throws SQLException { | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); | |||
double value = rs.getDouble(4); | |||
@@ -296,34 +303,41 @@ class MeasureFilterSql { | |||
return row; | |||
} | |||
@Override | |||
Function sortFieldFunction() { | |||
return new Function<MeasureFilterRow, Double>() { | |||
@Override | |||
public Double apply(MeasureFilterRow row) { | |||
return row.getSortDouble(); | |||
} | |||
}; | |||
} | |||
@Override | |||
Ordering sortFieldOrdering(boolean ascending) { | |||
return ascending ? Ordering.natural().nullsLast() : Ordering.natural().reverse().nullsLast(); | |||
} | |||
} | |||
static class DateSortRowProcessor extends RowProcessor { | |||
@Override | |||
MeasureFilterRow fetch(ResultSet rs) throws SQLException { | |||
MeasureFilterRow row = new MeasureFilterRow(rs.getLong(1), rs.getLong(2), rs.getLong(3)); | |||
row.setSortDate(rs.getTimestamp(4)); | |||
return row; | |||
} | |||
@Override | |||
Function sortFieldFunction() { | |||
return new Function<MeasureFilterRow, Timestamp>() { | |||
@Override | |||
public Timestamp apply(MeasureFilterRow row) { | |||
return row.getSortDate(); | |||
} | |||
}; | |||
} | |||
@Override | |||
Ordering sortFieldOrdering(boolean ascending) { | |||
return newObjectOrdering(ascending); | |||
} | |||
@@ -332,6 +346,7 @@ class MeasureFilterSql { | |||
private static Ordering newObjectOrdering(boolean ascending) { | |||
if (ascending) { | |||
return Ordering.from(new Comparator<Comparable>() { | |||
@Override | |||
public int compare(@Nullable Comparable left, @Nullable Comparable right) { | |||
if (left == null) { | |||
return 1; | |||
@@ -345,6 +360,7 @@ class MeasureFilterSql { | |||
}); | |||
} | |||
return Ordering.from(new Comparator<Comparable>() { | |||
@Override | |||
public int compare(@Nullable Comparable left, @Nullable Comparable right) { | |||
if (left == null) { | |||
return 1; |
@@ -25,6 +25,7 @@ import org.sonar.api.server.ws.WebService; | |||
public class ManualMeasuresWs implements WebService { | |||
@Override | |||
public void define(Context context) { | |||
NewController controller = context.createController("api/manual_measures"); | |||
controller.setDescription("Manual measures management"); |
@@ -100,6 +100,7 @@ public class NotificationService implements ServerComponent { | |||
public void start() { | |||
executorService = Executors.newSingleThreadScheduledExecutor(); | |||
executorService.scheduleWithFixedDelay(new Runnable() { | |||
@Override | |||
public void run() { | |||
try { | |||
processQueue(); | |||
@@ -167,10 +168,12 @@ public class NotificationService implements ServerComponent { | |||
final SetMultimap<String, NotificationChannel> recipients = HashMultimap.create(); | |||
for (NotificationDispatcher dispatcher : dispatchers) { | |||
NotificationDispatcher.Context context = new NotificationDispatcher.Context() { | |||
@Override | |||
public void addUser(String username) { | |||
// This method is not used anymore | |||
} | |||
@Override | |||
public void addUser(String userLogin, NotificationChannel notificationChannel) { | |||
if (userLogin != null) { | |||
recipients.put(userLogin, notificationChannel); |
@@ -71,6 +71,7 @@ class ClassLoaderUtils { | |||
*/ | |||
static Collection<String> listFiles(ClassLoader classLoader, String rootPath) { | |||
return listResources(classLoader, rootPath, new Predicate<String>() { | |||
@Override | |||
public boolean apply(@Nullable String path) { | |||
return !StringUtils.endsWith(path, "/"); | |||
} |
@@ -30,6 +30,7 @@ import java.util.Properties; | |||
public final class PlatformServletContextListener implements ServletContextListener { | |||
@Override | |||
public void contextInitialized(ServletContextEvent event) { | |||
try { | |||
Properties props = new Properties(); | |||
@@ -59,6 +60,7 @@ public final class PlatformServletContextListener implements ServletContextListe | |||
} | |||
} | |||
@Override | |||
public void contextDestroyed(ServletContextEvent event) { | |||
Platform.getInstance().doStop(); | |||
} |
@@ -90,6 +90,7 @@ public class RailsAppsDeployer implements Startable { | |||
LOG.info("Deploy app: " + pluginKey); | |||
File appDir = new File(appsDir, pluginKey); | |||
ClassLoaderUtils.copyResources(appClassLoader, pathToRubyInitFile(pluginKey), appDir, new Function<String, String>() { | |||
@Override | |||
public String apply(@Nullable String relativePath) { | |||
// Relocate the deployed files : | |||
// relativePath format is: org/sonar/ror/sqale/app/controllers/foo_controller.rb |
@@ -54,6 +54,7 @@ public class ServerPluginJarInstaller extends PluginJarInstaller { | |||
} | |||
private static final class LibFilter implements ZipUtils.ZipEntryFilter { | |||
@Override | |||
public boolean accept(ZipEntry entry) { | |||
return entry.getName().startsWith("META-INF/lib"); | |||
} |
@@ -75,6 +75,7 @@ public class QProfileActivity extends ActivityDoc implements Activity { | |||
return RuleKey.parse((String) getField("ruleKey")); | |||
} | |||
@Override | |||
@CheckForNull | |||
public String login() { | |||
return getNullableField(ActivityNormalizer.LogFields.LOGIN.field()); |
@@ -184,6 +184,7 @@ public class RegisterQualityProfiles implements ServerComponent { | |||
private static Map<String, Collection<RulesProfile>> profilesByName(List<RulesProfile> profiles) { | |||
return Multimaps.index(profiles, new Function<RulesProfile, String>() { | |||
@Override | |||
public String apply(@Nullable RulesProfile profile) { | |||
return profile != null ? profile.getName() : null; | |||
} |
@@ -50,6 +50,7 @@ public class DefaultRuleFinder implements RuleFinder { | |||
this.index = indexes.get(RuleIndex.class); | |||
} | |||
@Override | |||
@CheckForNull | |||
public org.sonar.api.rules.Rule findById(int ruleId) { | |||
Rule rule = index.getById(ruleId); | |||
@@ -81,6 +82,7 @@ public class DefaultRuleFinder implements RuleFinder { | |||
return rules; | |||
} | |||
@Override | |||
@CheckForNull | |||
public org.sonar.api.rules.Rule findByKey(RuleKey key) { | |||
Rule rule = index.getNullableByKey(key); | |||
@@ -91,11 +93,13 @@ public class DefaultRuleFinder implements RuleFinder { | |||
} | |||
} | |||
@Override | |||
@CheckForNull | |||
public org.sonar.api.rules.Rule findByKey(String repositoryKey, String key) { | |||
return findByKey(RuleKey.of(repositoryKey, key)); | |||
} | |||
@Override | |||
public final org.sonar.api.rules.Rule find(org.sonar.api.rules.RuleQuery query) { | |||
Result<Rule> result = index.search(toQuery(query), new QueryContext()); | |||
if (!result.getHits().isEmpty()) { | |||
@@ -105,6 +109,7 @@ public class DefaultRuleFinder implements RuleFinder { | |||
} | |||
} | |||
@Override | |||
public final Collection<org.sonar.api.rules.Rule> findAll(org.sonar.api.rules.RuleQuery query) { | |||
List<org.sonar.api.rules.Rule> rules = newArrayList(); | |||
for (Rule rule : index.search(toQuery(query), new QueryContext()).getHits()) { |
@@ -76,6 +76,7 @@ public class RuleIndex extends BaseIndex<Rule, RuleDto, RuleKey> { | |||
super(IndexDefinition.RULE, normalizer, client); | |||
} | |||
@Override | |||
protected String getKeyValue(RuleKey key) { | |||
return key.toString(); | |||
} |
@@ -86,6 +86,7 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial | |||
this.indexDefinition = indexDefinition; | |||
} | |||
@Override | |||
public BaseNormalizer<DTO, KEY> getNormalizer() { | |||
return normalizer; | |||
} | |||
@@ -118,6 +119,7 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial | |||
} | |||
// Scrolling within the index | |||
@Override | |||
public Iterator<DOMAIN> scroll(final String scrollId) { | |||
return new Iterator<DOMAIN>() { | |||
@@ -185,6 +187,7 @@ public abstract class BaseIndex<DOMAIN, DTO extends Dto<KEY>, KEY extends Serial | |||
} | |||
} | |||
@Override | |||
public IndexStat getIndexStat() { | |||
IndexStat stat = new IndexStat(); | |||
@@ -31,10 +31,12 @@ class RuleMacro implements Macro { | |||
/** | |||
* First parameter is the repository, second one is the rule key. Exemple : {rule:squid:ArchitecturalConstraint} | |||
*/ | |||
@Override | |||
public String getRegex() { | |||
return "\\{rule:([a-zA-Z0-9._-]++):([a-zA-Z0-9._-]++)\\}"; | |||
} | |||
@Override | |||
public String getReplacement() { | |||
return "<a href='" + contextPath + "/coding_rules#rule_key=$1:$2'>$2</a>"; | |||
} |
@@ -334,6 +334,7 @@ public class ViewProxy<V extends View> implements Comparable<ViewProxy> { | |||
} | |||
@Override | |||
public int compareTo(ViewProxy other) { | |||
return new CompareToBuilder() | |||
.append(getTitle(), other.getTitle()) |
@@ -124,6 +124,7 @@ public class ListingWs implements WebService { | |||
// sort controllers by path | |||
Ordering<Controller> ordering = Ordering.natural().onResultOf(new Function<Controller, String>() { | |||
@Override | |||
public String apply(Controller controller) { | |||
return controller.path(); | |||
} | |||
@@ -144,6 +145,7 @@ public class ListingWs implements WebService { | |||
writer.prop("description", controller.description()); | |||
// sort actions by key | |||
Ordering<Action> ordering = Ordering.natural().onResultOf(new Function<Action, String>() { | |||
@Override | |||
public String apply(Action action) { | |||
return action.key(); | |||
} | |||
@@ -169,6 +171,7 @@ public class ListingWs implements WebService { | |||
if (!action.params().isEmpty()) { | |||
// sort parameters by key | |||
Ordering<Param> ordering = Ordering.natural().onResultOf(new Function<Param, String>() { | |||
@Override | |||
public String apply(@Nullable Param param) { | |||
return param != null ? param.key() : null; | |||
} |
@@ -40,23 +40,28 @@ public class DefaultActionPlan implements ActionPlan { | |||
/** | |||
* Unique key | |||
*/ | |||
@Override | |||
public String key() { | |||
return JsonUtils.getString(json, "key"); | |||
} | |||
@Override | |||
public String project() { | |||
return JsonUtils.getString(json, "project"); | |||
} | |||
@Override | |||
public String name() { | |||
return JsonUtils.getString(json, "name"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public String description() { | |||
return JsonUtils.getString(json, "desc"); | |||
} | |||
@Override | |||
public String status() { | |||
return JsonUtils.getString(json, "status"); | |||
} | |||
@@ -64,28 +69,34 @@ public class DefaultActionPlan implements ActionPlan { | |||
/** | |||
* Login of the user who created the action plan. | |||
*/ | |||
@Override | |||
public String userLogin() { | |||
return JsonUtils.getString(json, "userLogin"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Date deadLine() { | |||
return JsonUtils.getDateTime(json, "deadLine"); | |||
} | |||
@Override | |||
public Date createdAt() { | |||
return JsonUtils.getDateTime(json, "createdAt"); | |||
} | |||
@Override | |||
public Date updatedAt() { | |||
return JsonUtils.getDateTime(json, "updatedAt"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Integer totalIssues() { | |||
return JsonUtils.getInteger(json, "totalIssues"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Integer unresolvedIssues() { | |||
return JsonUtils.getInteger(json, "unresolvedIssues"); |
@@ -36,15 +36,18 @@ public class DefaultBulkChange implements BulkChange { | |||
private Integer totalIssuesNotChanged; | |||
private final List<String> issuesNotChangedKeys = new ArrayList<String>(); | |||
@Override | |||
public List<String> issuesNotChangedKeys() { | |||
return issuesNotChangedKeys; | |||
} | |||
@Override | |||
@CheckForNull | |||
public Integer totalIssuesChanged() { | |||
return totalIssuesChanged; | |||
} | |||
@Override | |||
@CheckForNull | |||
public Integer totalIssuesNotChanged() { | |||
return totalIssuesNotChanged; |
@@ -41,45 +41,55 @@ public class DefaultIssue implements Issue { | |||
/** | |||
* Unique key | |||
*/ | |||
@Override | |||
public String key() { | |||
return JsonUtils.getString(json, "key"); | |||
} | |||
@Override | |||
public Long componentId() { | |||
return JsonUtils.getLong(json, "componentId"); | |||
} | |||
@Override | |||
public String componentKey() { | |||
return JsonUtils.getString(json, "component"); | |||
} | |||
@Override | |||
public String projectKey() { | |||
return JsonUtils.getString(json, "project"); | |||
} | |||
@Override | |||
public String ruleKey() { | |||
return JsonUtils.getString(json, "rule"); | |||
} | |||
@Override | |||
public String severity() { | |||
return JsonUtils.getString(json, "severity"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public String message() { | |||
return JsonUtils.getString(json, "message"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Integer line() { | |||
return JsonUtils.getInteger(json, "line"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public String debt() { | |||
return JsonUtils.getString(json, "debt"); | |||
} | |||
@Override | |||
public String status() { | |||
return JsonUtils.getString(json, "status"); | |||
} | |||
@@ -87,11 +97,13 @@ public class DefaultIssue implements Issue { | |||
/** | |||
* The resolution type. Null if the issue is not resolved. | |||
*/ | |||
@Override | |||
@CheckForNull | |||
public String resolution() { | |||
return JsonUtils.getString(json, "resolution"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public String reporter() { | |||
return JsonUtils.getString(json, "reporter"); | |||
@@ -100,6 +112,7 @@ public class DefaultIssue implements Issue { | |||
/** | |||
* Login of assignee. Null if issue is not assigned. | |||
*/ | |||
@Override | |||
@CheckForNull | |||
public String assignee() { | |||
return JsonUtils.getString(json, "assignee"); | |||
@@ -108,34 +121,41 @@ public class DefaultIssue implements Issue { | |||
/** | |||
* SCM account | |||
*/ | |||
@Override | |||
@CheckForNull | |||
public String author() { | |||
return JsonUtils.getString(json, "author"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public String actionPlan() { | |||
return JsonUtils.getString(json, "actionPlan"); | |||
} | |||
@Override | |||
public Date creationDate() { | |||
return JsonUtils.getDateTime(json, "creationDate"); | |||
} | |||
@Override | |||
public Date updateDate() { | |||
return JsonUtils.getDateTime(json, "updateDate"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Date closeDate() { | |||
return JsonUtils.getDateTime(json, "closeDate"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public String attribute(String key) { | |||
return attributes().get(key); | |||
} | |||
@Override | |||
public Map<String, String> attributes() { | |||
Map<String, String> attr = (Map<String, String>) json.get("attr"); | |||
if (attr == null) { | |||
@@ -147,6 +167,7 @@ public class DefaultIssue implements Issue { | |||
/** | |||
* Non-null list of comments | |||
*/ | |||
@Override | |||
public List<IssueComment> comments() { | |||
List<IssueComment> comments = new ArrayList<IssueComment>(); | |||
List<Map> jsonComments = (List<Map>) json.get("comments"); |
@@ -39,14 +39,17 @@ public class DefaultIssueChange implements IssueChange { | |||
this.json = json; | |||
} | |||
@Override | |||
public String user() { | |||
return JsonUtils.getString(json, "user"); | |||
} | |||
@Override | |||
public Date creationDate() { | |||
return JsonUtils.getDateTime(json, "creationDate"); | |||
} | |||
@Override | |||
public List<IssueChangeDiff> diffs() { | |||
List<IssueChangeDiff> diffs = new ArrayList<IssueChangeDiff>(); | |||
List<Map> jsonDiffs = (List<Map>) json.get("diffs"); |
@@ -37,16 +37,19 @@ public class DefaultIssueChangeDiff implements IssueChangeDiff { | |||
this.json = json; | |||
} | |||
@Override | |||
public String key() { | |||
return JsonUtils.getString(json, "key"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Object newValue() { | |||
return parseValue("newValue"); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Object oldValue() { | |||
return parseValue("oldValue"); |
@@ -45,6 +45,7 @@ public class DefaultIssueClient implements IssueClient { | |||
this.parser = new IssueJsonParser(); | |||
} | |||
@Override | |||
public Issues find(IssueQuery query) { | |||
String json = requestFactory.get(SEARCH_URL, query.urlParams()); | |||
return parser.parseIssues(json); |
@@ -35,18 +35,22 @@ public class DefaultIssueComment implements IssueComment { | |||
this.json = json; | |||
} | |||
@Override | |||
public String key() { | |||
return JsonUtils.getString(json, "key"); | |||
} | |||
@Override | |||
public String htmlText() { | |||
return JsonUtils.getString(json, "htmlText"); | |||
} | |||
@Override | |||
public String login() { | |||
return JsonUtils.getString(json, "login"); | |||
} | |||
@Override | |||
public Date createdAt() { | |||
return JsonUtils.getDateTime(json, "createdAt"); | |||
} |
@@ -47,72 +47,88 @@ public class DefaultIssues implements Issues { | |||
private Paging paging; | |||
private Boolean maxResultsReached; | |||
@Override | |||
public List<Issue> list() { | |||
return list; | |||
} | |||
@Override | |||
public int size() { | |||
return list.size(); | |||
} | |||
@Override | |||
public Collection<Rule> rules() { | |||
return rulesByKey.values(); | |||
} | |||
@Override | |||
public Rule rule(Issue issue) { | |||
return rulesByKey.get(issue.ruleKey()); | |||
} | |||
@Override | |||
public Collection<User> users() { | |||
return usersByKey.values(); | |||
} | |||
@Override | |||
@CheckForNull | |||
public User user(String login) { | |||
return usersByKey.get(login); | |||
} | |||
@Override | |||
public Collection<Component> components() { | |||
return componentsByKey.values(); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Component component(Issue issue) { | |||
return componentsByKey.get(issue.componentKey()); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Component componentById(long id) { | |||
return componentsById.get(id); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Component componentByKey(String key) { | |||
return componentsByKey.get(key); | |||
} | |||
@Override | |||
public Collection<Component> projects() { | |||
return projectsByKey.values(); | |||
} | |||
@Override | |||
@CheckForNull | |||
public Component project(Issue issue) { | |||
return projectsByKey.get(issue.projectKey()); | |||
} | |||
@Override | |||
public Collection<ActionPlan> actionPlans() { | |||
return actionPlansByKey.values(); | |||
} | |||
@Override | |||
@CheckForNull | |||
public ActionPlan actionPlans(Issue issue) { | |||
return actionPlansByKey.get(issue.actionPlan()); | |||
} | |||
@Override | |||
public Paging paging() { | |||
return paging; | |||
} | |||
@Override | |||
@Nullable | |||
public Boolean maxResultsReached() { | |||
return maxResultsReached; |
@@ -27,6 +27,7 @@ import java.util.List; | |||
public abstract class AbstractUnmarshaller<M extends Model> implements Unmarshaller<M> { | |||
@Override | |||
public final M toModel(String json) { | |||
WSUtils utils = WSUtils.getINSTANCE(); | |||
M result = null; | |||
@@ -45,6 +46,7 @@ public abstract class AbstractUnmarshaller<M extends Model> implements Unmarshal | |||
} | |||
@Override | |||
public final List<M> toModels(String json) { | |||
WSUtils utils = WSUtils.getINSTANCE(); | |||
List<M> result = new ArrayList<M>(); |
@@ -26,6 +26,7 @@ import java.util.List; | |||
public class AuthenticationUnmarshaller implements Unmarshaller<Authentication> { | |||
@Override | |||
public Authentication toModel(String json) { | |||
WSUtils utils = WSUtils.getINSTANCE(); | |||
Object map = utils.parse(json); | |||
@@ -34,6 +35,7 @@ public class AuthenticationUnmarshaller implements Unmarshaller<Authentication> | |||
return new Authentication().setValid(validJson != null ? validJson : false); | |||
} | |||
@Override | |||
public List<Authentication> toModels(String json) { | |||
throw new UnsupportedOperationException(); | |||
} |
@@ -28,6 +28,7 @@ import java.util.List; | |||
* @since 2.9 | |||
*/ | |||
public class ServerSetupUnmarshaller implements Unmarshaller<ServerSetup> { | |||
@Override | |||
public ServerSetup toModel(String json) { | |||
WSUtils utils = WSUtils.getINSTANCE(); | |||
Object map = utils.parse(json); | |||
@@ -36,6 +37,7 @@ public class ServerSetupUnmarshaller implements Unmarshaller<ServerSetup> { | |||
.setMessage(utils.getString(map, "msg")); | |||
} | |||
@Override | |||
public List<ServerSetup> toModels(String json) { | |||
throw new UnsupportedOperationException(); | |||
} |
@@ -28,6 +28,7 @@ import java.util.List; | |||
* @author Evgeny Mandrikov | |||
*/ | |||
public class ServerUnmarshaller implements Unmarshaller<Server> { | |||
@Override | |||
public Server toModel(String json) { | |||
WSUtils utils = WSUtils.getINSTANCE(); | |||
Object map = utils.parse(json); | |||
@@ -42,6 +43,7 @@ public class ServerUnmarshaller implements Unmarshaller<Server> { | |||
return server; | |||
} | |||
@Override | |||
public List<Server> toModels(String json) { | |||
throw new UnsupportedOperationException(); | |||
} |
@@ -86,10 +86,12 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
return this; | |||
} | |||
@Override | |||
public Project getProject() { | |||
return sonarIndex.getProject(); | |||
} | |||
@Override | |||
public List<DecoratorContext> getChildren() { | |||
checkReadOnly("getModules"); | |||
return childrenContexts; | |||
@@ -101,6 +103,7 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
} | |||
} | |||
@Override | |||
public <M> M getMeasures(MeasuresFilter<M> filter) { | |||
Collection<Measure> unfiltered; | |||
if (filter instanceof MeasuresFilters.MetricFilter) { | |||
@@ -112,10 +115,12 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
return filter.filter(unfiltered); | |||
} | |||
@Override | |||
public Measure getMeasure(Metric metric) { | |||
return getMeasures(MeasuresFilters.metric(metric)); | |||
} | |||
@Override | |||
public Collection<Measure> getChildrenMeasures(MeasuresFilter filter) { | |||
List<Measure> result = Lists.newArrayList(); | |||
for (DecoratorContext childContext : childrenContexts) { | |||
@@ -131,14 +136,17 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
return result; | |||
} | |||
@Override | |||
public Collection<Measure> getChildrenMeasures(Metric metric) { | |||
return getChildrenMeasures(MeasuresFilters.metric(metric)); | |||
} | |||
@Override | |||
public Resource getResource() { | |||
return resource; | |||
} | |||
@Override | |||
public DecoratorContext saveMeasure(Measure measure) { | |||
checkReadOnly(SAVE_MEASURE_METHOD); | |||
Metric metric = metricFinder.findByKey(measure.getMetricKey()); | |||
@@ -167,6 +175,7 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
return this; | |||
} | |||
@Override | |||
public DecoratorContext saveMeasure(Metric metric, Double value) { | |||
checkReadOnly(SAVE_MEASURE_METHOD); | |||
saveMeasure(new Measure(metric, value)); | |||
@@ -176,6 +185,7 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
/** | |||
* {@inheritDoc} | |||
*/ | |||
@Override | |||
public List<Violation> getViolations(ViolationQuery violationQuery) { | |||
return sonarIndex.getViolations(violationQuery); | |||
} | |||
@@ -183,39 +193,48 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
/** | |||
* {@inheritDoc} | |||
*/ | |||
@Override | |||
public List<Violation> getViolations() { | |||
return sonarIndex.getViolations(resource); | |||
} | |||
@Override | |||
public Dependency saveDependency(Dependency dependency) { | |||
checkReadOnly("addDependency"); | |||
return sonarIndex.addDependency(dependency); | |||
} | |||
@Override | |||
public Set<Dependency> getDependencies() { | |||
return sonarIndex.getDependencies(); | |||
} | |||
@Override | |||
public Collection<Dependency> getIncomingDependencies() { | |||
return sonarIndex.getIncomingEdges(resource); | |||
} | |||
@Override | |||
public Collection<Dependency> getOutgoingDependencies() { | |||
return sonarIndex.getOutgoingEdges(resource); | |||
} | |||
@Override | |||
public List<Event> getEvents() { | |||
return sonarIndex.getEvents(resource); | |||
} | |||
@Override | |||
public Event createEvent(String name, String description, String category, Date date) { | |||
return sonarIndex.addEvent(resource, name, description, category, date); | |||
} | |||
@Override | |||
public void deleteEvent(Event event) { | |||
sonarIndex.deleteEvent(event); | |||
} | |||
@Override | |||
public DefaultDecoratorContext saveViolation(Violation violation, boolean force) { | |||
if (violation.getResource() == null) { | |||
violation.setResource(resource); | |||
@@ -224,6 +243,7 @@ public class DefaultDecoratorContext implements DecoratorContext { | |||
return this; | |||
} | |||
@Override | |||
public DefaultDecoratorContext saveViolation(Violation violation) { | |||
return saveViolation(violation, false); | |||
} |
@@ -52,6 +52,7 @@ public class DefaultFileLinesContext implements FileLinesContext { | |||
this.resource = resource; | |||
} | |||
@Override | |||
public void setIntValue(String metricKey, int line, int value) { | |||
Preconditions.checkNotNull(metricKey); | |||
Preconditions.checkArgument(line > 0); | |||
@@ -59,6 +60,7 @@ public class DefaultFileLinesContext implements FileLinesContext { | |||
setValue(metricKey, line, value); | |||
} | |||
@Override | |||
public Integer getIntValue(String metricKey, int line) { | |||
Preconditions.checkNotNull(metricKey); | |||
Preconditions.checkArgument(line > 0); | |||
@@ -72,6 +74,7 @@ public class DefaultFileLinesContext implements FileLinesContext { | |||
return (Integer) lines.get(line); | |||
} | |||
@Override | |||
public void setStringValue(String metricKey, int line, String value) { | |||
Preconditions.checkNotNull(metricKey); | |||
Preconditions.checkArgument(line > 0); | |||
@@ -80,6 +83,7 @@ public class DefaultFileLinesContext implements FileLinesContext { | |||
setValue(metricKey, line, value); | |||
} | |||
@Override | |||
public String getStringValue(String metricKey, int line) { | |||
Preconditions.checkNotNull(metricKey); | |||
Preconditions.checkArgument(line > 0); | |||
@@ -106,6 +110,7 @@ public class DefaultFileLinesContext implements FileLinesContext { | |||
getOrCreateLines(metricKey).put(line, value); | |||
} | |||
@Override | |||
public void save() { | |||
for (Map.Entry<String, Map<Integer, Object>> entry : map.entrySet()) { | |||
String metricKey = entry.getKey(); |
@@ -77,6 +77,7 @@ public class DefaultProjectTree implements ProjectTree { | |||
return projects; | |||
} | |||
@Override | |||
public Project getRootProject() { | |||
for (Project project : projects) { | |||
if (project.getParent() == null) { | |||
@@ -86,6 +87,7 @@ public class DefaultProjectTree implements ProjectTree { | |||
throw new IllegalStateException("Can not find the root project from the list of Maven modules"); | |||
} | |||
@Override | |||
public ProjectDefinition getProjectDefinition(Project project) { | |||
for (Map.Entry<ProjectDefinition, Project> entry : projectsByDef.entrySet()) { | |||
if (ObjectUtils.equals(entry.getValue(), project)) { |
@@ -63,6 +63,7 @@ public class DefaultSensorContext implements SensorContext { | |||
return project; | |||
} | |||
@Override | |||
public boolean index(Resource resource) { | |||
// SONAR-5006 | |||
if (indexedByCore(resource)) { | |||
@@ -176,6 +177,7 @@ public class DefaultSensorContext implements SensorContext { | |||
} | |||
} | |||
@Override | |||
public void saveViolation(Violation violation, boolean force) { | |||
if (violation.getResource() == null) { | |||
violation.setResource(resourceOrProject(violation.getResource())); | |||
@@ -183,10 +185,12 @@ public class DefaultSensorContext implements SensorContext { | |||
index.addViolation(violation, force); | |||
} | |||
@Override | |||
public void saveViolation(Violation violation) { | |||
saveViolation(violation, false); | |||
} | |||
@Override | |||
public void saveViolations(Collection<Violation> violations) { | |||
if (violations != null) { | |||
for (Violation violation : violations) { | |||
@@ -195,42 +199,52 @@ public class DefaultSensorContext implements SensorContext { | |||
} | |||
} | |||
@Override | |||
public Dependency saveDependency(Dependency dependency) { | |||
return index.addDependency(dependency); | |||
} | |||
@Override | |||
public Set<Dependency> getDependencies() { | |||
return index.getDependencies(); | |||
} | |||
@Override | |||
public Collection<Dependency> getIncomingDependencies(Resource to) { | |||
return index.getIncomingEdges(resourceOrProject(to)); | |||
} | |||
@Override | |||
public Collection<Dependency> getOutgoingDependencies(Resource from) { | |||
return index.getOutgoingEdges(resourceOrProject(from)); | |||
} | |||
@Override | |||
public void saveSource(Resource reference, String source) { | |||
// useless since 4.2. | |||
} | |||
@Override | |||
public void saveLink(ProjectLink link) { | |||
index.addLink(link); | |||
} | |||
@Override | |||
public void deleteLink(String key) { | |||
index.deleteLink(key); | |||
} | |||
@Override | |||
public List<Event> getEvents(Resource resource) { | |||
return index.getEvents(resource); | |||
} | |||
@Override | |||
public Event createEvent(Resource resource, String name, String description, String category, Date date) { | |||
return index.addEvent(resource, name, description, category, date); | |||
} | |||
@Override | |||
public void deleteEvent(Event event) { | |||
index.deleteEvent(event); | |||
} |
@@ -59,6 +59,7 @@ public class DefaultTimeMachine implements TimeMachine { | |||
this.techDebtModel = techDebtModel; | |||
} | |||
@Override | |||
public List<Measure> getMeasures(TimeMachineQuery query) { | |||
Map<Integer, Metric> metricById = getMetricsById(query); | |||
@@ -76,6 +77,7 @@ public class DefaultTimeMachine implements TimeMachine { | |||
return result; | |||
} | |||
@Override | |||
public List<Object[]> getMeasuresFields(TimeMachineQuery query) { | |||
Map<Integer, Metric> metricById = getMetricsById(query); | |||
List<Object[]> rows = execute(query, false, metricById.keySet()); |
@@ -64,6 +64,7 @@ public final class FormulaDecorator implements Decorator { | |||
/** | |||
* {@inheritDoc} | |||
*/ | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -92,6 +93,7 @@ public final class FormulaDecorator implements Decorator { | |||
/** | |||
* {@inheritDoc} | |||
*/ | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (context.getMeasure(metric) != null) { | |||
return; |
@@ -30,10 +30,12 @@ public class BatchDatabaseSessionFactory implements DatabaseSessionFactory { | |||
this.session = session; | |||
} | |||
@Override | |||
public DatabaseSession getSession() { | |||
return session; | |||
} | |||
@Override | |||
public void clear() { | |||
} | |||
} |
@@ -106,14 +106,17 @@ public class BatchPluginRepository implements PluginRepository { | |||
} | |||
} | |||
@Override | |||
public Plugin getPlugin(String key) { | |||
return pluginsByKey.get(key); | |||
} | |||
@Override | |||
public Collection<PluginMetadata> getMetadata() { | |||
return metadataByKey.values(); | |||
} | |||
@Override | |||
public PluginMetadata getMetadata(String pluginKey) { | |||
return metadataByKey.get(pluginKey); | |||
} |
@@ -56,6 +56,7 @@ public class DefaultPluginsReferential implements PluginsReferential { | |||
try { | |||
final RemotePluginFile file = remote.file(); | |||
return fileCache.get(file.getFilename(), file.getHash(), new FileCache.Downloader() { | |||
@Override | |||
public void download(String filename, File toFile) throws IOException { | |||
String url = "/deploy/plugins/" + remote.getKey() + "/" + file.getFilename(); | |||
if (LOG.isDebugEnabled()) { |
@@ -63,6 +63,7 @@ public class JdbcDriverHolder { | |||
String hash = nameAndHash[1]; | |||
File jdbcDriver = fileCache.get(filename, hash, new FileCache.Downloader() { | |||
@Override | |||
public void download(String filename, File toFile) throws IOException { | |||
String url = "/deploy/" + filename; | |||
if (LOG.isDebugEnabled()) { |
@@ -84,6 +84,7 @@ public class TaskContainer extends ComponentContainer { | |||
private void installTaskExtensions() { | |||
getComponentByType(ExtensionInstaller.class).install(this, new ExtensionMatcher() { | |||
@Override | |||
public boolean accept(Object extension) { | |||
return ExtensionUtils.isType(extension, TaskComponent.class); | |||
} |
@@ -79,6 +79,7 @@ public final class DebtDecorator implements Decorator { | |||
this.ruleFinder = ruleFinder; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -88,6 +89,7 @@ public final class DebtDecorator implements Decorator { | |||
return Arrays.<Metric>asList(CoreMetrics.TECHNICAL_DEBT); | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
Issuable issuable = perspectives.as(Issuable.class, resource); | |||
if (issuable != null && shouldSaveMeasure(context)) { |
@@ -86,6 +86,7 @@ public class IssueChangelogDebtCalculator implements BatchComponent { | |||
// Changelog have to be sorted from newest to oldest. | |||
// Null date should be the first as this happen when technical debt has changed since previous analysis. | |||
Ordering<FieldDiffs> ordering = Ordering.natural().reverse().nullsFirst().onResultOf(new Function<FieldDiffs, Date>() { | |||
@Override | |||
public Date apply(FieldDiffs diff) { | |||
return diff.creationDate(); | |||
} |
@@ -63,6 +63,7 @@ public final class NewDebtDecorator implements Decorator { | |||
this.issueChangelogDebtCalculator = issueChangelogDebtCalculator; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -74,6 +75,7 @@ public final class NewDebtDecorator implements Decorator { | |||
); | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
Issuable issuable = perspectives.as(Issuable.class, resource); | |||
if (issuable != null && shouldSaveNewMetrics(context)) { |
@@ -63,6 +63,7 @@ public final class SqaleRatingDecorator implements Decorator { | |||
this.fs = null; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -79,6 +80,7 @@ public final class SqaleRatingDecorator implements Decorator { | |||
return Lists.<Metric>newArrayList(CoreMetrics.SQALE_RATING, CoreMetrics.DEVELOPMENT_COST, CoreMetrics.SQALE_DEBT_RATIO); | |||
} | |||
@Override | |||
public void decorate(Resource resource, DecoratorContext context) { | |||
if (ResourceUtils.isPersistable(resource) && !ResourceUtils.isUnitTestClass(resource)) { | |||
Long developmentCost = getDevelopmentCost(context); |
@@ -57,6 +57,7 @@ public class BaseTangleIndexDecorator implements Decorator { | |||
return tangleIndexMetric; | |||
} | |||
@Override | |||
public final boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@@ -64,6 +65,7 @@ public class BaseTangleIndexDecorator implements Decorator { | |||
/** | |||
* {@inheritDoc} | |||
*/ | |||
@Override | |||
public final void decorate(Resource resource, DecoratorContext context) { | |||
if (!shouldDecorateResource(context)) { | |||
return; |
@@ -50,10 +50,12 @@ public class DirectoryDsmDecorator implements Decorator { | |||
this.index = index; | |||
} | |||
@Override | |||
public boolean shouldExecuteOnProject(Project project) { | |||
return true; | |||
} | |||
@Override | |||
public void decorate(final Resource resource, DecoratorContext context) { | |||
if (shouldDecorateResource(resource, context)) { | |||
List<DecoratorContext> fileContexts = context.getChildren(); |