aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-batch
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-08-03 19:28:44 +0200
committerJulien HENRY <julien.henry@sonarsource.com>2015-08-03 19:28:44 +0200
commite39b1ab39d3854fbb6266d8a9048a152ee54fdb6 (patch)
tree091cf6f1f8eb67f0153b541ceb4ecb3a1346c9ad /sonar-batch
parent0b2387019db64b7acaedf298bd6335b3fd570d65 (diff)
downloadsonarqube-e39b1ab39d3854fbb6266d8a9048a152ee54fdb6.tar.gz
sonarqube-e39b1ab39d3854fbb6266d8a9048a152ee54fdb6.zip
Fix issue tracking when no server analysis
Diffstat (limited to 'sonar-batch')
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java31
1 files changed, 16 insertions, 15 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java
index 8fcbe931c36..ecd8ba5ad2c 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/issue/tracking/LocalIssueTracking.java
@@ -69,11 +69,12 @@ public class LocalIssueTracking {
private final ActiveRules activeRules;
private final BatchComponentCache componentCache;
private final ServerIssueRepository serverIssueRepository;
- private final ProjectRepositories projectRepositories;
private final AnalysisMode analysisMode;
private final ReportPublisher reportPublisher;
private final Date analysisDate;
+ private boolean hasServerAnalysis;
+
public LocalIssueTracking(BatchComponentCache resourceCache, IssueCache issueCache, IssueTracking tracking,
ServerLineHashesLoader lastLineHashes, IssueWorkflow workflow, IssueUpdater updater,
ActiveRules activeRules, ServerIssueRepository serverIssueRepository,
@@ -85,21 +86,19 @@ public class LocalIssueTracking {
this.workflow = workflow;
this.updater = updater;
this.serverIssueRepository = serverIssueRepository;
- this.projectRepositories = projectRepositories;
this.analysisMode = analysisMode;
this.reportPublisher = reportPublisher;
this.analysisDate = ((Project) resourceCache.getRoot().resource()).getAnalysisDate();
this.changeContext = IssueChangeContext.createScan(analysisDate);
this.activeRules = activeRules;
+ this.hasServerAnalysis = projectRepositories.lastAnalysisDate() != null;
}
public void execute() {
- if (projectRepositories.lastAnalysisDate() == null) {
- LOG.debug("No previous analysis, skipping issue tracking");
- return;
+ if (hasServerAnalysis) {
+ serverIssueRepository.load();
}
- serverIssueRepository.load();
BatchReportReader reader = new BatchReportReader(reportPublisher.getReportDir());
for (BatchComponent component : componentCache.all()) {
@@ -124,23 +123,25 @@ public class LocalIssueTracking {
throw new IllegalStateException("Can't read issues for " + component.key(), e);
}
- // all the issues that are not closed in db before starting this module scan, including manual issues
- Collection<ServerIssue> serverIssues = loadServerIssues(component);
+ List<DefaultIssue> trackedIssues = Lists.newArrayList();
+ if (hasServerAnalysis) {
+ // all the issues that are not closed in db before starting this module scan, including manual issues
+ Collection<ServerIssue> serverIssues = loadServerIssues(component);
- SourceHashHolder sourceHashHolder = loadSourceHashes(component);
+ SourceHashHolder sourceHashHolder = loadSourceHashes(component);
- IssueTrackingResult trackingResult = tracking.track(sourceHashHolder, serverIssues, rawIssues);
+ IssueTrackingResult trackingResult = tracking.track(sourceHashHolder, serverIssues, rawIssues);
- List<DefaultIssue> trackedIssues = Lists.newArrayList();
- // unmatched from server = issues that have been resolved + issues on disabled/removed rules + manual issues
- addUnmatchedFromServer(trackingResult.unmatched(), sourceHashHolder, trackedIssues);
+ // unmatched from server = issues that have been resolved + issues on disabled/removed rules + manual issues
+ addUnmatchedFromServer(trackingResult.unmatched(), sourceHashHolder, trackedIssues);
- mergeMatched(component, trackingResult, trackedIssues, rawIssues);
+ mergeMatched(component, trackingResult, trackedIssues, rawIssues);
+ }
// Unmatched raw issues = new issues
addUnmatchedRawIssues(component, rawIssues, trackedIssues);
- if (ResourceUtils.isRootProject(component.resource())) {
+ if (hasServerAnalysis && ResourceUtils.isRootProject(component.resource())) {
// issues that relate to deleted components
addIssuesOnDeletedComponents(trackedIssues);
}