diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-10-10 00:01:22 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-10-10 00:01:23 +0200 |
commit | 736c775bfc2cde38a53e4d43f858d3a3b6728c34 (patch) | |
tree | caee18e0a6007e19e8ee81d64a2b1e8dfe17a847 /sonar-batch | |
parent | 7d562d641868532e5edbd6f03fac739eff9bcc90 (diff) | |
download | sonarqube-736c775bfc2cde38a53e4d43f858d3a3b6728c34.tar.gz sonarqube-736c775bfc2cde38a53e4d43f858d3a3b6728c34.zip |
Add missing @Override annotations
Diffstat (limited to 'sonar-batch')
52 files changed, 165 insertions, 0 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java index 33172ca4aaa..eb8174abb0d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultDecoratorContext.java @@ -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); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultFileLinesContext.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultFileLinesContext.java index 98c5ef1dc78..df46490c7af 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/DefaultFileLinesContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultFileLinesContext.java @@ -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(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectTree.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectTree.java index 60d7eced356..1d9aeed130f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectTree.java +++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultProjectTree.java @@ -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)) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java index 089b2a3c58f..b8092ee54b4 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultSensorContext.java @@ -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); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java b/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java index 565417efad0..648b624bfa4 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java +++ b/sonar-batch/src/main/java/org/sonar/batch/DefaultTimeMachine.java @@ -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()); diff --git a/sonar-batch/src/main/java/org/sonar/batch/FormulaDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/FormulaDecorator.java index b0dd6bf3d11..75de88257d8 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/FormulaDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/FormulaDecorator.java @@ -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; diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchDatabaseSessionFactory.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchDatabaseSessionFactory.java index 40ae273a23c..1178041b439 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchDatabaseSessionFactory.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchDatabaseSessionFactory.java @@ -30,10 +30,12 @@ public class BatchDatabaseSessionFactory implements DatabaseSessionFactory { this.session = session; } + @Override public DatabaseSession getSession() { return session; } + @Override public void clear() { } } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java index e65adbce4fc..0ecd4d2b0ae 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/BatchPluginRepository.java @@ -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); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DefaultPluginsReferential.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DefaultPluginsReferential.java index 1332f59b062..7d611676d2c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DefaultPluginsReferential.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/DefaultPluginsReferential.java @@ -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()) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcDriverHolder.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcDriverHolder.java index 87eca7394bc..849c5269da7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcDriverHolder.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/JdbcDriverHolder.java @@ -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()) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java index 17af5c5fcf0..0ba55b20c9d 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/bootstrap/TaskContainer.java @@ -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); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java index c2c9c6b0e4c..f4521d664a6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/debt/DebtDecorator.java @@ -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)) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/IssueChangelogDebtCalculator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/IssueChangelogDebtCalculator.java index d34d0004500..7b925117ca1 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/debt/IssueChangelogDebtCalculator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/debt/IssueChangelogDebtCalculator.java @@ -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(); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java index 7320c9c912d..43046d3763b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/debt/NewDebtDecorator.java @@ -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)) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingDecorator.java index 35672b85d2b..3b1a1f49fbb 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/debt/SqaleRatingDecorator.java @@ -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); diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/BaseTangleIndexDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/design/BaseTangleIndexDecorator.java index c550c312bad..509cedcc7f1 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/design/BaseTangleIndexDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/design/BaseTangleIndexDecorator.java @@ -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; diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/DirectoryDsmDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/design/DirectoryDsmDecorator.java index 0aaa2aa854d..0446d61fd38 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/design/DirectoryDsmDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/design/DirectoryDsmDecorator.java @@ -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(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/MavenDependenciesSensor.java b/sonar-batch/src/main/java/org/sonar/batch/design/MavenDependenciesSensor.java index 67f92b40e55..9b618b7b4e8 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/design/MavenDependenciesSensor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/design/MavenDependenciesSensor.java @@ -94,6 +94,7 @@ public class MavenDependenciesSensor implements Sensor { this.index = index; } + @Override public boolean shouldExecuteOnProject(Project project) { return true; } @@ -157,6 +158,7 @@ public class MavenDependenciesSensor implements Sensor { } + @Override public void analyse(final Project project, final SensorContext context) { if (settings.hasKey(SONAR_MAVEN_PROJECT_DEPENDENCY)) { LOG.debug("Using dependency provided by property " + SONAR_MAVEN_PROJECT_DEPENDENCY); @@ -185,10 +187,12 @@ public class MavenDependenciesSensor implements Sensor { DependencyNode root = treeBuilder.buildDependencyTree(project.getPom(), localRepository, artifactFactory, artifactMetadataSource, null, artifactCollector); DependencyNodeVisitor visitor = new BuildingDependencyNodeVisitor(new DependencyNodeVisitor() { + @Override public boolean visit(DependencyNode node) { return true; } + @Override public boolean endVisit(DependencyNode node) { if (node.getParent() != null && node.getParent() != node) { saveDependency(project, node, context); diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/ProjectDsmDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/design/ProjectDsmDecorator.java index c030e586a50..f9ae4de6a50 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/design/ProjectDsmDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/design/ProjectDsmDecorator.java @@ -48,10 +48,12 @@ public class ProjectDsmDecorator 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)) { Collection<Resource> subProjects = getSubProjects((Project) resource); diff --git a/sonar-batch/src/main/java/org/sonar/batch/design/SubProjectDsmDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/design/SubProjectDsmDecorator.java index d58012869c7..3d850f3ab50 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/design/SubProjectDsmDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/design/SubProjectDsmDecorator.java @@ -50,10 +50,12 @@ public class SubProjectDsmDecorator 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> directoryContexts = context.getChildren(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java index 57814cad4ec..1c37360eb8b 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultIndex.java @@ -297,6 +297,7 @@ public class DefaultIndex extends SonarIndex { return dependencies; } + @Override public Dependency getEdge(Resource from, Resource to) { Map<Resource, Dependency> map = outgoingDependenciesByResource.get(from); if (map != null) { @@ -305,14 +306,17 @@ public class DefaultIndex extends SonarIndex { return null; } + @Override public boolean hasEdge(Resource from, Resource to) { return getEdge(from, to) != null; } + @Override public Set<Resource> getVertices() { return buckets.keySet(); } + @Override public Collection<Dependency> getOutgoingEdges(Resource from) { Map<Resource, Dependency> deps = outgoingDependenciesByResource.get(from); if (deps != null) { @@ -321,6 +325,7 @@ public class DefaultIndex extends SonarIndex { return Collections.emptyList(); } + @Override public Collection<Dependency> getIncomingEdges(Resource to) { Map<Resource, Dependency> deps = incomingDependenciesByResource.get(to); if (deps != null) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultPersistenceManager.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultPersistenceManager.java index 6b42c7184bf..b70c623b9d6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultPersistenceManager.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultPersistenceManager.java @@ -48,15 +48,18 @@ public final class DefaultPersistenceManager implements PersistenceManager { this.eventPersister = eventPersister; } + @Override public void clear() { resourcePersister.clear(); sourcePersister.clear(); } + @Override public void saveProject(Project project, @Nullable Project parent) { resourcePersister.saveProject(project, parent); } + @Override public Snapshot saveResource(Project project, Resource resource, @Nullable Resource parent) { if (ResourceUtils.isPersistable(resource)) { return resourcePersister.saveResource(project, resource, parent); @@ -64,36 +67,44 @@ public final class DefaultPersistenceManager implements PersistenceManager { return null; } + @Override public void setSource(Resource file, String source) { sourcePersister.saveSource(file, source); } + @Override public String getSource(Resource resource) { return sourcePersister.getSource(resource); } + @Override public void saveDependency(Project project, Dependency dependency, Dependency parentDependency) { if (ResourceUtils.isPersistable(dependency.getFrom()) && ResourceUtils.isPersistable(dependency.getTo())) { dependencyPersister.saveDependency(project, dependency, parentDependency); } } + @Override public void saveLink(Project project, ProjectLink link) { linkPersister.saveLink(project, link); } + @Override public void deleteLink(Project project, String key) { linkPersister.deleteLink(project, key); } + @Override public List<Event> getEvents(Resource resource) { return eventPersister.getEvents(resource); } + @Override public void deleteEvent(Event event) { eventPersister.deleteEvent(event); } + @Override public void saveEvent(Resource resource, Event event) { if (ResourceUtils.isPersistable(resource)) { eventPersister.saveEvent(resource, event); diff --git a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java index 7eeb87ea4f9..fcc4dd0262c 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/index/DefaultResourcePersister.java @@ -69,6 +69,7 @@ public final class DefaultResourcePersister implements ResourcePersister { this.resourceCache = resourceCache; } + @Override public Snapshot saveProject(Project project, @Nullable Project parent) { Snapshot snapshot = snapshotsByResource.get(project); if (snapshot == null) { @@ -129,11 +130,13 @@ public final class DefaultResourcePersister implements ResourcePersister { return snapshot; } + @Override @CheckForNull public Snapshot getSnapshot(@Nullable Resource reference) { return snapshotsByResource.get(reference); } + @Override public Snapshot getSnapshotOrFail(Resource resource) { Snapshot snapshot = getSnapshot(resource); if (snapshot == null) { @@ -158,10 +161,12 @@ public final class DefaultResourcePersister implements ResourcePersister { return snapshotsByResource; } + @Override public Snapshot saveResource(Project project, Resource resource) { return saveResource(project, resource, null); } + @Override public Snapshot saveResource(Project project, Resource resource, @Nullable Resource parent) { Snapshot snapshot = snapshotsByResource.get(resource); if (snapshot == null) { @@ -245,6 +250,7 @@ public final class DefaultResourcePersister implements ResourcePersister { return snapshot; } + @Override @CheckForNull public Snapshot getLastSnapshot(Snapshot snapshot, boolean onlyOlder) { String hql = "SELECT s FROM " + Snapshot.class.getSimpleName() + " s WHERE s.last=:last AND s.resourceId=:resourceId"; @@ -260,6 +266,7 @@ public final class DefaultResourcePersister implements ResourcePersister { return session.getSingleResult(query, null); } + @Override public void clear() { // we keep cache of projects for (Iterator<Map.Entry<Resource, Snapshot>> it = snapshotsByResource.entrySet().iterator(); it.hasNext();) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/ScanIssueStorage.java b/sonar-batch/src/main/java/org/sonar/batch/issue/ScanIssueStorage.java index 18cbd39daba..4ca89943fc1 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/issue/ScanIssueStorage.java +++ b/sonar-batch/src/main/java/org/sonar/batch/issue/ScanIssueStorage.java @@ -53,6 +53,7 @@ public class ScanIssueStorage extends IssueStorage implements BatchComponent { this.projectTree = projectTree; } + @Override protected void doInsert(DbSession session, Date now, DefaultIssue issue) { IssueMapper issueMapper = session.getMapper(IssueMapper.class); long componentId = componentId(issue); @@ -62,6 +63,7 @@ public class ScanIssueStorage extends IssueStorage implements BatchComponent { issueMapper.insert(dto); } + @Override protected void doUpdate(DbSession session, Date now, DefaultIssue issue) { IssueMapper issueMapper = session.getMapper(IssueMapper.class); IssueDto dto = IssueDto.toDtoForUpdate(issue, projectId(), now); diff --git a/sonar-batch/src/main/java/org/sonar/batch/language/LanguageDistributionDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/language/LanguageDistributionDecorator.java index 6b4842f71dc..cc246cfc793 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/language/LanguageDistributionDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/language/LanguageDistributionDecorator.java @@ -35,6 +35,7 @@ import org.sonar.api.resources.ResourceUtils; public class LanguageDistributionDecorator implements Decorator { + @Override public boolean shouldExecuteOnProject(Project project) { return true; } @@ -49,6 +50,7 @@ public class LanguageDistributionDecorator implements Decorator { return CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION; } + @Override public void decorate(Resource resource, DecoratorContext context) { CountDistributionBuilder nclocDistribution = new CountDistributionBuilder(CoreMetrics.NCLOC_LANGUAGE_DISTRIBUTION); if (ResourceUtils.isFile(resource)) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/languages/DefaultLanguagesReferential.java b/sonar-batch/src/main/java/org/sonar/batch/languages/DefaultLanguagesReferential.java index e9099c197cc..4d43ea2d8ce 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/languages/DefaultLanguagesReferential.java +++ b/sonar-batch/src/main/java/org/sonar/batch/languages/DefaultLanguagesReferential.java @@ -41,6 +41,7 @@ public class DefaultLanguagesReferential implements LanguagesReferential { /** * Get language. */ + @Override @CheckForNull public Language get(String languageKey) { org.sonar.api.resources.Language language = languages.get(languageKey); @@ -50,6 +51,7 @@ public class DefaultLanguagesReferential implements LanguagesReferential { /** * Get list of all supported languages. */ + @Override public Collection<Language> all() { org.sonar.api.resources.Language[] all = languages.all(); Collection<Language> result = new ArrayList<Language>(all.length); diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorExecutionEvent.java b/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorExecutionEvent.java index d571a51855d..b58cc9cc633 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorExecutionEvent.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorExecutionEvent.java @@ -32,6 +32,7 @@ class DecoratorExecutionEvent extends AbstractPhaseEvent<DecoratorExecutionHandl this.decorator = decorator; } + @Override public Decorator getDecorator() { return decorator; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsPhaseEvent.java b/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsPhaseEvent.java index b3e82da38c4..7854fc03316 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsPhaseEvent.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/DecoratorsPhaseEvent.java @@ -34,6 +34,7 @@ class DecoratorsPhaseEvent extends AbstractPhaseEvent<DecoratorsPhaseHandler> this.decorators = decorators; } + @Override public List<Decorator> getDecorators() { return decorators; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java b/sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java index 32b26389862..f6cc90b7847 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/GraphPersister.java @@ -48,6 +48,7 @@ public class GraphPersister implements ScanPersister { this.builders = builders; } + @Override public void persist() { DbSession session = myBatis.openSession(true); GraphDtoMapper mapper = session.getMapper(GraphDtoMapper.class); diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/InitializerExecutionEvent.java b/sonar-batch/src/main/java/org/sonar/batch/phases/InitializerExecutionEvent.java index cc024c4a2e6..5e2b03d64d7 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/InitializerExecutionEvent.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/InitializerExecutionEvent.java @@ -32,6 +32,7 @@ class InitializerExecutionEvent extends AbstractPhaseEvent<InitializerExecutionH this.initializer = initializer; } + @Override public Initializer getInitializer() { return initializer; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersPhaseEvent.java b/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersPhaseEvent.java index ab7ab3916d2..691c279957a 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersPhaseEvent.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/InitializersPhaseEvent.java @@ -34,6 +34,7 @@ class InitializersPhaseEvent extends AbstractPhaseEvent<InitializersPhaseHandler this.initializers = initializers; } + @Override public List<Initializer> getInitializers() { return initializers; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/PersistersPhaseEvent.java b/sonar-batch/src/main/java/org/sonar/batch/phases/PersistersPhaseEvent.java index c2074effcda..ad43c00ab36 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/PersistersPhaseEvent.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/PersistersPhaseEvent.java @@ -34,6 +34,7 @@ class PersistersPhaseEvent extends AbstractPhaseEvent<PersistersPhaseHandler> this.persisters = persisters; } + @Override public List<ScanPersister> getPersisters() { return persisters; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/PhasesTimeProfiler.java b/sonar-batch/src/main/java/org/sonar/batch/phases/PhasesTimeProfiler.java index 9c80c0d7255..05eda79a065 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/PhasesTimeProfiler.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/PhasesTimeProfiler.java @@ -42,12 +42,14 @@ public class PhasesTimeProfiler implements SensorExecutionHandler, DecoratorExec private TimeProfiler profiler = new TimeProfiler(LOG); private DecoratorsProfiler decoratorsProfiler = new DecoratorsProfiler(); + @Override public void onSensorsPhase(SensorsPhaseEvent event) { if (event.isStart()) { LOG.debug("Sensors : {}", StringUtils.join(event.getSensors(), " -> ")); } } + @Override public void onSensorExecution(SensorExecutionEvent event) { if (event.isStart()) { profiler.start("Sensor " + event.getSensor()); @@ -56,6 +58,7 @@ public class PhasesTimeProfiler implements SensorExecutionHandler, DecoratorExec } } + @Override public void onDecoratorExecution(DecoratorExecutionEvent event) { if (event.isStart()) { decoratorsProfiler.start(event.getDecorator()); @@ -64,6 +67,7 @@ public class PhasesTimeProfiler implements SensorExecutionHandler, DecoratorExec } } + @Override public void onDecoratorsPhase(DecoratorsPhaseEvent event) { if (event.isStart()) { LOG.info("Execute decorators..."); diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobPhaseEvent.java b/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobPhaseEvent.java index e886fd9b008..52cf4826cf1 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobPhaseEvent.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/PostJobPhaseEvent.java @@ -34,6 +34,7 @@ class PostJobPhaseEvent extends AbstractPhaseEvent<PostJobsPhaseHandler> this.postJobs = postJobs; } + @Override public List<PostJob> getPostJobs() { return postJobs; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectAnalysisEvent.java b/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectAnalysisEvent.java index 3131c6663ea..7c4ac3234e5 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectAnalysisEvent.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/ProjectAnalysisEvent.java @@ -32,6 +32,7 @@ class ProjectAnalysisEvent extends AbstractPhaseEvent<ProjectAnalysisHandler> this.project = project; } + @Override public Project getProject() { return project; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorExecutionEvent.java b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorExecutionEvent.java index bbb3c81005e..9e8593ba7d6 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorExecutionEvent.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorExecutionEvent.java @@ -32,6 +32,7 @@ class SensorExecutionEvent extends AbstractPhaseEvent<SensorExecutionHandler> this.sensor = sensor; } + @Override public Sensor getSensor() { return sensor; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsPhaseEvent.java b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsPhaseEvent.java index f18c6ac9f6d..6ef613088fd 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsPhaseEvent.java +++ b/sonar-batch/src/main/java/org/sonar/batch/phases/SensorsPhaseEvent.java @@ -34,6 +34,7 @@ class SensorsPhaseEvent extends AbstractPhaseEvent<SensorsPhaseHandler> this.sensors = sensors; } + @Override public List<Sensor> getSensors() { return sensors; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java index 42d61fb4f64..fed134857cc 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java +++ b/sonar-batch/src/main/java/org/sonar/batch/profiling/PhasesSumUpTimeProfiler.java @@ -132,6 +132,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx println(""); } + @Override public void onSensorsPhase(SensorsPhaseEvent event) { if (event.isStart()) { currentModuleProfiling.addPhaseProfiling(Phases.Phase.SENSOR); @@ -140,6 +141,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx } } + @Override public void onSensorExecution(SensorExecutionEvent event) { PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phases.Phase.SENSOR); if (event.isStart()) { @@ -149,6 +151,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx } } + @Override public void onPersistersPhase(PersistersPhaseEvent event) { if (event.isStart()) { currentModuleProfiling.addPhaseProfiling(Phases.Phase.PERSISTER); @@ -157,6 +160,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx } } + @Override public void onPersisterExecution(PersisterExecutionEvent event) { PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phases.Phase.PERSISTER); if (event.isStart()) { @@ -166,6 +170,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx } } + @Override public void onDecoratorExecution(DecoratorExecutionEvent event) { PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phases.Phase.DECORATOR); if (event.isStart()) { @@ -178,6 +183,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx } } + @Override public void onDecoratorsPhase(DecoratorsPhaseEvent event) { if (event.isStart()) { currentModuleProfiling.addPhaseProfiling(Phases.Phase.DECORATOR); @@ -190,6 +196,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx } } + @Override public void onPostJobsPhase(PostJobsPhaseEvent event) { if (event.isStart()) { currentModuleProfiling.addPhaseProfiling(Phases.Phase.POSTJOB); @@ -198,6 +205,7 @@ public class PhasesSumUpTimeProfiler implements ProjectAnalysisHandler, SensorEx } } + @Override public void onPostJobExecution(PostJobExecutionEvent event) { PhaseProfiling profiling = currentModuleProfiling.getProfilingPerPhase(Phases.Phase.POSTJOB); if (event.isStart()) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/GenerateQualityGateEvents.java b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/GenerateQualityGateEvents.java index 26fccb3d739..824610b5d01 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/qualitygate/GenerateQualityGateEvents.java +++ b/sonar-batch/src/main/java/org/sonar/batch/qualitygate/GenerateQualityGateEvents.java @@ -44,6 +44,7 @@ public class GenerateQualityGateEvents implements Decorator { this.notificationManager = notificationManager; } + @Override public boolean shouldExecuteOnProject(Project project) { return qualityGate.isEnabled(); } @@ -53,6 +54,7 @@ public class GenerateQualityGateEvents implements Decorator { return CoreMetrics.ALERT_STATUS; } + @Override public void decorate(Resource resource, DecoratorContext context) { if (!shouldDecorateResource(resource)) { return; diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileDecorator.java index 9ebc5db4624..05371f00828 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileDecorator.java @@ -39,6 +39,7 @@ public class QProfileDecorator implements Decorator { return CoreMetrics.QUALITY_PROFILES; } + @Override public boolean shouldExecuteOnProject(Project project) { return !project.getModules().isEmpty(); } diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java index 3de4a4b985b..53fb0894817 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileEventsDecorator.java @@ -62,6 +62,7 @@ public class QProfileEventsDecorator implements Decorator { return CoreMetrics.QUALITY_PROFILES; } + @Override public boolean shouldExecuteOnProject(Project project) { return true; } diff --git a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileSensor.java b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileSensor.java index 8f84c66ca90..13ab4448d78 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileSensor.java +++ b/sonar-batch/src/main/java/org/sonar/batch/rule/QProfileSensor.java @@ -39,11 +39,13 @@ public class QProfileSensor implements Sensor { this.fs = fs; } + @Override public boolean shouldExecuteOnProject(Project project) { // Should be only executed on leaf modules return project.getModules().isEmpty(); } + @Override public void analyse(Project project, SensorContext context) { UsedQProfiles used = new UsedQProfiles(); for (String language : fs.languages()) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java index ae6b1aa4ee6..e2b78269175 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ModuleScanContainer.java @@ -200,6 +200,7 @@ public class ModuleScanContainer extends ComponentContainer { private void addExtensions() { ExtensionInstaller installer = getComponentByType(ExtensionInstaller.class); installer.install(this, new ExtensionMatcher() { + @Override public boolean accept(Object extension) { if (ExtensionUtils.isType(extension, BatchComponent.class) && ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_PROJECT)) { // Special use-case: the extension point ProjectBuilder is used in a Maven environment to define some diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java index 6a115108a0b..3c881aada88 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ProjectScanContainer.java @@ -234,6 +234,7 @@ public class ProjectScanContainer extends ComponentContainer { } static class BatchExtensionFilter implements ExtensionMatcher { + @Override public boolean accept(Object extension) { return ExtensionUtils.isType(extension, BatchComponent.class) && ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_BATCH); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java b/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java index 0ff2d3be352..2ded6e055b4 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/ScanTask.java @@ -43,6 +43,7 @@ public class ScanTask implements Task { this.taskContainer = taskContainer; } + @Override public void execute() { boolean sensorMode = CoreProperties.ANALYSIS_MODE_SENSOR.equals(taskContainer.getComponentByType(BootstrapProperties.class).property(CoreProperties.ANALYSIS_MODE)); if (sensorMode) { diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java index ba0fe388bca..0617ea8e8fa 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/filesystem/ProjectFileSystemAdapter.java @@ -68,14 +68,17 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { // used to avoid NPE in Project#getFileSystem() } + @Override public Charset getSourceCharset() { return target.sourceCharset(); } + @Override public File getBasedir() { return target.baseDir(); } + @Override public File getBuildDir() { File dir = target.buildDir(); if (dir == null) { @@ -85,6 +88,7 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { return dir; } + @Override public File getBuildOutputDir() { File dir = Iterables.getFirst(target.binaryDirs(), null); if (dir == null) { @@ -95,24 +99,29 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { return dir; } + @Override public List<File> getSourceDirs() { return target.sourceDirs(); } + @Override public ProjectFileSystem addSourceDir(File dir) { target.addSourceDir(dir); return this; } + @Override public List<File> getTestDirs() { return target.testDirs(); } + @Override public ProjectFileSystem addTestDir(File dir) { target.addTestDir(dir); return this; } + @Override public File getReportOutputDir() { if (pom != null) { return resolvePath(pom.getReporting().getOutputDirectory()); @@ -121,10 +130,12 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { return new File(getBuildDir(), "site"); } + @Override public File getSonarWorkingDirectory() { return target.workingDir(); } + @Override public File resolvePath(String path) { File file = new File(path); if (!file.isAbsolute()) { @@ -137,43 +148,51 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { return file; } + @Override public List<File> getSourceFiles(Language... langs) { return Lists.newArrayList(target.files(target.predicates().and( target.predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.MAIN), newHasLanguagesPredicate(langs)))); } + @Override public List<File> getJavaSourceFiles() { return getSourceFiles(Java.INSTANCE); } + @Override public boolean hasJavaSourceFiles() { return !getJavaSourceFiles().isEmpty(); } + @Override public List<File> getTestFiles(Language... langs) { return Lists.newArrayList(target.files(target.predicates().and( target.predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.TEST), newHasLanguagesPredicate(langs)))); } + @Override public boolean hasTestFiles(Language lang) { return target.hasFiles(target.predicates().and( target.predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.TEST), target.predicates().hasLanguage(lang.getKey()))); } + @Override public File writeToWorkingDirectory(String content, String fileName) throws IOException { File file = new File(target.workingDir(), fileName); FileUtils.writeStringToFile(file, content, CharEncoding.UTF_8); return file; } + @Override public File getFileFromBuildDirectory(String filename) { File file = new File(getBuildDir(), filename); return file.exists() ? file : null; } + @Override public Resource toResource(File file) { if (file == null || !file.exists()) { return null; @@ -185,6 +204,7 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { return file.isFile() ? org.sonar.api.resources.File.create(relativePath) : org.sonar.api.resources.Directory.create(relativePath); } + @Override public List<InputFile> mainFiles(String... langs) { return Lists.newArrayList((Iterable) target.inputFiles(target.predicates().and( target.predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.MAIN), @@ -193,6 +213,7 @@ public class ProjectFileSystemAdapter implements ProjectFileSystem { } + @Override public List<InputFile> testFiles(String... langs) { return Lists.newArrayList((Iterable) target.inputFiles(target.predicates().and( target.predicates().hasType(org.sonar.api.batch.fs.InputFile.Type.TEST), diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java index bd8cee930d8..ca7b9700f5f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan/measure/MeasureValueCoder.java @@ -42,6 +42,7 @@ class MeasureValueCoder implements ValueCoder { this.techDebtModel = techDebtModel; } + @Override public void put(Value value, Object object, CoderContext context) { Measure<?> m = (Measure) object; value.putUTF(m.getMetricKey()); @@ -76,6 +77,7 @@ class MeasureValueCoder implements ValueCoder { } } + @Override public Object get(Value value, Class clazz, CoderContext context) { Measure<?> m = new Measure(); String metricKey = value.getString(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContext.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContext.java index c4aa0550914..5574c33e04e 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContext.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/DefaultFileLinesContext.java @@ -49,6 +49,7 @@ public class DefaultFileLinesContext implements FileLinesContext { this.inputFile = inputFile; } + @Override public void setIntValue(String metricKey, int line, int value) { Preconditions.checkNotNull(metricKey); Preconditions.checkArgument(line > 0); @@ -56,10 +57,12 @@ public class DefaultFileLinesContext implements FileLinesContext { setValue(metricKey, line, value); } + @Override public Integer getIntValue(String metricKey, int line) { throw new UnsupportedOperationException(); } + @Override public void setStringValue(String metricKey, int line, String value) { Preconditions.checkNotNull(metricKey); Preconditions.checkArgument(line > 0); @@ -68,6 +71,7 @@ public class DefaultFileLinesContext implements FileLinesContext { setValue(metricKey, line, value); } + @Override public String getStringValue(String metricKey, int line) { throw new UnsupportedOperationException(); } @@ -85,6 +89,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(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java index 41a2cda0390..5d3cb485f47 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/ModuleScanContainer.java @@ -130,6 +130,7 @@ public class ModuleScanContainer extends ComponentContainer { private void addExtensions() { ExtensionInstaller installer = getComponentByType(ExtensionInstaller.class); installer.install(this, new ExtensionMatcher() { + @Override public boolean accept(Object extension) { return ExtensionUtils.isType(extension, BatchComponent.class) && ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_PROJECT); diff --git a/sonar-batch/src/main/java/org/sonar/batch/scan2/ProjectScanContainer.java b/sonar-batch/src/main/java/org/sonar/batch/scan2/ProjectScanContainer.java index 8eeb6c5b113..431529be787 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/scan2/ProjectScanContainer.java +++ b/sonar-batch/src/main/java/org/sonar/batch/scan2/ProjectScanContainer.java @@ -158,6 +158,7 @@ public class ProjectScanContainer extends ComponentContainer { } static class BatchExtensionFilter implements ExtensionMatcher { + @Override public boolean accept(Object extension) { return ExtensionUtils.isType(extension, BatchComponent.class) && ExtensionUtils.isInstantiationStrategy(extension, InstantiationStrategy.PER_BATCH); diff --git a/sonar-batch/src/main/java/org/sonar/batch/tasks/ListTask.java b/sonar-batch/src/main/java/org/sonar/batch/tasks/ListTask.java index 06e891df925..93a0419b32f 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/tasks/ListTask.java +++ b/sonar-batch/src/main/java/org/sonar/batch/tasks/ListTask.java @@ -38,6 +38,7 @@ public class ListTask implements Task { this.tasks = tasks; } + @Override public void execute() { logBlankLine(); log("Available tasks:"); diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseValueCoder.java index 88b5de896d9..402cc624361 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseValueCoder.java +++ b/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseValueCoder.java @@ -38,6 +38,7 @@ class DefaultTestCaseValueCoder implements ValueCoder { this.inputPathCache = inputPathCache; } + @Override public void put(Value value, Object object, CoderContext context) { DefaultTestCase t = (DefaultTestCase) object; value.putUTF(((DefaultInputFile) t.testFile()).moduleKey()); @@ -59,6 +60,7 @@ class DefaultTestCaseValueCoder implements ValueCoder { } } + @Override public Object get(Value value, Class clazz, CoderContext context) { String moduleKey = value.getString(); String relativePath = value.getString(); |