]> source.dussan.org Git - sonarqube.git/blob
82ed25a8009f0a603e5a7c29591086e70f889e80
[sonarqube.git] /
1 /*
2  * SonarQube
3  * Copyright (C) 2009-2016 SonarSource SA
4  * mailto:contact AT sonarsource DOT com
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 3 of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19  */
20 package org.sonar.server.computation.container;
21
22 import java.util.Arrays;
23 import java.util.List;
24 import javax.annotation.Nullable;
25 import org.sonar.core.issue.tracking.Tracker;
26 import org.sonar.core.platform.ContainerPopulator;
27 import org.sonar.server.computation.analysis.AnalysisMetadataHolderImpl;
28 import org.sonar.server.computation.batch.BatchReportDirectoryHolderImpl;
29 import org.sonar.server.computation.batch.BatchReportReaderImpl;
30 import org.sonar.server.computation.component.DbIdsRepositoryImpl;
31 import org.sonar.server.computation.component.SettingsRepositoryImpl;
32 import org.sonar.server.computation.component.TreeRootHolderImpl;
33 import org.sonar.server.computation.duplication.CrossProjectDuplicationStatusHolderImpl;
34 import org.sonar.server.computation.duplication.DuplicationRepositoryImpl;
35 import org.sonar.server.computation.duplication.IntegrateCrossProjectDuplications;
36 import org.sonar.server.computation.event.EventRepositoryImpl;
37 import org.sonar.server.computation.filesystem.ComputationTempFolderProvider;
38 import org.sonar.server.computation.issue.BaseIssuesLoader;
39 import org.sonar.server.computation.issue.CloseIssuesOnRemovedComponentsVisitor;
40 import org.sonar.server.computation.issue.ComponentIssuesRepositoryImpl;
41 import org.sonar.server.computation.issue.ComponentsWithUnprocessedIssues;
42 import org.sonar.server.computation.issue.DebtCalculator;
43 import org.sonar.server.computation.issue.DefaultAssignee;
44 import org.sonar.server.computation.issue.EffortAggregator;
45 import org.sonar.server.computation.issue.IntegrateIssuesVisitor;
46 import org.sonar.server.computation.issue.IssueAssigner;
47 import org.sonar.server.computation.issue.IssueCache;
48 import org.sonar.server.computation.issue.IssueCounter;
49 import org.sonar.server.computation.issue.IssueLifecycle;
50 import org.sonar.server.computation.issue.IssueVisitors;
51 import org.sonar.server.computation.issue.LoadComponentUuidsHavingOpenIssuesVisitor;
52 import org.sonar.server.computation.issue.NewEffortAggregator;
53 import org.sonar.server.computation.issue.NewEffortCalculator;
54 import org.sonar.server.computation.issue.RuleRepositoryImpl;
55 import org.sonar.server.computation.issue.RuleTagsCopier;
56 import org.sonar.server.computation.issue.RuleTypeCopier;
57 import org.sonar.server.computation.issue.ScmAccountToUser;
58 import org.sonar.server.computation.issue.ScmAccountToUserLoader;
59 import org.sonar.server.computation.issue.TrackerBaseInputFactory;
60 import org.sonar.server.computation.issue.TrackerExecution;
61 import org.sonar.server.computation.issue.TrackerRawInputFactory;
62 import org.sonar.server.computation.issue.UpdateConflictResolver;
63 import org.sonar.server.computation.issue.commonrule.BranchCoverageRule;
64 import org.sonar.server.computation.issue.commonrule.CommentDensityRule;
65 import org.sonar.server.computation.issue.commonrule.CommonRuleEngineImpl;
66 import org.sonar.server.computation.issue.commonrule.DuplicatedBlockRule;
67 import org.sonar.server.computation.issue.commonrule.LineCoverageRule;
68 import org.sonar.server.computation.issue.commonrule.SkippedTestRule;
69 import org.sonar.server.computation.issue.commonrule.TestErrorRule;
70 import org.sonar.server.computation.language.LanguageRepositoryImpl;
71 import org.sonar.server.computation.measure.MeasureComputersHolderImpl;
72 import org.sonar.server.computation.measure.MeasureComputersVisitor;
73 import org.sonar.server.computation.measure.MeasureRepositoryImpl;
74 import org.sonar.server.computation.measure.MeasureToMeasureDto;
75 import org.sonar.server.computation.metric.MetricModule;
76 import org.sonar.server.computation.period.PeriodsHolderImpl;
77 import org.sonar.server.computation.qualitygate.EvaluationResultTextConverterImpl;
78 import org.sonar.server.computation.qualitygate.QualityGateHolderImpl;
79 import org.sonar.server.computation.qualitygate.QualityGateServiceImpl;
80 import org.sonar.server.computation.qualitymodel.NewQualityModelMeasuresVisitor;
81 import org.sonar.server.computation.qualitymodel.QualityModelMeasuresVisitor;
82 import org.sonar.server.computation.qualitymodel.RatingSettings;
83 import org.sonar.server.computation.qualityprofile.ActiveRulesHolderImpl;
84 import org.sonar.ce.queue.CeTask;
85 import org.sonar.server.computation.scm.ScmInfoRepositoryImpl;
86 import org.sonar.server.computation.source.LastCommitVisitor;
87 import org.sonar.server.computation.source.SourceHashRepositoryImpl;
88 import org.sonar.server.computation.source.SourceLinesRepositoryImpl;
89 import org.sonar.server.computation.step.ComputationStepExecutor;
90 import org.sonar.server.computation.step.ComputationSteps;
91 import org.sonar.server.computation.step.ReportComputationSteps;
92 import org.sonar.server.computation.taskprocessor.MutableTaskResultHolderImpl;
93 import org.sonar.server.devcockpit.DevCockpitBridge;
94 import org.sonar.server.view.index.ViewIndex;
95
96 public final class ReportComputeEngineContainerPopulator implements ContainerPopulator<ComputeEngineContainer> {
97   private final CeTask task;
98   private final DevCockpitBridge devCockpitBridge;
99
100   public ReportComputeEngineContainerPopulator(CeTask task, @Nullable DevCockpitBridge devCockpitBridge) {
101     this.task = task;
102     this.devCockpitBridge = devCockpitBridge;
103   }
104
105   @Override
106   public void populateContainer(ComputeEngineContainer container) {
107     ComputationSteps steps = new ReportComputationSteps(container);
108     container.add(task);
109     container.add(steps);
110     container.addSingletons(componentClasses());
111     if (devCockpitBridge != null) {
112       container.addSingletons(devCockpitBridge.getCeComponents());
113     }
114     container.addSingletons(steps.orderedStepClasses());
115   }
116
117   /**
118    * List of all objects to be injected in the picocontainer dedicated to computation stack.
119    * Does not contain the steps declared in {@link ReportComputationSteps#orderedStepClasses()}.
120    */
121   private static List componentClasses() {
122     return Arrays.asList(
123       ComputationStepExecutor.class,
124       new ComputationTempFolderProvider(),
125
126       MetricModule.class,
127
128       // holders
129       AnalysisMetadataHolderImpl.class,
130       CrossProjectDuplicationStatusHolderImpl.class,
131       BatchReportDirectoryHolderImpl.class,
132       TreeRootHolderImpl.class,
133       PeriodsHolderImpl.class,
134       QualityGateHolderImpl.class,
135       RatingSettings.class,
136       ActiveRulesHolderImpl.class,
137       MeasureComputersHolderImpl.class,
138       MutableTaskResultHolderImpl.class,
139
140       BatchReportReaderImpl.class,
141
142       // repositories
143       LanguageRepositoryImpl.class,
144       MeasureRepositoryImpl.class,
145       EventRepositoryImpl.class,
146       SettingsRepositoryImpl.class,
147       DbIdsRepositoryImpl.class,
148       QualityGateServiceImpl.class,
149       EvaluationResultTextConverterImpl.class,
150       SourceLinesRepositoryImpl.class,
151       SourceHashRepositoryImpl.class,
152       ScmInfoRepositoryImpl.class,
153       DuplicationRepositoryImpl.class,
154
155       // issues
156       RuleRepositoryImpl.class,
157       ScmAccountToUserLoader.class,
158       ScmAccountToUser.class,
159       IssueCache.class,
160       DefaultAssignee.class,
161       IssueVisitors.class,
162       IssueLifecycle.class,
163       ComponentsWithUnprocessedIssues.class,
164       ComponentIssuesRepositoryImpl.class,
165
166       // common rules
167       CommonRuleEngineImpl.class,
168       BranchCoverageRule.class,
169       LineCoverageRule.class,
170       CommentDensityRule.class,
171       DuplicatedBlockRule.class,
172       TestErrorRule.class,
173       SkippedTestRule.class,
174
175       // order is important: RuleTypeCopier must be the first one. And DebtAggregator must be before NewDebtAggregator (new debt requires debt)
176       RuleTypeCopier.class,
177       RuleTagsCopier.class,
178       DebtCalculator.class,
179       EffortAggregator.class,
180       NewEffortCalculator.class,
181       NewEffortAggregator.class,
182       IssueAssigner.class,
183       IssueCounter.class,
184
185       // visitors : order is important, measure computers must be executed at the end in order to access to every measures / issues
186       LoadComponentUuidsHavingOpenIssuesVisitor.class,
187       IntegrateIssuesVisitor.class,
188       CloseIssuesOnRemovedComponentsVisitor.class,
189       QualityModelMeasuresVisitor.class,
190       NewQualityModelMeasuresVisitor.class,
191       LastCommitVisitor.class,
192       MeasureComputersVisitor.class,
193
194       UpdateConflictResolver.class,
195       TrackerBaseInputFactory.class,
196       TrackerRawInputFactory.class,
197       Tracker.class,
198       TrackerExecution.class,
199       BaseIssuesLoader.class,
200
201       // duplication
202       IntegrateCrossProjectDuplications.class,
203
204       // views
205       ViewIndex.class,
206
207       MeasureToMeasureDto.class
208       );
209   }
210
211 }