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     */
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.DefaultDashboard;
038    import org.sonar.plugins.core.dashboards.HotspotsDashboard;
039    import org.sonar.plugins.core.dashboards.ReviewsDashboard;
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.*;
048    
049    import java.util.List;
050    
051    @Properties({
052        @Property(
053            key = CoreProperties.SERVER_BASE_URL,
054            defaultValue = CoreProperties.SERVER_BASE_URL_DEFAULT_VALUE,
055            name = "Server base URL",
056            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.",
057            project = false,
058            global = true,
059            category = CoreProperties.CATEGORY_GENERAL),
060        @Property(
061            key = CoreProperties.CORE_COVERAGE_PLUGIN_PROPERTY,
062            defaultValue = "cobertura",
063            name = "Code coverage plugin",
064            description = "Key of the code coverage plugin to use.",
065            project = true,
066            global = true,
067            category = CoreProperties.CATEGORY_CODE_COVERAGE),
068        @Property(
069            key = CoreProperties.CORE_IMPORT_SOURCES_PROPERTY,
070            defaultValue = "" + CoreProperties.CORE_IMPORT_SOURCES_DEFAULT_VALUE,
071            name = "Import sources",
072            description = "Set to false if sources should not be displayed, e.g. for security reasons.",
073            project = true,
074            module = true,
075            global = true,
076            category = CoreProperties.CATEGORY_SECURITY),
077        @Property(
078            key = CoreProperties.CORE_TENDENCY_DEPTH_PROPERTY,
079            defaultValue = "" + CoreProperties.CORE_TENDENCY_DEPTH_DEFAULT_VALUE,
080            name = "Tendency period",
081            description = TendencyDecorator.PROP_DAYS_DESCRIPTION,
082            project = false,
083            global = true,
084            category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
085        @Property(
086            key = CoreProperties.SKIP_TENDENCIES_PROPERTY,
087            defaultValue = "" + CoreProperties.SKIP_TENDENCIES_DEFAULT_VALUE,
088            name = "Skip tendencies",
089            description = "Skip calculation of measure tendencies",
090            project = true,
091            module = false,
092            global = true,
093            category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
094        @Property(
095            key = CoreProperties.CORE_SKIPPED_MODULES_PROPERTY,
096            name = "Exclude modules",
097            description = "Maven artifact ids of modules to exclude (comma-separated).",
098            project = true,
099            global = false,
100            category = CoreProperties.CATEGORY_GENERAL),
101        @Property(
102            key = CoreProperties.CORE_FORCE_AUTHENTICATION_PROPERTY,
103            defaultValue = "" + CoreProperties.CORE_FORCE_AUTHENTICATION_DEFAULT_VALUE,
104            name = "Force user authentication",
105            description = "Forcing user authentication stops un-logged users to access Sonar.",
106            project = false,
107            global = true,
108            category = CoreProperties.CATEGORY_SECURITY),
109        @Property(
110            key = CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_PROPERTY,
111            defaultValue = "" + CoreProperties.CORE_ALLOW_USERS_TO_SIGNUP_DEAULT_VALUE,
112            name = "Allow users to sign up online",
113            description = "Users can sign up online.",
114            project = false,
115            global = true,
116            category = CoreProperties.CATEGORY_SECURITY),
117        @Property(
118            key = CoreProperties.CORE_DEFAULT_GROUP,
119            defaultValue = CoreProperties.CORE_DEFAULT_GROUP_DEFAULT_VALUE,
120            name = "Default user group",
121            description = "Any new users will automatically join this group.",
122            project = false,
123            global = true,
124            category = CoreProperties.CATEGORY_SECURITY),
125        @Property(
126            key = CoreProperties.CORE_VIOLATION_LOCALE_PROPERTY,
127            defaultValue = "en",
128            name = "Locale used for violation messages",
129            description = "Locale to be used when generating violation messages. It's up to each rule engine to support this global internationalization property",
130            project = true,
131            global = true,
132            category = CoreProperties.CATEGORY_L10N),
133        @Property(
134            key = "sonar.timemachine.period1",
135            name = "Period 1",
136            description = "Period used to compare measures and track new violations. Values are : <ul class='bullet'><li>Number of days before " +
137                "analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, for example 2010-12-25</li><li>'previous_analysis' to " +
138                "compare to previous analysis</li></ul>" +
139                "Changing this property only take effect after subsequent project inspections.",
140            project = false,
141            global = true,
142            defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_1,
143            category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
144        @Property(
145            key = "sonar.timemachine.period2",
146            name = "Period 2",
147            description = "See the property 'Period 1'",
148            project = false,
149            global = true,
150            defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_2,
151            category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
152        @Property(
153            key = "sonar.timemachine.period3",
154            name = "Period 3",
155            description = "See the property 'Period 1'",
156            project = false,
157            global = true,
158            defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_3,
159            category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
160        @Property(
161            key = "sonar.timemachine.period4",
162            name = "Period 4",
163            description = "Period used to compare measures and track new violations. This property is specific to the project. Values are : " +
164                "<ul class='bullet'><li>Number of days before analysis, for example 5.</li><li>A custom date. Format is yyyy-MM-dd, " +
165                "for example 2010-12-25</li><li>'previous_analysis' to compare to previous analysis</li><li>A version, for example 1.2</li></ul>" +
166                "Changing this property only take effect after subsequent project inspection.",
167            project = true,
168            global = false,
169            defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_4,
170            category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
171        @Property(
172            key = "sonar.timemachine.period5",
173            name = "Period 5",
174            description = "See the property 'Period 4'",
175            project = true,
176            global = false,
177            defaultValue = CoreProperties.TIMEMACHINE_DEFAULT_PERIOD_5,
178            category = CoreProperties.CATEGORY_DIFFERENTIAL_VIEWS),
179    
180    
181        // SERVER-SIDE TECHNICAL PROPERTIES
182    
183        @Property(
184            key = "sonar.security.realm",
185            name = "Security Realm",
186            project = false,
187            global = false
188        ),
189        @Property(
190            key = "sonar.security.savePassword",
191            name = "Save external password",
192            project = false,
193            global = false
194        ),
195        @Property(
196            key = "sonar.authenticator.downcase",
197            name = "Downcase login",
198            description = "Downcase login during user authentication, typically for Active Directory",
199            project = false,
200            global = false,
201            defaultValue = "false"),
202        @Property(
203            key = CoreProperties.CORE_AUTHENTICATOR_CREATE_USERS,
204            name = "Create user accounts",
205            description = "Create accounts when authenticating users via an external system",
206            project = false,
207            global = false,
208            defaultValue = "true"),
209        @Property(
210            key = CoreProperties.CORE_AUTHENTICATOR_IGNORE_STARTUP_FAILURE,
211            name = "Ignore failures during authenticator startup",
212            defaultValue = "false",
213            project = false,
214            global = false)
215    })
216    public class CorePlugin extends SonarPlugin {
217    
218      @SuppressWarnings({"rawtypes", "unchecked"})
219      public List getExtensions() {
220        List extensions = Lists.newLinkedList();
221    
222        extensions.add(DefaultResourceTypes.class);
223        extensions.add(UserManagedMetrics.class);
224        extensions.add(ProjectFileSystemLogger.class);
225    
226        // maven
227        extensions.add(MavenInitializer.class);
228    
229        // languages
230        extensions.add(Java.class);
231    
232        // pages
233        extensions.add(TestsViewerDefinition.class);
234        extensions.add(Lcom4Viewer.class);
235    
236        // widgets
237        extensions.add(AlertsWidget.class);
238        extensions.add(CoverageWidget.class);
239        extensions.add(ItCoverageWidget.class);
240        extensions.add(CommentsDuplicationsWidget.class);
241        extensions.add(DescriptionWidget.class);
242        extensions.add(ComplexityWidget.class);
243        extensions.add(RulesWidget.class);
244        extensions.add(SizeWidget.class);
245        extensions.add(EventsWidget.class);
246        extensions.add(CustomMeasuresWidget.class);
247        extensions.add(TimelineWidget.class);
248        extensions.add(TimeMachineWidget.class);
249        extensions.add(HotspotMetricWidget.class);
250        extensions.add(HotspotMostViolatedResourcesWidget.class);
251        extensions.add(HotspotMostViolatedRulesWidget.class);
252        extensions.add(MyReviewsWidget.class);
253        extensions.add(ProjectReviewsWidget.class);
254        extensions.add(FalsePositiveReviewsWidget.class);
255        extensions.add(ReviewsPerDeveloperWidget.class);
256        extensions.add(PlannedReviewsWidget.class);
257        extensions.add(UnplannedReviewsWidget.class);
258        extensions.add(ActionPlansWidget.class);
259        extensions.add(ReviewsMetricsWidget.class);
260        extensions.add(TreemapWidget.class);
261    
262        // dashboards
263        extensions.add(DefaultDashboard.class);
264        extensions.add(HotspotsDashboard.class);
265        extensions.add(ReviewsDashboard.class);
266    
267        // chart
268        extensions.add(XradarChart.class);
269        extensions.add(DistributionBarChart.class);
270        extensions.add(DistributionAreaChart.class);
271    
272        // colorizers
273        extensions.add(JavaColorizerFormat.class);
274    
275        // batch
276        extensions.add(ProfileSensor.class);
277        extensions.add(ProfileEventsSensor.class);
278        extensions.add(ProjectLinksSensor.class);
279        extensions.add(UnitTestDecorator.class);
280        extensions.add(VersionEventsSensor.class);
281        extensions.add(CheckAlertThresholds.class);
282        extensions.add(GenerateAlertEvents.class);
283        extensions.add(ViolationsDecorator.class);
284        extensions.add(WeightedViolationsDecorator.class);
285        extensions.add(ViolationsDensityDecorator.class);
286        extensions.add(LineCoverageDecorator.class);
287        extensions.add(CoverageDecorator.class);
288        extensions.add(BranchCoverageDecorator.class);
289        extensions.add(ItLineCoverageDecorator.class);
290        extensions.add(ItCoverageDecorator.class);
291        extensions.add(ItBranchCoverageDecorator.class);
292        extensions.add(ApplyProjectRolesDecorator.class);
293        extensions.add(ExcludedResourceFilter.class);
294        extensions.add(CommentDensityDecorator.class);
295        extensions.add(NoSonarFilter.class);
296        extensions.add(DirectoriesDecorator.class);
297        extensions.add(FilesDecorator.class);
298        extensions.add(ReviewNotifications.class);
299        extensions.add(ReviewWorkflowDecorator.class);
300        extensions.add(ReferenceAnalysis.class);
301        extensions.add(ManualMeasureDecorator.class);
302        extensions.add(ManualViolationInjector.class);
303        extensions.add(ViolationSeverityUpdater.class);
304        extensions.add(IndexProjectPostJob.class);
305        extensions.add(ReviewsMeasuresDecorator.class);
306    
307        // time machine
308        extensions.add(TendencyDecorator.class);
309        extensions.add(VariationDecorator.class);
310        extensions.add(ViolationTrackingDecorator.class);
311        extensions.add(ViolationPersisterDecorator.class);
312        extensions.add(NewViolationsDecorator.class);
313        extensions.add(TimeMachineConfigurationPersister.class);
314        extensions.add(NewCoverageFileAnalyzer.class);
315        extensions.add(NewItCoverageFileAnalyzer.class);
316        extensions.add(NewCoverageAggregator.class);
317    
318        return extensions;
319      }
320    }