001    /*
002     * Sonar, open source software quality management tool.
003     * Copyright (C) 2008-2011 SonarSource
004     * mailto:contact AT sonarsource DOT com
005     *
006     * Sonar is free software; you can redistribute it and/or
007     * modify it under the terms of the GNU Lesser General Public
008     * License as published by the Free Software Foundation; either
009     * version 3 of the License, or (at your option) any later version.
010     *
011     * Sonar is distributed in the hope that it will be useful,
012     * but WITHOUT ANY WARRANTY; without even the implied warranty of
013     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014     * Lesser General Public License for more details.
015     *
016     * You should have received a copy of the GNU Lesser General Public
017     * License along with Sonar; if not, write to the Free Software
018     * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02
019     */
020    package org.sonar.plugins.core;
021    
022    import com.google.common.collect.Lists;
023    import org.sonar.api.CoreProperties;
024    import org.sonar.api.Properties;
025    import org.sonar.api.Property;
026    import org.sonar.api.SonarPlugin;
027    import org.sonar.api.checks.NoSonarFilter;
028    import org.sonar.api.resources.Java;
029    import org.sonar.plugins.core.batch.ExcludedResourceFilter;
030    import org.sonar.plugins.core.batch.IndexProjectPostJob;
031    import org.sonar.plugins.core.batch.MavenInitializer;
032    import org.sonar.plugins.core.batch.ProjectFileSystemLogger;
033    import org.sonar.plugins.core.charts.DistributionAreaChart;
034    import org.sonar.plugins.core.charts.DistributionBarChart;
035    import org.sonar.plugins.core.charts.XradarChart;
036    import org.sonar.plugins.core.colorizers.JavaColorizerFormat;
037    import org.sonar.plugins.core.dashboards.HotspotsDashboard;
038    import org.sonar.plugins.core.dashboards.DefaultDashboard;
039    import org.sonar.plugins.core.metrics.UserManagedMetrics;
040    import org.sonar.plugins.core.security.ApplyProjectRolesDecorator;
041    import org.sonar.plugins.core.sensors.*;
042    import org.sonar.plugins.core.testdetailsviewer.TestsViewerDefinition;
043    import org.sonar.plugins.core.timemachine.*;
044    import org.sonar.plugins.core.web.Lcom4Viewer;
045    import org.sonar.plugins.core.widgets.*;
046    import org.sonar.plugins.core.widgets.actionPlans.ActionPlansWidget;
047    import org.sonar.plugins.core.widgets.reviews.FalsePositiveReviewsWidget;
048    import org.sonar.plugins.core.widgets.reviews.MyReviewsWidget;
049    import org.sonar.plugins.core.widgets.reviews.PlannedReviewsWidget;
050    import org.sonar.plugins.core.widgets.reviews.ProjectReviewsWidget;
051    import org.sonar.plugins.core.widgets.reviews.ReviewsPerDeveloperWidget;
052    import org.sonar.plugins.core.widgets.reviews.UnplannedReviewsWidget;
053    
054    import java.util.List;
055    
056    @Properties({
057      @Property(
058        key = CoreProperties.SERVER_BASE_URL,
059        defaultValue = CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE,
060        name = "Server base URL",
061        description = "HTTP URL of this Sonar server, such as <i>http://yourhost.yourdomain/sonar</i>. This value is used i.e. to create links in emails.",
062        project = false,
063        global = true,
064        category = CoreProperties.CATEGORY_GENERAL),
065      @Property(
066        key = CoreProperties.CORE_COVERAGE_PLUGIN_PROPERTY,
067        defaultValue = "cobertura",
068        name = "Code coverage plugin",
069        description = "Key of the code coverage plugin to use.",
070        project = true,
071        global = true,
072        category = CoreProperties.CATEGORY_CODE_COVERAGE),
073      @Property(
074        key = CoreProperties.CORE_IMPORT_SOURCES_PROPERTY,
075        defaultValue = "" + CoreProperties.CORE_IMPORT_SOURCES_DEFAULT_VALUE,
076        name = "Import sources",
077        description = "Set to false if sources should not be displayed, e.g. for security reasons.",
078        project = true,
079        module = true,
080        global = true,
081        category = CoreProperties.CATEGORY_SECURITY),
082      @Property(
083        key = CoreProperties.CORE_TENDENCY_DEPTH_PROPERTY,
084        defaultValue = "" + CoreProperties.CORE_TENDENCY_DEPTH_DEFAULT_VALUE,
085        name = "Tendency period",
086        description = TendencyDecorator.PROP_DAYS_DESCRIPTION,
087        project = false,
088        global = true,
089        category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
090      @Property(
091        key = CoreProperties.SKIP_TENDENCIES_PROPERTY,
092        defaultValue = "" + CoreProperties.SKIP_TENDENCIES_DEFAULT_VALUE,
093        name = "Skip tendencies",
094        description = "Skip calculation of measure tendencies",
095        project = true,
096        module = false,
097        global = true,
098        category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
099      @Property(
100        key = CoreProperties.CORE_SKIPPED_MODULES_PROPERTY,
101        name = "Exclude modules",
102        description = "Maven artifact ids of modules to exclude (comma-separated).",
103        project = true,
104        global = false,
105        category = CoreProperties.CATEGORY_GENERAL),
106      @Property(
107        key = CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY,
108        defaultValue = "" + CoreProperties.CORE_FORCE_AUTHENTICATION_DEFAULT_VALUE,
109        name = "Force user authentication",
110        description = "Forcing user authentication stops un-logged users to access Sonar.",
111        project = false,
112        global = true,
113        category = CoreProperties.CATEGORY_SECURITY),
114      @Property(
115        key = CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY,
116        defaultValue = "" + CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_DEAULT_VALUE,
117        name = "Allow users to sign up online",
118        description = "Users can sign up online.",
119        project = false,
120        global = true,
121        category = CoreProperties.CATEGORY_SECURITY),
122      @Property(
123        key = CoreProperties.CORE_DEFAULT_GROUP,
124        defaultValue = CoreProperties.CORE_DEFAULT_GROUP_DEFAULT_VALUE,
125        name = "Default user group",
126        description = "Any new users will automatically join this group.",
127        project = false,
128        global = true,
129        category = CoreProperties.CATEGORY_SECURITY),
130      @Property(
131        key = CoreProperties.CORE_VIOLATION_LOCALE_PROPERTY,
132        defaultValue = "en",
133        name = "Locale used for violation messages",
134        description = "Locale to be used when generating violation messages. It's up to each rule engine to support this global internationalization property",
135        project = true,
136        global = true,
137        category = CoreProperties.CATEGORY_L10N),
138      @Property(
139        key = "sonar.timemachine.period1",
140        name = "Period 1",
141        description = "Period used to compare measures and track new violations. Values are : <ul class='bullet'><li>Number of days before " +
142          "analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to " +
143          "compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
144        project = false,
145        global = true,
146        defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_1,
147        category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
148      @Property(
149        key = "sonar.timemachine.period2",
150        name = "Period 2",
151        description = "See the property 'Period 1'",
152        project = false,
153        global = true,
154        defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2,
155        category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
156      @Property(
157        key = "sonar.timemachine.period3",
158        name = "Period 3",
159        description = "See the property 'Period 1'",
160        project = false,
161        global = true,
162        defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_3,
163        category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
164      @Property(
165        key = "sonar.timemachine.period4",
166        name = "Period 4",
167        description = "Period used to compare measures and track new violations. This property is specific to the project. Values are : " +
168          "<ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, " +
169          "for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>",
170        project = true,
171        global = false,
172        defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4,
173        category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
174      @Property(
175        key = "sonar.timemachine.period5",
176        name = "Period 5",
177        description = "See the property 'Period 4'",
178        project = true,
179        global = false,
180        defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5,
181        category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
182    
183    
184      // SERVER-SIDE TECHNICAL PROPERTIES
185    
186      @Property(
187        key = "sonar.authenticator.downcase",
188        name = "Downcase login",
189        description = "Downcase login during user authentication, typically for Active Directory",
190        project = false,
191        global = false,
192        defaultValue = "false"),
193      @Property(
194        key = CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS,
195        name = "Create user accounts",
196        description = "Create accounts when authenticating users via an external system",
197        project = false,
198        global = false,
199        defaultValue = "false"),
200      @Property(
201        key = CoreProperties.CORE_AUTHENTICATOR_IGNORE_STARTUP_FAILURE,
202        name = "Ignore failures during authenticator startup",
203        defaultValue = "false",
204        project = false,
205        global = false)
206    })
207    public class CorePlugin extends SonarPlugin {
208    
209      @SuppressWarnings({"rawtypes", "unchecked"})
210      public List getExtensions() {
211        List extensions = Lists.newLinkedList();
212    
213        extensions.add(ProjectFileSystemLogger.class);
214    
215        // maven
216        extensions.add(MavenInitializer.class);
217    
218        // languages
219        extensions.add(Java.class);
220    
221        // metrics
222        extensions.add(UserManagedMetrics.class);
223    
224        // pages
225        extensions.add(TestsViewerDefinition.class);
226        extensions.add(Lcom4Viewer.class);
227    
228        // widgets
229        extensions.add(AlertsWidget.class);
230        extensions.add(CoverageWidget.class);
231        extensions.add(ItCoverageWidget.class);
232        extensions.add(CommentsDuplicationsWidget.class);
233        extensions.add(DescriptionWidget.class);
234        extensions.add(ComplexityWidget.class);
235        extensions.add(RulesWidget.class);
236        extensions.add(SizeWidget.class);
237        extensions.add(EventsWidget.class);
238        extensions.add(CustomMeasuresWidget.class);
239        extensions.add(TimelineWidget.class);
240        extensions.add(TimeMachineWidget.class);
241        extensions.add(HotspotMetricWidget.class);
242        extensions.add(HotspotMostViolatedResourcesWidget.class);
243        extensions.add(HotspotMostViolatedRulesWidget.class);
244        extensions.add(MyReviewsWidget.class);
245        extensions.add(ProjectReviewsWidget.class);
246        extensions.add(FalsePositiveReviewsWidget.class);
247        extensions.add(ReviewsPerDeveloperWidget.class);
248        extensions.add(PlannedReviewsWidget.class);
249        extensions.add(UnplannedReviewsWidget.class);
250        extensions.add(ActionPlansWidget.class);
251    
252        // dashboards
253        extensions.add(DefaultDashboard.class);
254        extensions.add(HotspotsDashboard.class);
255    
256        // chart
257        extensions.add(XradarChart.class);
258        extensions.add(DistributionBarChart.class);
259        extensions.add(DistributionAreaChart.class);
260    
261        // colorizers
262        extensions.add(JavaColorizerFormat.class);
263    
264        // batch
265        extensions.add(ProfileSensor.class);
266        extensions.add(ProfileEventsSensor.class);
267        extensions.add(ProjectLinksSensor.class);
268        extensions.add(UnitTestDecorator.class);
269        extensions.add(VersionEventsSensor.class);
270        extensions.add(CheckAlertThresholds.class);
271        extensions.add(GenerateAlertEvents.class);
272        extensions.add(ViolationsDecorator.class);
273        extensions.add(WeightedViolationsDecorator.class);
274        extensions.add(ViolationsDensityDecorator.class);
275        extensions.add(LineCoverageDecorator.class);
276        extensions.add(CoverageDecorator.class);
277        extensions.add(BranchCoverageDecorator.class);
278        extensions.add(ItLineCoverageDecorator.class);
279        extensions.add(ItCoverageDecorator.class);
280        extensions.add(ItBranchCoverageDecorator.class);
281        extensions.add(ApplyProjectRolesDecorator.class);
282        extensions.add(ExcludedResourceFilter.class);
283        extensions.add(CommentDensityDecorator.class);
284        extensions.add(NoSonarFilter.class);
285        extensions.add(DirectoriesDecorator.class);
286        extensions.add(FilesDecorator.class);
287        extensions.add(CloseReviewsDecorator.class);
288        extensions.add(ReferenceAnalysis.class);
289        extensions.add(ManualMeasureDecorator.class);
290        extensions.add(ManualViolationInjector.class);
291        extensions.add(UpdateReviewsDecorator.class);
292        extensions.add(ViolationSeverityUpdater.class);
293        extensions.add(IndexProjectPostJob.class);
294    
295        // time machine
296        extensions.add(TendencyDecorator.class);
297        extensions.add(VariationDecorator.class);
298        extensions.add(ViolationTrackingDecorator.class);
299        extensions.add(ViolationPersisterDecorator.class);
300        extensions.add(NewViolationsDecorator.class);
301        extensions.add(TimeMachineConfigurationPersister.class);
302        extensions.add(NewCoverageFileAnalyzer.class);
303        extensions.add(NewItCoverageFileAnalyzer.class);
304        extensions.add(NewCoverageAggregator.class);
305    
306        return extensions;
307      }
308    }