001/*
002 * Sonar, open source software quality management tool.
003 * Copyright (C) 2008-2012 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 */
020package org.sonar.plugins.core;
021
022import org.sonar.plugins.core.dashboards.MyFavouritesDashboard;
023
024import com.google.common.collect.Lists;
025import org.sonar.api.CoreProperties;
026import org.sonar.api.Extension;
027import org.sonar.api.Properties;
028import org.sonar.api.Property;
029import org.sonar.api.PropertyType;
030import org.sonar.api.SonarPlugin;
031import org.sonar.api.checks.NoSonarFilter;
032import org.sonar.api.resources.Java;
033import org.sonar.plugins.core.batch.ExcludedResourceFilter;
034import org.sonar.plugins.core.batch.IndexProjectPostJob;
035import org.sonar.plugins.core.batch.MavenInitializer;
036import org.sonar.plugins.core.batch.ProjectFileSystemLogger;
037import org.sonar.plugins.core.charts.DistributionAreaChart;
038import org.sonar.plugins.core.charts.DistributionBarChart;
039import org.sonar.plugins.core.charts.XradarChart;
040import org.sonar.plugins.core.colorizers.JavaColorizerFormat;
041import org.sonar.plugins.core.dashboards.DefaultDashboard;
042import org.sonar.plugins.core.dashboards.HotspotsDashboard;
043import org.sonar.plugins.core.dashboards.ProjectsDashboard;
044import org.sonar.plugins.core.dashboards.ReviewsDashboard;
045import org.sonar.plugins.core.dashboards.TimeMachineDashboard;
046import org.sonar.plugins.core.dashboards.TreemapDashboard;
047import org.sonar.plugins.core.filters.MyFavouritesFilter;
048import org.sonar.plugins.core.filters.ProjectFilter;
049import org.sonar.plugins.core.filters.TreeMapFilter;
050import org.sonar.plugins.core.security.ApplyProjectRolesDecorator;
051import org.sonar.plugins.core.sensors.BranchCoverageDecorator;
052import org.sonar.plugins.core.sensors.CheckAlertThresholds;
053import org.sonar.plugins.core.sensors.CommentDensityDecorator;
054import org.sonar.plugins.core.sensors.CoverageDecorator;
055import org.sonar.plugins.core.sensors.DirectoriesDecorator;
056import org.sonar.plugins.core.sensors.FilesDecorator;
057import org.sonar.plugins.core.sensors.GenerateAlertEvents;
058import org.sonar.plugins.core.sensors.ItBranchCoverageDecorator;
059import org.sonar.plugins.core.sensors.ItCoverageDecorator;
060import org.sonar.plugins.core.sensors.ItLineCoverageDecorator;
061import org.sonar.plugins.core.sensors.LineCoverageDecorator;
062import org.sonar.plugins.core.sensors.ManualMeasureDecorator;
063import org.sonar.plugins.core.sensors.ManualViolationInjector;
064import org.sonar.plugins.core.sensors.ProfileEventsSensor;
065import org.sonar.plugins.core.sensors.ProfileSensor;
066import org.sonar.plugins.core.sensors.ProjectLinksSensor;
067import org.sonar.plugins.core.sensors.ReviewNotifications;
068import org.sonar.plugins.core.sensors.ReviewWorkflowDecorator;
069import org.sonar.plugins.core.sensors.ReviewsMeasuresDecorator;
070import org.sonar.plugins.core.sensors.UnitTestDecorator;
071import org.sonar.plugins.core.sensors.VersionEventsSensor;
072import org.sonar.plugins.core.sensors.ViolationSeverityUpdater;
073import org.sonar.plugins.core.sensors.ViolationsDecorator;
074import org.sonar.plugins.core.sensors.ViolationsDensityDecorator;
075import org.sonar.plugins.core.sensors.WeightedViolationsDecorator;
076import org.sonar.plugins.core.testdetailsviewer.TestsViewerDefinition;
077import org.sonar.plugins.core.timemachine.NewCoverageAggregator;
078import org.sonar.plugins.core.timemachine.NewCoverageFileAnalyzer;
079import org.sonar.plugins.core.timemachine.NewItCoverageFileAnalyzer;
080import org.sonar.plugins.core.timemachine.NewViolationsDecorator;
081import org.sonar.plugins.core.timemachine.ReferenceAnalysis;
082import org.sonar.plugins.core.timemachine.TendencyDecorator;
083import org.sonar.plugins.core.timemachine.TimeMachineConfigurationPersister;
084import org.sonar.plugins.core.timemachine.VariationDecorator;
085import org.sonar.plugins.core.timemachine.ViolationPersisterDecorator;
086import org.sonar.plugins.core.timemachine.ViolationTrackingDecorator;
087import org.sonar.plugins.core.web.Lcom4Viewer;
088import org.sonar.plugins.core.widgets.AlertsWidget;
089import org.sonar.plugins.core.widgets.CommentsDuplicationsWidget;
090import org.sonar.plugins.core.widgets.ComplexityWidget;
091import org.sonar.plugins.core.widgets.CoverageWidget;
092import org.sonar.plugins.core.widgets.CustomMeasuresWidget;
093import org.sonar.plugins.core.widgets.DescriptionWidget;
094import org.sonar.plugins.core.widgets.EventsWidget;
095import org.sonar.plugins.core.widgets.FilterWidget;
096import org.sonar.plugins.core.widgets.HotspotMetricWidget;
097import org.sonar.plugins.core.widgets.HotspotMostViolatedResourcesWidget;
098import org.sonar.plugins.core.widgets.HotspotMostViolatedRulesWidget;
099import org.sonar.plugins.core.widgets.ItCoverageWidget;
100import org.sonar.plugins.core.widgets.RulesWidget;
101import org.sonar.plugins.core.widgets.SizeWidget;
102import org.sonar.plugins.core.widgets.TimeMachineWidget;
103import org.sonar.plugins.core.widgets.TimelineWidget;
104import org.sonar.plugins.core.widgets.TreemapWidget;
105import org.sonar.plugins.core.widgets.actionPlans.ActionPlansWidget;
106import org.sonar.plugins.core.widgets.reviews.FalsePositiveReviewsWidget;
107import org.sonar.plugins.core.widgets.reviews.MyReviewsWidget;
108import org.sonar.plugins.core.widgets.reviews.PlannedReviewsWidget;
109import org.sonar.plugins.core.widgets.reviews.ProjectReviewsWidget;
110import org.sonar.plugins.core.widgets.reviews.ReviewsMetricsWidget;
111import org.sonar.plugins.core.widgets.reviews.ReviewsPerDeveloperWidget;
112import org.sonar.plugins.core.widgets.reviews.UnplannedReviewsWidget;
113
114import java.util.List;
115
116@Properties({
117  @Property(
118    key = CoreProperties.SERVER_BASE_URL,
119    defaultValue = CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE,
120    name = "Server base URL",
121    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.",
122    project = false,
123    global = true,
124    category = CoreProperties.CATEGORY_GENERAL),
125  @Property(
126    key = CoreProperties.CORE_COVERAGE_PLUGIN_PROPERTY,
127    defaultValue = "cobertura",
128    name = "Code coverage plugin",
129    description = "Key of the code coverage plugin to use.",
130    project = true,
131    global = true,
132    category = CoreProperties.CATEGORY_CODE_COVERAGE),
133  @Property(
134    key = CoreProperties.CORE_IMPORT_SOURCES_PROPERTY,
135    defaultValue = "" + CoreProperties.CORE_IMPORT_SOURCES_DEFAULT_VALUE,
136    name = "Import sources",
137    description = "Set to false if sources should not be displayed, e.g. for security reasons.",
138    project = true,
139    module = true,
140    global = true,
141    category = CoreProperties.CATEGORY_SECURITY,
142    type = PropertyType.BOOLEAN),
143  @Property(
144    key = CoreProperties.CORE_TENDENCY_DEPTH_PROPERTY,
145    defaultValue = "" + CoreProperties.CORE_TENDENCY_DEPTH_DEFAULT_VALUE,
146    name = "Tendency period",
147    description = TendencyDecorator.PROP_DAYS_DESCRIPTION,
148    project = false,
149    global = true,
150    category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS,
151    type = PropertyType.INTEGER),
152  @Property(
153    key = CoreProperties.SKIP_TENDENCIES_PROPERTY,
154    defaultValue = "" + CoreProperties.SKIP_TENDENCIES_DEFAULT_VALUE,
155    name = "Skip tendencies",
156    description = "Skip calculation of measure tendencies",
157    project = true,
158    module = false,
159    global = true,
160    category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS,
161    type = PropertyType.BOOLEAN),
162  @Property(
163    key = CoreProperties.CORE_SKIPPED_MODULES_PROPERTY,
164    name = "Exclude modules",
165    description = "Maven artifact ids of modules to exclude (comma-separated).",
166    project = true,
167    global = false,
168    category = CoreProperties.CATEGORY_GENERAL),
169  @Property(
170    key = CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY,
171    defaultValue = "" + CoreProperties.CORE_FORCE_AUTHENTICATION_DEFAULT_VALUE,
172    name = "Force user authentication",
173    description = "Forcing user authentication stops un-logged users to access Sonar.",
174    project = false,
175    global = true,
176    category = CoreProperties.CATEGORY_SECURITY,
177    type = PropertyType.BOOLEAN),
178  @Property(
179    key = CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY,
180    defaultValue = "" + CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_DEAULT_VALUE,
181    name = "Allow users to sign up online",
182    description = "Users can sign up online.",
183    project = false,
184    global = true,
185    category = CoreProperties.CATEGORY_SECURITY,
186    type = PropertyType.BOOLEAN),
187  @Property(
188    key = CoreProperties.CORE_DEFAULT_GROUP,
189    defaultValue = CoreProperties.CORE_DEFAULT_GROUP_DEFAULT_VALUE,
190    name = "Default user group",
191    description = "Any new users will automatically join this group.",
192    project = false,
193    global = true,
194    category = CoreProperties.CATEGORY_SECURITY),
195  @Property(
196    key = CoreProperties.CORE_VIOLATION_LOCALE_PROPERTY,
197    defaultValue = "en",
198    name = "Locale used for violation messages",
199    description = "Locale to be used when generating violation messages. It's up to each rule engine to support this global internationalization property",
200    project = true,
201    global = true,
202    category = CoreProperties.CATEGORY_L10N),
203  @Property(
204    key = "sonar.timemachine.period1",
205    name = "Period 1",
206    description = "Period used to compare measures and track new violations. Values are : <ul class='bullet'><li>Number of days before " +
207      "analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to " +
208      "compare to previous analysis</li></ul>" + "<p>When specifying a number of days or a date, the snapshot selected for comparison is " +
209      " the first one available inside the corresponding time range. </p>" +
210      "<p>Changing this property only takes effect after subsequent project inspections.<p/>",
211    project = false,
212    global = true,
213    defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_1,
214    category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
215  @Property(
216    key = "sonar.timemachine.period2",
217    name = "Period 2",
218    description = "See the property 'Period 1'",
219    project = false,
220    global = true,
221    defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2,
222    category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
223  @Property(
224    key = "sonar.timemachine.period3",
225    name = "Period 3",
226    description = "See the property 'Period 1'",
227    project = false,
228    global = true,
229    defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_3,
230    category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
231  @Property(
232    key = "sonar.timemachine.period4",
233    name = "Period 4",
234    description = "Period used to compare measures and track new violations. This property is specific to the project. Values are : " +
235      "<ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, " +
236      "for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>" +
237      "<p>When specifying a number of days or a date, the snapshot selected for comparison is the first one available inside the corresponding time range. </p>" +
238      "<p>Changing this property only takes effect after subsequent project inspections.<p/>",
239    project = true,
240    global = false,
241    defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4,
242    category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
243  @Property(
244    key = "sonar.timemachine.period5",
245    name = "Period 5",
246    description = "See the property 'Period 4'",
247    project = true,
248    global = false,
249    defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5,
250    category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
251
252  // SERVER-SIDE TECHNICAL PROPERTIES
253
254  @Property(
255    key = "sonar.security.realm",
256    name = "Security Realm",
257    project = false,
258    global = false
259  ),
260  @Property(
261    key = "sonar.security.savePassword",
262    name = "Save external password",
263    project = false,
264    global = false
265  ),
266  @Property(
267    key = "sonar.authenticator.downcase",
268    name = "Downcase login",
269    description = "Downcase login during user authentication, typically for Active Directory",
270    project = false,
271    global = false,
272    defaultValue = "false",
273    type = PropertyType.BOOLEAN),
274  @Property(
275    key = CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS,
276    name = "Create user accounts",
277    description = "Create accounts when authenticating users via an external system",
278    project = false,
279    global = false,
280    defaultValue = "true",
281    type = PropertyType.BOOLEAN),
282  @Property(
283    key = CoreProperties.CORE_AUTHENTICATOR_IGNORE_STARTUP_FAILURE,
284    name = "Ignore failures during authenticator startup",
285    defaultValue = "false",
286    project = false,
287    global = false,
288    type = PropertyType.BOOLEAN)
289})
290public final class CorePlugin extends SonarPlugin {
291
292  @SuppressWarnings({"rawtypes", "unchecked"})
293  public List<Class<? extends Extension>> getExtensions() {
294    List extensions = Lists.newLinkedList();
295
296    extensions.add(DefaultResourceTypes.class);
297    extensions.add(UserManagedMetrics.class);
298    extensions.add(ProjectFileSystemLogger.class);
299
300    // maven
301    extensions.add(MavenInitializer.class);
302
303    // languages
304    extensions.add(Java.class);
305
306    // pages
307    extensions.add(TestsViewerDefinition.class);
308    extensions.add(Lcom4Viewer.class);
309
310    // filters
311    extensions.add(ProjectFilter.class);
312    extensions.add(TreeMapFilter.class);
313    extensions.add(MyFavouritesFilter.class);
314
315    // widgets
316    extensions.add(AlertsWidget.class);
317    extensions.add(CoverageWidget.class);
318    extensions.add(ItCoverageWidget.class);
319    extensions.add(CommentsDuplicationsWidget.class);
320    extensions.add(DescriptionWidget.class);
321    extensions.add(ComplexityWidget.class);
322    extensions.add(RulesWidget.class);
323    extensions.add(SizeWidget.class);
324    extensions.add(EventsWidget.class);
325    extensions.add(CustomMeasuresWidget.class);
326    extensions.add(TimelineWidget.class);
327    extensions.add(TimeMachineWidget.class);
328    extensions.add(HotspotMetricWidget.class);
329    extensions.add(HotspotMostViolatedResourcesWidget.class);
330    extensions.add(HotspotMostViolatedRulesWidget.class);
331    extensions.add(MyReviewsWidget.class);
332    extensions.add(ProjectReviewsWidget.class);
333    extensions.add(FalsePositiveReviewsWidget.class);
334    extensions.add(ReviewsPerDeveloperWidget.class);
335    extensions.add(PlannedReviewsWidget.class);
336    extensions.add(UnplannedReviewsWidget.class);
337    extensions.add(ActionPlansWidget.class);
338    extensions.add(ReviewsMetricsWidget.class);
339    extensions.add(TreemapWidget.class);
340    extensions.add(FilterWidget.class);
341
342    // dashboards
343    extensions.add(DefaultDashboard.class);
344    extensions.add(HotspotsDashboard.class);
345    extensions.add(ReviewsDashboard.class);
346    extensions.add(TimeMachineDashboard.class);
347    extensions.add(ProjectsDashboard.class);
348    extensions.add(TreemapDashboard.class);
349    extensions.add(MyFavouritesDashboard.class);
350
351    // chart
352    extensions.add(XradarChart.class);
353    extensions.add(DistributionBarChart.class);
354    extensions.add(DistributionAreaChart.class);
355
356    // colorizers
357    extensions.add(JavaColorizerFormat.class);
358
359    // batch
360    extensions.add(ProfileSensor.class);
361    extensions.add(ProfileEventsSensor.class);
362    extensions.add(ProjectLinksSensor.class);
363    extensions.add(UnitTestDecorator.class);
364    extensions.add(VersionEventsSensor.class);
365    extensions.add(CheckAlertThresholds.class);
366    extensions.add(GenerateAlertEvents.class);
367    extensions.add(ViolationsDecorator.class);
368    extensions.add(WeightedViolationsDecorator.class);
369    extensions.add(ViolationsDensityDecorator.class);
370    extensions.add(LineCoverageDecorator.class);
371    extensions.add(CoverageDecorator.class);
372    extensions.add(BranchCoverageDecorator.class);
373    extensions.add(ItLineCoverageDecorator.class);
374    extensions.add(ItCoverageDecorator.class);
375    extensions.add(ItBranchCoverageDecorator.class);
376    extensions.add(ApplyProjectRolesDecorator.class);
377    extensions.add(ExcludedResourceFilter.class);
378    extensions.add(CommentDensityDecorator.class);
379    extensions.add(NoSonarFilter.class);
380    extensions.add(DirectoriesDecorator.class);
381    extensions.add(FilesDecorator.class);
382    extensions.add(ReviewNotifications.class);
383    extensions.add(ReviewWorkflowDecorator.class);
384    extensions.add(ReferenceAnalysis.class);
385    extensions.add(ManualMeasureDecorator.class);
386    extensions.add(ManualViolationInjector.class);
387    extensions.add(ViolationSeverityUpdater.class);
388    extensions.add(IndexProjectPostJob.class);
389    extensions.add(ReviewsMeasuresDecorator.class);
390
391    // time machine
392    extensions.add(TendencyDecorator.class);
393    extensions.add(VariationDecorator.class);
394    extensions.add(ViolationTrackingDecorator.class);
395    extensions.add(ViolationPersisterDecorator.class);
396    extensions.add(NewViolationsDecorator.class);
397    extensions.add(TimeMachineConfigurationPersister.class);
398    extensions.add(NewCoverageFileAnalyzer.class);
399    extensions.add(NewItCoverageFileAnalyzer.class);
400    extensions.add(NewCoverageAggregator.class);
401
402    return extensions;
403  }
404}