├── .gitignore
├── Jenkinsfile
├── src
├── test
│ ├── resources
│ │ ├── .ignore
│ │ └── checkstyle-result-build2.xml
│ └── java
│ │ └── hudson
│ │ └── plugins
│ │ └── analysis
│ │ └── collector
│ │ ├── AnalysisResultTest.java
│ │ ├── AnalysisHealthDescriptorTest.java
│ │ ├── Main.java
│ │ ├── workflow
│ │ └── WorkflowCompatibilityTest.java
│ │ └── AnalysisGraphConfigurationTest.java
└── main
│ ├── resources
│ ├── graph
│ │ ├── taglib
│ │ ├── deactivate.properties
│ │ ├── deactivate_de.properties
│ │ ├── tools_de.properties
│ │ ├── deactivate_ja.properties
│ │ ├── deactivate.jelly
│ │ ├── deactivate_zh_TW.properties
│ │ ├── tools_zh_TW.properties
│ │ └── tools.jelly
│ ├── hudson
│ │ └── plugins
│ │ │ └── analysis
│ │ │ └── collector
│ │ │ ├── WarningsCountColumn
│ │ │ ├── columnHeader_de.properties
│ │ │ ├── columnHeader.jelly
│ │ │ ├── config.jelly
│ │ │ └── column.jelly
│ │ │ ├── Messages_fr.properties
│ │ │ ├── dashboard
│ │ │ ├── WarningsTablePortlet
│ │ │ │ ├── WarningsPerJobDescriptor
│ │ │ │ │ ├── local-config_de.properties
│ │ │ │ │ ├── local-config_ja.properties
│ │ │ │ │ ├── local-config.jelly
│ │ │ │ │ ├── local-config_fr.properties
│ │ │ │ │ └── local-config_zh_TW.properties
│ │ │ │ ├── portlet_de.properties
│ │ │ │ ├── portlet_ja.properties
│ │ │ │ ├── portlet_fr.properties
│ │ │ │ ├── portlet_zh_TW.properties
│ │ │ │ └── portlet.jelly
│ │ │ └── WarningsOriginGraphPortlet
│ │ │ │ └── WarningsGraphDescriptor
│ │ │ │ └── local-config.jelly
│ │ │ ├── Messages_de.properties
│ │ │ ├── tokens
│ │ │ ├── WarningsCountTokenMacro
│ │ │ │ └── help.jelly
│ │ │ ├── NewWarningsCountTokenMacro
│ │ │ │ └── help.jelly
│ │ │ ├── FixedWarningsCountTokenMacro
│ │ │ │ └── help.jelly
│ │ │ └── WarningsResultTokenMacro
│ │ │ │ └── help.jelly
│ │ │ ├── AnalysisPublisher
│ │ │ ├── global.jelly
│ │ │ └── config.jelly
│ │ │ ├── AnalysisProjectAction
│ │ │ ├── jobMain_de.properties
│ │ │ └── jobMain.jelly
│ │ │ ├── AnalysisUserGraphConfigurationView
│ │ │ └── local-config.jelly
│ │ │ ├── AnalysisDefaultGraphConfigurationView
│ │ │ └── local-config.jelly
│ │ │ ├── Messages.properties
│ │ │ ├── Messages_ja.properties
│ │ │ └── Messages_zh_TW.properties
│ └── index.jelly
│ ├── webapp
│ ├── icons
│ │ ├── ORIGIN.png
│ │ ├── analysis-24x24.png
│ │ └── analysis-48x48.png
│ ├── help_zh_TW.html
│ ├── help.html
│ └── help_de.html
│ └── java
│ └── hudson
│ └── plugins
│ └── analysis
│ └── collector
│ ├── tokens
│ ├── WarningsResultTokenMacro.java
│ ├── WarningsCountTokenMacro.java
│ ├── NewWarningsCountTokenMacro.java
│ └── FixedWarningsCountTokenMacro.java
│ ├── handler
│ ├── DryHandler.java
│ ├── PmdHandler.java
│ ├── TasksHandler.java
│ ├── FindBugsHandler.java
│ ├── AnalysisHandler.java
│ ├── CheckStyleHandler.java
│ ├── AndroidLintHandler.java
│ └── WarningsHandler.java
│ ├── AnalysisHealthDescriptor.java
│ ├── AnalysisResultAction.java
│ ├── dashboard
│ ├── WarningsTotalsGraphPortlet.java
│ ├── WarningsPriorityGraphPortlet.java
│ ├── WarningsUserGraphPortlet.java
│ ├── WarningsNewVersusFixedGraphPortlet.java
│ ├── WarningsOriginGraphPortlet.java
│ └── WarningsTablePortlet.java
│ ├── AnalysisDefaultGraphConfigurationView.java
│ ├── AnalysisAnnotationsAggregator.java
│ ├── AnalysisUserGraphConfigurationView.java
│ ├── AnalysisGraphConfiguration.java
│ ├── AnalysisResult.java
│ ├── AnalysisDescriptor.java
│ ├── OriginGraph.java
│ ├── AnalysisProjectAction.java
│ ├── AnalysisPublisher.java
│ ├── WarningsCountColumn.java
│ └── WarningsAggregator.java
├── german.sh
├── .settings
├── org.moreunit.prefs
├── org.eclipse.m2e.core.prefs
├── org.eclipse.core.resources.prefs
└── org.eclipse.jdt.ui.prefs
├── release.sh
├── clean.sh
├── debug.sh
├── go.sh
├── README.txt
├── .pmd
├── .checkstyle
├── License.txt
├── pom.xml
└── .fbprefs
/.gitignore:
--------------------------------------------------------------------------------
1 | target
2 |
--------------------------------------------------------------------------------
/Jenkinsfile:
--------------------------------------------------------------------------------
1 | buildPlugin()
--------------------------------------------------------------------------------
/src/test/resources/.ignore:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/main/resources/graph/taglib:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/german.sh:
--------------------------------------------------------------------------------
1 | mvn compile stapler:i18n -Dlocale=de
2 |
3 |
--------------------------------------------------------------------------------
/.settings/org.moreunit.prefs:
--------------------------------------------------------------------------------
1 | eclipse.preferences.version=1
2 | org.moreunit.preferences.version=2
3 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/analysis/collector/WarningsCountColumn/columnHeader_de.properties:
--------------------------------------------------------------------------------
1 | \#\ Warnings=# Warnungen
2 |
--------------------------------------------------------------------------------
/release.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | git pull
4 | git push
5 | mvn -B -Djava.net.id=drulli release:prepare release:perform
6 |
7 |
8 |
--------------------------------------------------------------------------------
/src/main/webapp/icons/ORIGIN.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/analysis-collector-plugin/master/src/main/webapp/icons/ORIGIN.png
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/analysis/collector/Messages_fr.properties:
--------------------------------------------------------------------------------
1 | Analysis.ResultAction.Header=R\u00E9sultats des Analyses Statiques
--------------------------------------------------------------------------------
/src/main/webapp/icons/analysis-24x24.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/analysis-collector-plugin/master/src/main/webapp/icons/analysis-24x24.png
--------------------------------------------------------------------------------
/src/main/webapp/icons/analysis-48x48.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jenkinsci/analysis-collector-plugin/master/src/main/webapp/icons/analysis-48x48.png
--------------------------------------------------------------------------------
/.settings/org.eclipse.m2e.core.prefs:
--------------------------------------------------------------------------------
1 | #Wed Jun 22 15:14:09 CEST 2011
2 | activeProfiles=
3 | eclipse.preferences.version=1
4 | resolveWorkspaceProjects=true
5 | version=1
6 |
--------------------------------------------------------------------------------
/clean.sh:
--------------------------------------------------------------------------------
1 | rm -rf $JENKINS_HOME/plugins/analysis-collector*
2 |
3 | mvn clean install
4 | cp -f target/*.hpi $JENKINS_HOME/plugins/
5 |
6 | cd $JENKINS_HOME
7 | ./go.sh
8 |
--------------------------------------------------------------------------------
/src/main/resources/graph/deactivate.properties:
--------------------------------------------------------------------------------
1 | disable.title=Disable other trend graphs
2 | disable.description=Disable the trend graphs of all other static analysis plug-ins
3 |
--------------------------------------------------------------------------------
/debug.sh:
--------------------------------------------------------------------------------
1 | export MAVEN_OPTS="-Xmx1024m -Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=8000,suspend=n"
2 | rm -rf $JENKINS_HOME/plugins/analysis-collector*
3 | mvn hpi:run
4 |
--------------------------------------------------------------------------------
/src/main/resources/graph/deactivate_de.properties:
--------------------------------------------------------------------------------
1 | disable.title=Deaktiviere einzelne Trend Graphen
2 | disable.description=Deaktiviere die Trend Graphen der anderen Analyse Plug-ins
3 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet/WarningsPerJobDescriptor/local-config_de.properties:
--------------------------------------------------------------------------------
1 | Show\ images\ in\ table\ header=Nutze Icons im Titel
2 |
--------------------------------------------------------------------------------
/go.sh:
--------------------------------------------------------------------------------
1 | rm -rf $JENKINS_HOME/plugins/analysis-collector*
2 |
3 | mvn install || { echo "Build failed"; exit 1; }
4 |
5 | cp -f target/*.hpi $JENKINS_HOME/plugins/
6 | cd $JENKINS_HOME
7 | ./go.sh
8 |
9 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/analysis/collector/WarningsCountColumn/columnHeader.jelly:
--------------------------------------------------------------------------------
1 |
2 | ${%# Warnings}
4 |
3 | 啟用這個選項後,Jenkins 會把 Checkstyle, Dry, FindBugs, PMD, Tasks 及 Warnings 4 | 等靜態程式分析外掛程式全部彙總起來。彙總後的分析結果可以用來產出歷史結果趨勢、模組及套件 (Package) 5 | 統計、檢視分析報告及警告的網頁畫面、健康狀態報告及建置穩定性。 6 |
7 |3 | When this option is configured Jenkins aggregates the results of the static analysis plug-ins 4 | Checkstyle, Dry, FindBugs, PMD, Tasks, and Warnings. These aggregated analysis results are then 5 | used as input for the historical result trend, module and package statistics, web UI for viewing 6 | analysis reports and warnings, health reporting and build stability. 7 |
8 |3 | Wenn dieses Plug-in aktiviert wird, fasst Jenkins nach jedem Build die Ergebnisse der statischen 4 | Analyse Plug-ins Checkstyle, Dry, FindBugs, PMD, Tasks und Warnings zusammen. Diese zusammengefassten 5 | Ergebnisse werden dann als Eingabe für die verschiedenen Ansichten verwendet: Trend 6 | Anzeige, Projekt und Package Statistiken, usw. Zudem zeigt Jenkins die jeweiligen Warnungen direkt in 7 | der betroffen Datei an. Ebenso wir der Gesundsheitszustand und die Build Stabilität auf den 8 | zusammengefassten Ergebnissen berechnet. 9 |
10 |summary.jelly file.
17 | * 18 | * Moreover, this class renders the warnings result trend. 19 | *
20 | * 21 | * @author Ulli Hafner 22 | */ 23 | public class AnalysisResultAction extends AbstractResultActiontrue if the trend graphs of the other plug-ins could be deactivated
63 | */
64 | public boolean canDeacticateOtherTrendGraphs() {
65 | return analysisConfiguration.canDeacticateOtherTrendGraphs();
66 | }
67 | }
68 |
69 |
--------------------------------------------------------------------------------
/src/main/java/hudson/plugins/analysis/collector/AnalysisAnnotationsAggregator.java:
--------------------------------------------------------------------------------
1 | package hudson.plugins.analysis.collector;
2 |
3 | import hudson.Launcher;
4 | import hudson.matrix.MatrixRun;
5 | import hudson.matrix.MatrixBuild;
6 | import hudson.model.Action;
7 | import hudson.model.BuildListener;
8 | import hudson.plugins.analysis.core.AnnotationsAggregator;
9 | import hudson.plugins.analysis.core.HealthDescriptor;
10 | import hudson.plugins.analysis.core.ParserResult;
11 |
12 | /**
13 | * Aggregates {@link AnalysisResultAction}s of {@link MatrixRun}s into
14 | * {@link MatrixBuild}.
15 | *
16 | * @author Ulli Hafner
17 | */
18 | public class AnalysisAnnotationsAggregator extends AnnotationsAggregator {
19 | /**
20 | * Creates a new instance of {@link AnnotationsAggregator}.
21 | *
22 | * @param build
23 | * the matrix build
24 | * @param launcher
25 | * the launcher
26 | * @param listener
27 | * the build listener
28 | * @param healthDescriptor
29 | * health descriptor
30 | * @param defaultEncoding
31 | * the default encoding to be used when reading and parsing files
32 | * @param usePreviousBuildAsReference
33 | * determines whether the previous build should be used as the
34 | * reference build
35 | * @param useStableBuildAsReference
36 | * determines whether only stable builds should be used as
37 | * reference builds or not
38 | */
39 | public AnalysisAnnotationsAggregator(final MatrixBuild build, final Launcher launcher,
40 | final BuildListener listener, final HealthDescriptor healthDescriptor, final String defaultEncoding,
41 | final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) {
42 | super(build, launcher, listener, healthDescriptor, defaultEncoding,
43 | usePreviousBuildAsReference, useStableBuildAsReference);
44 | }
45 |
46 | @Override
47 | protected Action createAction(final HealthDescriptor healthDescriptor, final String defaultEncoding, final ParserResult aggregatedResult) {
48 | return new AnalysisResultAction(build, healthDescriptor,
49 | new AnalysisResult(build, defaultEncoding, aggregatedResult,
50 | usePreviousBuildAsReference(), useOnlyStableBuildsAsReference()));
51 | }
52 |
53 | @Override
54 | protected boolean hasResult(final MatrixRun run) {
55 | return getAction(run) != null;
56 | }
57 |
58 | @Override
59 | protected AnalysisResult getResult(final MatrixRun run) {
60 | return getAction(run).getResult();
61 | }
62 |
63 | private AnalysisResultAction getAction(final MatrixRun run) {
64 | return run.getAction(AnalysisResultAction.class);
65 | }
66 | }
67 |
68 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/analysis/collector/Messages_zh_TW.properties:
--------------------------------------------------------------------------------
1 | # The MIT License
2 | #
3 | # Copyright (c) 2013, Chunghwa Telecom Co., Ltd., Pei-Tang Huang
4 | #
5 | # Permission is hereby granted, free of charge, to any person obtaining a copy
6 | # of this software and associated documentation files (the "Software"), to deal
7 | # in the Software without restriction, including without limitation the rights
8 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | # copies of the Software, and to permit persons to whom the Software is
10 | # furnished to do so, subject to the following conditions:
11 | #
12 | # The above copyright notice and this permission notice shall be included in
13 | # all copies or substantial portions of the Software.
14 | #
15 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | # THE SOFTWARE.
22 |
23 | Analysis.Publisher.Name=\u767c\u4f48\u5408\u4f75\u5206\u6790\u7d50\u679c
24 |
25 | Analysis.ProjectAction.Name=\u975c\u614b\u5206\u6790\u8b66\u544a
26 |
27 | Analysis.Trend.Name=\u975c\u614b\u5206\u6790\u8da8\u52e2
28 |
29 | Analysis.ResultAction.Header=\u975c\u614b\u5206\u6790\u7d50\u679c
30 |
31 | Analysis.ResultAction.HealthReportNoItem=\u5206\u6790: \u627e\u4e0d\u5230\u8b66\u544a\u3002
32 | Analysis.ResultAction.HealthReportSingleItem=\u5206\u6790: \u627e\u5230 1 \u9805\u8b66\u544a\u3002
33 | Analysis.ResultAction.HealthReportMultipleItem=\u5206\u6790: \u627e\u5230 {0} \u9805\u8b66\u544a\u3002
34 |
35 | Analysis.Detail.header=\u975c\u614b\u5206\u6790\u8b66\u544a
36 |
37 | Analysis.FixedWarnings.Detail.header=\u5df2\u4fee\u6b63\u7684\u8b66\u544a
38 | Analysis.NewWarnings.Detail.header=\u65b0\u7684\u8b66\u544a
39 |
40 | Analysis.Checkstyle.Warning.Origin=Checkstyle
41 | Analysis.Dry.Warning.Origin=\u91cd\u8907\u7a0b\u5f0f\u78bc
42 | Analysis.FindBugs.Warning.Origin=FindBugs
43 | Analysis.PMD.Warning.Origin=PMD
44 | Analysis.Tasks.Warning.Origin=\u672a\u89e3\u5de5\u4f5c
45 | Analysis.Warnings.Warning.Origin=\u7de8\u8b6f\u5668
46 |
47 | Trend.type.analysis=\u8b66\u544a\u985e\u578b\u5206\u4f48
48 |
49 | Portlet.WarningsTable=\u5404\u5c08\u6848\u7684\u8b66\u544a
50 | Portlet.WarningsPriorityGraph=\u8b66\u544a\u8da8\u52e2\u5716 (\u512a\u5148\u9806\u5e8f\u5206\u4f48)
51 | Portlet.WarningsNewVsFixedGraph=\u8b66\u544a\u8da8\u52e2\u5716 (\u65b0\u589e\u8207\u4fee\u6b63)
52 | Portlet.WarningsOriginGraph=\u8b66\u544a\u8da8\u52e2\u5716 (\u985e\u578b\u5206\u4f48)
53 | Portlet.WarningsTotalsGraph=\u8b66\u544a\u8da8\u52e2\u5716 (\u7e3d\u8a08)
54 |
55 |
--------------------------------------------------------------------------------
/src/main/java/hudson/plugins/analysis/collector/AnalysisUserGraphConfigurationView.java:
--------------------------------------------------------------------------------
1 | package hudson.plugins.analysis.collector;
2 |
3 | import javax.servlet.http.Cookie;
4 |
5 | import org.kohsuke.stapler.StaplerRequest;
6 | import org.kohsuke.stapler.StaplerResponse;
7 |
8 | import hudson.model.Job;
9 | import hudson.plugins.analysis.core.BuildHistory;
10 | import hudson.plugins.analysis.graph.GraphConfiguration;
11 | import hudson.plugins.analysis.graph.UserGraphConfigurationView;
12 |
13 | /**
14 | * Adds some more parameters to the configuration view.
15 | *
16 | * @author Ulli Hafner
17 | */
18 | public class AnalysisUserGraphConfigurationView extends UserGraphConfigurationView {
19 | /** The graph configuration. */
20 | private final AnalysisGraphConfiguration analysisConfiguration;
21 |
22 | /**
23 | * Creates a new instance of {@link AnalysisUserGraphConfigurationView}.
24 | *
25 | * @param configuration
26 | * the graph configuration
27 | * @param job
28 | * the owning job to configure the graphs for
29 | * @param pluginName
30 | * The name of the plug-in. Also used as the suffix of the cookie
31 | * name that is used to persist the configuration per user.
32 | * @param cookies
33 | * the cookies containing the graph configuration
34 | * @param buildHistory
35 | * the build history for this job
36 | */
37 | public AnalysisUserGraphConfigurationView(final AnalysisGraphConfiguration configuration, final Job, ?> job,
38 | final String pluginName, final Cookie[] cookies, final BuildHistory buildHistory) {
39 | super(configuration, job, pluginName, cookies, buildHistory);
40 |
41 | analysisConfiguration = configuration;
42 | }
43 |
44 | @Override
45 | protected void persistValue(final String value, final String pluginName, final StaplerRequest request,
46 | final StaplerResponse response) {
47 | super.persistValue(value, pluginName, request, response);
48 |
49 | GraphConfiguration configuration;
50 | if (analysisConfiguration.canDeacticateOtherTrendGraphs()) {
51 | configuration = GraphConfiguration.createDeactivated();
52 | }
53 | else {
54 | configuration = GraphConfiguration.createDefault();
55 | }
56 | for (String plugin : AnalysisDescriptor.getPlugins()) {
57 | super.persistValue(configuration.serializeToString(), plugin, request, response);
58 | }
59 | }
60 |
61 | /**
62 | * Returns whether the trend graphs of the other plug-ins could be deactivated.
63 | *
64 | * @return true if the trend graphs of the other plug-ins could be deactivated
65 | */
66 | public boolean canDeacticateOtherTrendGraphs() {
67 | return analysisConfiguration.canDeacticateOtherTrendGraphs();
68 | }
69 | }
70 |
71 |
--------------------------------------------------------------------------------
/src/main/java/hudson/plugins/analysis/collector/AnalysisGraphConfiguration.java:
--------------------------------------------------------------------------------
1 | package hudson.plugins.analysis.collector;
2 |
3 | import hudson.plugins.analysis.graph.BuildResultGraph;
4 | import hudson.plugins.analysis.graph.GraphConfiguration;
5 |
6 | import java.util.Collection;
7 |
8 | import net.sf.json.JSONException;
9 | import net.sf.json.JSONObject;
10 |
11 | /**
12 | * A graph configuration that additionally handles the deactivation of the
13 | * individual trend graphs of the analysis plug-ins.
14 | *
15 | * @author Ulli Hafner
16 | */
17 | public class AnalysisGraphConfiguration extends GraphConfiguration {
18 | /** Determines whether the trend graphs of the other plug-ins could be deactivated. */
19 | private boolean canDeactivateGraphs;
20 |
21 | /**
22 | * Creates a new instance of {@link AnalysisGraphConfiguration}.
23 | *
24 | * @param availableGraphs
25 | * the available graphs
26 | */
27 | public AnalysisGraphConfiguration(final Collectiontrue if the trend graphs of the other plug-ins could be deactivated
64 | */
65 | public boolean canDeacticateOtherTrendGraphs() {
66 | return canDeactivateGraphs;
67 | }
68 |
69 | /**
70 | * See {@link #canDeacticateOtherTrendGraphs()}.
71 | *
72 | * @return see {@link #canDeacticateOtherTrendGraphs()}.
73 | */
74 | public boolean getCanDeacticateOtherTrendGraphs() {
75 | return canDeactivateGraphs;
76 | }
77 |
78 | @Override
79 | public String serializeToString() {
80 | return super.serializeToString() + serializeBoolean(canDeactivateGraphs);
81 | }
82 |
83 | // CHECKSTYLE:OFF
84 | @Override
85 | public int hashCode() {
86 | int prime = 31;
87 | int result = super.hashCode();
88 | result = prime * result + (canDeactivateGraphs ? 1231 : 1237);
89 | return result;
90 | }
91 | // CHECKSTYLE-ON
92 |
93 | // CHECKSTYLE-OFF
94 | @Override
95 | public boolean equals(final Object obj) {
96 | if (this == obj) {
97 | return true;
98 | }
99 | if (!super.equals(obj)) {
100 | return false;
101 | }
102 | if (getClass() != obj.getClass()) {
103 | return false;
104 | }
105 | AnalysisGraphConfiguration other = (AnalysisGraphConfiguration)obj;
106 | if (canDeactivateGraphs != other.canDeactivateGraphs) {
107 | return false;
108 | }
109 | return true;
110 | }
111 | // CHECKSTYLE-ON
112 | }
113 |
114 |
--------------------------------------------------------------------------------
/src/test/java/hudson/plugins/analysis/collector/workflow/WorkflowCompatibilityTest.java:
--------------------------------------------------------------------------------
1 | package hudson.plugins.analysis.collector.workflow;
2 |
3 | import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
4 | import org.jenkinsci.plugins.workflow.job.WorkflowJob;
5 | import org.junit.ClassRule;
6 | import org.junit.Test;
7 | import org.jvnet.hudson.test.JenkinsRule;
8 |
9 | import static org.junit.Assert.*;
10 |
11 | import hudson.FilePath;
12 | import hudson.model.Result;
13 | import hudson.plugins.analysis.collector.AnalysisResultAction;
14 |
15 | /**
16 | * Test workflow compatibility.
17 | */
18 | public class WorkflowCompatibilityTest {
19 | @ClassRule
20 | public static JenkinsRule j = new JenkinsRule();
21 |
22 | /**
23 | * General collector test using Findbugsas example.
24 | */
25 | @Test
26 | public void collectorPublisherWorkflowStep() throws Exception {
27 | WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, "wf");
28 | FilePath workspace = j.jenkins.getWorkspaceFor(job);
29 | FilePath report = workspace.child("target").child("findbugs.xml");
30 | report.copyFrom(WorkflowCompatibilityTest.class.getResourceAsStream("/findbugs-native.xml"));
31 | FilePath report2 = workspace.child("target").child("checkstyle-result.xml");
32 | report2.copyFrom(WorkflowCompatibilityTest.class.getResourceAsStream("/checkstyle-result-build2.xml"));
33 | job.setDefinition(new CpsFlowDefinition(
34 | "node {\n" +
35 | " step([$class: 'FindBugsPublisher'])\n" +
36 | " step([$class: 'CheckStylePublisher'])\n" +
37 | // Ignore checkstyle report
38 | " step([$class: 'AnalysisPublisher', checkStyleActivated: false])\n" +
39 | "}"));
40 | j.assertBuildStatusSuccess(job.scheduleBuild2(0));
41 | AnalysisResultAction result = job.getLastBuild().getAction(AnalysisResultAction.class);
42 | // Only 2 annotation coming from Findbugs, Checkstyle is ignored bhy configuration
43 | assertEquals(2, result.getResult().getAnnotations().size());
44 | }
45 |
46 | /**
47 | * Failure test.
48 | */
49 | @Test
50 | public void collectorPublisherWorkflowStepSetLimits() throws Exception {
51 | WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, "wf2");
52 | FilePath workspace = j.jenkins.getWorkspaceFor(job);
53 | FilePath report = workspace.child("target").child("findbugs.xml");
54 | report.copyFrom(WorkflowCompatibilityTest.class.getResourceAsStream("/findbugs-native.xml"));
55 | job.setDefinition(new CpsFlowDefinition(
56 | "node {\n" +
57 | " step([$class: 'FindBugsPublisher'])\n" +
58 | " step([$class: 'AnalysisPublisher', failedTotalAll: '0', usePreviousBuildAsReference: false])\n" +
59 | "}"));
60 | j.assertBuildStatus(Result.FAILURE, job.scheduleBuild2(0).get());
61 | AnalysisResultAction result = job.getLastBuild().getAction(AnalysisResultAction.class);
62 | assertEquals(result.getResult().getAnnotations().size(), 2);
63 | }
64 |
65 | /**
66 | * Unstable test.
67 | */
68 | @Test
69 | public void collectorPublisherWorkflowStepFailure() throws Exception {
70 | WorkflowJob job = j.jenkins.createProject(WorkflowJob.class, "wf3");
71 | FilePath workspace = j.jenkins.getWorkspaceFor(job);
72 | FilePath report = workspace.child("target").child("findbugs.xml");
73 | report.copyFrom(WorkflowCompatibilityTest.class.getResourceAsStream("/findbugs-native.xml"));
74 | job.setDefinition(new CpsFlowDefinition(
75 | "node {\n" +
76 | " step([$class: 'FindBugsPublisher'])\n" +
77 | " step([$class: 'AnalysisPublisher', unstableTotalAll: '0', usePreviousBuildAsReference: false])\n" +
78 | "}"));
79 | j.assertBuildStatus(Result.UNSTABLE, job.scheduleBuild2(0).get());
80 | AnalysisResultAction result = job.getLastBuild().getAction(AnalysisResultAction.class);
81 | assertEquals(result.getResult().getAnnotations().size(), 2);
82 | }
83 | }
84 |
85 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 | true if the Checkstyle plug-in is installed,
72 | * false if not.
73 | */
74 | public static boolean isCheckStyleInstalled() {
75 | return isPluginInstalled(CHECKSTYLE);
76 | }
77 |
78 | /**
79 | * Returns whether the Dry plug-in is installed.
80 | *
81 | * @return true if the Dry plug-in is installed,
82 | * false if not.
83 | */
84 | public static boolean isDryInstalled() {
85 | return isPluginInstalled(DRY);
86 | }
87 |
88 | /**
89 | * Returns whether the FindBugs plug-in is installed.
90 | *
91 | * @return true if the FindBugs plug-in is installed,
92 | * false if not.
93 | */
94 | public static boolean isFindBugsInstalled() {
95 | return isPluginInstalled(FINDBUGS);
96 | }
97 |
98 | /**
99 | * Returns whether the PMD plug-in is installed.
100 | *
101 | * @return true if the PMD plug-in is installed,
102 | * false if not.
103 | */
104 | public static boolean isPmdInstalled() {
105 | return isPluginInstalled(PMD);
106 | }
107 |
108 | /**
109 | * Returns whether the Open Tasks plug-in is installed.
110 | *
111 | * @return true if the Open Tasks plug-in is installed,
112 | * false if not.
113 | */
114 | public static boolean isOpenTasksInstalled() {
115 | return isPluginInstalled(TASKS);
116 | }
117 |
118 | /**
119 | * Returns whether the Warnings plug-in is installed.
120 | *
121 | * @return true if the Warnings plug-in is installed,
122 | * false if not.
123 | */
124 | public static boolean isWarningsInstalled() {
125 | return isPluginInstalled(WARNINGS);
126 | }
127 |
128 | /**
129 | * Returns whether the Android Lint plug-in is installed.
130 | *
131 | * @return true if the Android Lint plug-in is installed,
132 | * false if not.
133 | */
134 | public static boolean isAndroidLintInstalled() {
135 | return isPluginInstalled(ANDROID_LINT);
136 | }
137 |
138 | /**
139 | * Instantiates a new {@link AnalysisDescriptor}.
140 | */
141 | public AnalysisDescriptor() {
142 | super(AnalysisPublisher.class);
143 | }
144 |
145 | @Override
146 | public String getDisplayName() {
147 | return Messages.Analysis_Publisher_Name();
148 | }
149 |
150 | @Override
151 | public String getPluginRoot() {
152 | return "/plugin/analysis-collector/";
153 | }
154 |
155 | @Override
156 | public String getPluginName() {
157 | return PLUGIN_ID;
158 | }
159 |
160 | @Override
161 | public String getIconUrl() {
162 | return ICON_URL;
163 | }
164 |
165 | @Override
166 | public String getSummaryIconUrl() {
167 | return ICONS_PREFIX + "analysis-48x48.png";
168 | }
169 |
170 | @SuppressWarnings("rawtypes")
171 | @Override
172 | public boolean isApplicable(final Class extends AbstractProject> jobType) {
173 | return true;
174 | }
175 | }
176 |
--------------------------------------------------------------------------------
/src/main/java/hudson/plugins/analysis/collector/OriginGraph.java:
--------------------------------------------------------------------------------
1 | package hudson.plugins.analysis.collector;
2 |
3 | import hudson.plugins.analysis.core.BuildResult;
4 | import hudson.plugins.analysis.graph.CategoryBuildResultGraph;
5 | import hudson.plugins.analysis.graph.ColorPalette;
6 | import hudson.plugins.analysis.graph.GraphConfiguration;
7 | import hudson.plugins.analysis.util.ToolTipProvider;
8 |
9 | import java.awt.Color;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | import org.jfree.chart.JFreeChart;
14 | import org.jfree.chart.renderer.category.CategoryItemRenderer;
15 | import org.jfree.data.category.CategoryDataset;
16 |
17 | import com.google.common.collect.Lists;
18 |
19 | /**
20 | * Builds a graph showing all warnings by their origin.
21 | *
22 | * @author Ulli Hafner
23 | */
24 | public class OriginGraph extends CategoryBuildResultGraph {
25 | /** Number of colors to use from Hudson's color table. */
26 | private static final int HUDSON_GREEN_INDEX = 3;
27 |
28 | private final Listtrue if CheckStyle results should be shown, false otherwise
97 | */
98 | public boolean isCheckStyleActivated() {
99 | return warningsAggregator.hasCheckStyle(getOwner());
100 | }
101 |
102 | /**
103 | * Returns whether DRY results should be shown.
104 | *
105 | * @return true if DRY results should be shown, false otherwise
106 | */
107 | public boolean isDryActivated() {
108 | return warningsAggregator.hasDry(getOwner());
109 | }
110 |
111 | /**
112 | * Returns whether FindBugs results should be shown.
113 | *
114 | * @return true if FindBugs results should be shown, false otherwise
115 | */
116 | public boolean isFindBugsActivated() {
117 | return warningsAggregator.hasFindBugs(getOwner());
118 | }
119 |
120 | /**
121 | * Returns whether PMD results should be shown.
122 | *
123 | * @return true if PMD results should be shown, false otherwise
124 | */
125 | public boolean isPmdActivated() {
126 | return warningsAggregator.hasPmd(getOwner());
127 | }
128 |
129 | /**
130 | * Returns whether open tasks should be shown.
131 | *
132 | * @return true if open tasks should be shown, false otherwise
133 | */
134 | public boolean isOpenTasksActivated() {
135 | return warningsAggregator.hasTasks(getOwner());
136 | }
137 |
138 | /**
139 | * Returns whether compiler warnings results should be shown.
140 | *
141 | * @return true if compiler warnings results should be shown, false otherwise
142 | */
143 | public boolean isWarningsActivated() {
144 | return warningsAggregator.hasCompilerWarnings(getOwner());
145 | }
146 |
147 | /**
148 | * Returns whether Android lint results should be shown.
149 | *
150 | * @return true if Android lint results should be shown, false otherwise
151 | */
152 | public boolean isAndroidLintActivated() {
153 | return warningsAggregator.hasAndroidLint(getOwner());
154 | }
155 |
156 | /**
157 | * Returns the number of Checkstyle warnings for this action.
158 | *
159 | * @return the number of Checkstyle warnings
160 | */
161 | public String getCheckStyle() {
162 | return warningsAggregator.getCheckStyle(getOwner());
163 | }
164 |
165 | /**
166 | * Returns the number of duplicate code warnings for this action.
167 | *
168 | * @return the number of duplicate code warnings
169 | */
170 | public String getDry() {
171 | return warningsAggregator.getDry(getOwner());
172 | }
173 |
174 | /**
175 | * Returns the number of FindBugs warnings for this action.
176 | *
177 | * @return the number of FindBugs warnings
178 | */
179 | public String getFindBugs() {
180 | return warningsAggregator.getFindBugs(getOwner());
181 | }
182 |
183 | /**
184 | * Returns the number of PMD warnings for this action.
185 | *
186 | * @return the number of PMD warnings
187 | */
188 | public String getPmd() {
189 | return warningsAggregator.getPmd(getOwner());
190 | }
191 |
192 | /**
193 | * Returns the number of open tasks for this action.
194 | *
195 | * @return the number of open tasks
196 | */
197 | public String getTasks() {
198 | return warningsAggregator.getTasks(getOwner());
199 | }
200 |
201 | /**
202 | * Returns the total number of warnings for this action.
203 | *
204 | * @return the number of compiler warnings
205 | */
206 | public String getCompilerWarnings() {
207 | return warningsAggregator.getCompilerWarnings(getOwner());
208 | }
209 |
210 | /**
211 | * Returns the number of Android lint warnings for this action.
212 | *
213 | * @return the number of Android lint warnings
214 | */
215 | public String getAndroidLint() {
216 | return warningsAggregator.getAndroidLint(getOwner());
217 | }
218 | }
219 |
--------------------------------------------------------------------------------
/.fbprefs:
--------------------------------------------------------------------------------
1 | #FindBugs User Preferences
2 | #Fri Jul 13 08:53:48 CEST 2012
3 | cloud_id=edu.umd.cs.findbugs.cloud.doNothingCloud
4 | detectorAppendingToAnObjectOutputStream=AppendingToAnObjectOutputStream|true
5 | detectorAtomicityProblem=AtomicityProblem|true
6 | detectorBadAppletConstructor=BadAppletConstructor|false
7 | detectorBadResultSetAccess=BadResultSetAccess|true
8 | detectorBadSyntaxForRegularExpression=BadSyntaxForRegularExpression|true
9 | detectorBadUseOfReturnValue=BadUseOfReturnValue|true
10 | detectorBadlyOverriddenAdapter=BadlyOverriddenAdapter|true
11 | detectorBooleanReturnNull=BooleanReturnNull|true
12 | detectorCallToUnsupportedMethod=CallToUnsupportedMethod|false
13 | detectorCheckExpectedWarnings=CheckExpectedWarnings|false
14 | detectorCheckImmutableAnnotation=CheckImmutableAnnotation|true
15 | detectorCheckTypeQualifiers=CheckTypeQualifiers|true
16 | detectorCloneIdiom=CloneIdiom|true
17 | detectorComparatorIdiom=ComparatorIdiom|true
18 | detectorConfusedInheritance=ConfusedInheritance|true
19 | detectorConfusionBetweenInheritedAndOuterMethod=ConfusionBetweenInheritedAndOuterMethod|true
20 | detectorCrossSiteScripting=CrossSiteScripting|true
21 | detectorDefaultEncodingDetector=DefaultEncodingDetector|true
22 | detectorDoInsideDoPrivileged=DoInsideDoPrivileged|true
23 | detectorDontCatchIllegalMonitorStateException=DontCatchIllegalMonitorStateException|true
24 | detectorDontIgnoreResultOfPutIfAbsent=DontIgnoreResultOfPutIfAbsent|true
25 | detectorDontUseEnum=DontUseEnum|true
26 | detectorDroppedException=DroppedException|true
27 | detectorDumbMethodInvocations=DumbMethodInvocations|true
28 | detectorDumbMethods=DumbMethods|true
29 | detectorDuplicateBranches=DuplicateBranches|true
30 | detectorEmptyZipFileEntry=EmptyZipFileEntry|true
31 | detectorEqualsOperandShouldHaveClassCompatibleWithThis=EqualsOperandShouldHaveClassCompatibleWithThis|true
32 | detectorExplicitSerialization=ExplicitSerialization|true
33 | detectorFinalizerNullsFields=FinalizerNullsFields|true
34 | detectorFindBadCast2=FindBadCast2|true
35 | detectorFindBadForLoop=FindBadForLoop|true
36 | detectorFindCircularDependencies=FindCircularDependencies|true
37 | detectorFindDeadLocalStores=FindDeadLocalStores|true
38 | detectorFindDoubleCheck=FindDoubleCheck|true
39 | detectorFindEmptySynchronizedBlock=FindEmptySynchronizedBlock|true
40 | detectorFindFieldSelfAssignment=FindFieldSelfAssignment|true
41 | detectorFindFinalizeInvocations=FindFinalizeInvocations|true
42 | detectorFindFloatEquality=FindFloatEquality|true
43 | detectorFindHEmismatch=FindHEmismatch|true
44 | detectorFindInconsistentSync2=FindInconsistentSync2|true
45 | detectorFindJSR166LockMonitorenter=FindJSR166LockMonitorenter|true
46 | detectorFindLocalSelfAssignment2=FindLocalSelfAssignment2|true
47 | detectorFindMaskedFields=FindMaskedFields|true
48 | detectorFindMismatchedWaitOrNotify=FindMismatchedWaitOrNotify|true
49 | detectorFindNakedNotify=FindNakedNotify|true
50 | detectorFindNonSerializableStoreIntoSession=FindNonSerializableStoreIntoSession|true
51 | detectorFindNonSerializableValuePassedToWriteObject=FindNonSerializableValuePassedToWriteObject|true
52 | detectorFindNonShortCircuit=FindNonShortCircuit|true
53 | detectorFindNullDeref=FindNullDeref|true
54 | detectorFindNullDerefsInvolvingNonShortCircuitEvaluation=FindNullDerefsInvolvingNonShortCircuitEvaluation|true
55 | detectorFindOpenStream=FindOpenStream|true
56 | detectorFindPuzzlers=FindPuzzlers|true
57 | detectorFindRefComparison=FindRefComparison|true
58 | detectorFindReturnRef=FindReturnRef|true
59 | detectorFindRunInvocations=FindRunInvocations|true
60 | detectorFindSelfComparison=FindSelfComparison|true
61 | detectorFindSelfComparison2=FindSelfComparison2|true
62 | detectorFindSleepWithLockHeld=FindSleepWithLockHeld|true
63 | detectorFindSpinLoop=FindSpinLoop|true
64 | detectorFindSqlInjection=FindSqlInjection|true
65 | detectorFindTwoLockWait=FindTwoLockWait|true
66 | detectorFindUncalledPrivateMethods=FindUncalledPrivateMethods|true
67 | detectorFindUnconditionalWait=FindUnconditionalWait|true
68 | detectorFindUninitializedGet=FindUninitializedGet|true
69 | detectorFindUnrelatedTypesInGenericContainer=FindUnrelatedTypesInGenericContainer|true
70 | detectorFindUnreleasedLock=FindUnreleasedLock|true
71 | detectorFindUnsatisfiedObligation=FindUnsatisfiedObligation|true
72 | detectorFindUnsyncGet=FindUnsyncGet|true
73 | detectorFindUseOfNonSerializableValue=FindUseOfNonSerializableValue|true
74 | detectorFindUselessControlFlow=FindUselessControlFlow|true
75 | detectorFormatStringChecker=FormatStringChecker|true
76 | detectorHugeSharedStringConstants=HugeSharedStringConstants|true
77 | detectorIDivResultCastToDouble=IDivResultCastToDouble|true
78 | detectorIncompatMask=IncompatMask|true
79 | detectorInconsistentAnnotations=InconsistentAnnotations|true
80 | detectorInefficientMemberAccess=InefficientMemberAccess|false
81 | detectorInefficientToArray=InefficientToArray|true
82 | detectorInfiniteLoop=InfiniteLoop|true
83 | detectorInfiniteRecursiveLoop=InfiniteRecursiveLoop|true
84 | detectorInfiniteRecursiveLoop2=InfiniteRecursiveLoop2|false
85 | detectorInheritanceUnsafeGetResource=InheritanceUnsafeGetResource|true
86 | detectorInitializationChain=InitializationChain|true
87 | detectorInstantiateStaticClass=InstantiateStaticClass|true
88 | detectorIntCast2LongAsInstant=IntCast2LongAsInstant|true
89 | detectorInvalidJUnitTest=InvalidJUnitTest|true
90 | detectorIteratorIdioms=IteratorIdioms|true
91 | detectorLazyInit=LazyInit|true
92 | detectorLoadOfKnownNullValue=LoadOfKnownNullValue|true
93 | detectorLostLoggerDueToWeakReference=LostLoggerDueToWeakReference|true
94 | detectorMethodReturnCheck=MethodReturnCheck|true
95 | detectorMultithreadedInstanceAccess=MultithreadedInstanceAccess|true
96 | detectorMutableLock=MutableLock|true
97 | detectorMutableStaticFields=MutableStaticFields|true
98 | detectorNaming=Naming|true
99 | detectorNoteUnconditionalParamDerefs=NoteUnconditionalParamDerefs|true
100 | detectorNumberConstructor=NumberConstructor|true
101 | detectorOverridingEqualsNotSymmetrical=OverridingEqualsNotSymmetrical|true
102 | detectorPreferZeroLengthArrays=PreferZeroLengthArrays|true
103 | detectorPublicSemaphores=PublicSemaphores|false
104 | detectorQuestionableBooleanAssignment=QuestionableBooleanAssignment|true
105 | detectorReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass=ReadOfInstanceFieldInMethodInvokedByConstructorInSuperclass|true
106 | detectorReadReturnShouldBeChecked=ReadReturnShouldBeChecked|true
107 | detectorRedundantInterfaces=RedundantInterfaces|true
108 | detectorRepeatedConditionals=RepeatedConditionals|true
109 | detectorRuntimeExceptionCapture=RuntimeExceptionCapture|true
110 | detectorSerializableIdiom=SerializableIdiom|true
111 | detectorStartInConstructor=StartInConstructor|true
112 | detectorStaticCalendarDetector=StaticCalendarDetector|true
113 | detectorStringConcatenation=StringConcatenation|true
114 | detectorSuperfluousInstanceOf=SuperfluousInstanceOf|true
115 | detectorSuspiciousThreadInterrupted=SuspiciousThreadInterrupted|true
116 | detectorSwitchFallthrough=SwitchFallthrough|true
117 | detectorSynchronizeAndNullCheckField=SynchronizeAndNullCheckField|true
118 | detectorSynchronizeOnClassLiteralNotGetClass=SynchronizeOnClassLiteralNotGetClass|true
119 | detectorSynchronizingOnContentsOfFieldToProtectField=SynchronizingOnContentsOfFieldToProtectField|true
120 | detectorURLProblems=URLProblems|true
121 | detectorUncallableMethodOfAnonymousClass=UncallableMethodOfAnonymousClass|true
122 | detectorUnnecessaryMath=UnnecessaryMath|true
123 | detectorUnreadFields=UnreadFields|true
124 | detectorUseObjectEquals=UseObjectEquals|true
125 | detectorUselessSubclassMethod=UselessSubclassMethod|true
126 | detectorVarArgsProblems=VarArgsProblems|true
127 | detectorVolatileUsage=VolatileUsage|true
128 | detectorWaitInLoop=WaitInLoop|true
129 | detectorWrongMapIterator=WrongMapIterator|true
130 | detectorXMLFactoryBypass=XMLFactoryBypass|true
131 | detector_threshold=3
132 | effort=max
133 | excludefilter0=../analysis-config/etc/findbugs-exclusion-filter.xml|true
134 | filter_settings=Low|BAD_PRACTICE,CORRECTNESS,EXPERIMENTAL,I18N,MALICIOUS_CODE,MT_CORRECTNESS,PERFORMANCE,SECURITY,STYLE|false|20
135 | filter_settings_neg=NOISE|
136 | run_at_full_build=true
137 |
--------------------------------------------------------------------------------
/src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet/portlet.jelly:
--------------------------------------------------------------------------------
1 |
2 | | ${%Job} | 14 |Checkstyle | 17 |${%Duplicate Code} | 20 |FindBugs | 23 |PMD | 26 |${%Open Tasks} | 29 |${%Compiler Warnings} | 32 |${%Android Lint} | 35 |${%Total} | 62 ||||||||
|
68 | |
70 |
72 | |
74 |
77 | |
79 |
82 | |
84 |
87 | |
89 |
92 | |
94 |
97 | |
99 |
102 | |
104 |
107 | |
115 | |||||||
| 120 | ${%Total} 121 | | 122 |124 | ${it.getCheckStyle(jobs)} 125 | | 126 |129 | ${it.getDry(jobs)} 130 | | 131 |134 | ${it.getFindBugs(jobs)} 135 | | 136 |139 | ${it.getPmd(jobs)} 140 | | 141 |144 | ${it.getTasks(jobs)} 145 | | 146 |149 | ${it.getWarnings(jobs)} 150 | | 151 |154 | ${it.getAndroidLint(jobs)} 155 | | 156 |159 | ${it.getTotal(jobs)} 160 | | 161 |
true if CheckStyle results should be collected, false otherwise
78 | */
79 | public boolean isCheckStyleActivated() {
80 | return !isCheckStyleDeactivated;
81 | }
82 |
83 | /**
84 | * Returns whether DRY results should be collected.
85 | *
86 | * @return true if DRY results should be collected, false otherwise
87 | */
88 | public boolean isDryActivated() {
89 | return !isDryDeactivated;
90 | }
91 |
92 | /**
93 | * Returns whether FindBugs results should be collected.
94 | *
95 | * @return true if FindBugs results should be collected, false otherwise
96 | */
97 | public boolean isFindBugsActivated() {
98 | return !isFindBugsDeactivated;
99 | }
100 |
101 | /**
102 | * Returns whether PMD results should be collected.
103 | *
104 | * @return true if PMD results should be collected, false otherwise
105 | */
106 | public boolean isPmdActivated() {
107 | return !isPmdDeactivated;
108 | }
109 |
110 | /**
111 | * Returns whether open tasks should be collected.
112 | *
113 | * @return true if open tasks should be collected, false otherwise
114 | */
115 | public boolean isOpenTasksActivated() {
116 | return !isOpenTasksDeactivated;
117 | }
118 |
119 | /**
120 | * Returns whether compiler warnings results should be collected.
121 | *
122 | * @return true if compiler warnings results should be collected, false otherwise
123 | */
124 | public boolean isWarningsActivated() {
125 | return !isWarningsDeactivated;
126 | }
127 |
128 | /**
129 | * Returns whether Android lint results should be collected.
130 | *
131 | * @return true if Android lint results should be collected, false otherwise
132 | */
133 | public boolean isAndroidLintActivated() {
134 | return !isAndroidLintDeactivated;
135 | }
136 |
137 | @Override
138 | protected Class extends AbstractProjectAction>> getAction() {
139 | return AnalysisProjectAction.class;
140 | }
141 |
142 | @Override
143 | protected String getPluginName() {
144 | return "analysis";
145 | }
146 |
147 | @Override
148 | protected BuildResultGraph getGraphType() {
149 | return new OriginGraph(isCheckStyleActivated(), isDryActivated(), isFindBugsActivated(), isPmdActivated(), isOpenTasksActivated(), isWarningsActivated(), isAndroidLintActivated());
150 | }
151 |
152 | /**
153 | * Extension point registration.
154 | */
155 | @Extension(optional = true)
156 | public static class WarningsGraphDescriptor extends Descriptortrue if the Checkstyle plug-in is installed,
161 | * false if not.
162 | */
163 | public boolean isCheckStyleInstalled() {
164 | return AnalysisDescriptor.isCheckStyleInstalled();
165 | }
166 |
167 | /**
168 | * Returns whether the Dry plug-in is installed.
169 | *
170 | * @return true if the Dry plug-in is installed,
171 | * false if not.
172 | */
173 | public boolean isDryInstalled() {
174 | return AnalysisDescriptor.isDryInstalled();
175 | }
176 |
177 | /**
178 | * Returns whether the FindBugs plug-in is installed.
179 | *
180 | * @return true if the FindBugs plug-in is installed,
181 | * false if not.
182 | */
183 | public boolean isFindBugsInstalled() {
184 | return AnalysisDescriptor.isFindBugsInstalled();
185 | }
186 |
187 | /**
188 | * Returns whether the PMD plug-in is installed.
189 | *
190 | * @return true if the PMD plug-in is installed,
191 | * false if not.
192 | */
193 | public boolean isPmdInstalled() {
194 | return AnalysisDescriptor.isPmdInstalled();
195 | }
196 |
197 | /**
198 | * Returns whether the Open Tasks plug-in is installed.
199 | *
200 | * @return true if the Open Tasks plug-in is installed,
201 | * false if not.
202 | */
203 | public boolean isOpenTasksInstalled() {
204 | return AnalysisDescriptor.isOpenTasksInstalled();
205 | }
206 |
207 | /**
208 | * Returns whether the Warnings plug-in is installed.
209 | *
210 | * @return true if the Warnings plug-in is installed,
211 | * false if not.
212 | */
213 | public boolean isWarningsInstalled() {
214 | return AnalysisDescriptor.isWarningsInstalled();
215 | }
216 |
217 | /**
218 | * Returns whether the Android Lint plug-in is installed.
219 | *
220 | * @return true if the Android Lint plug-in is installed,
221 | * false if not.
222 | */
223 | public boolean isAndroidLintInstalled() {
224 | return AnalysisDescriptor.isAndroidLintInstalled();
225 | }
226 |
227 | @Override
228 | public String getDisplayName() {
229 | return Messages.Portlet_WarningsOriginGraph();
230 | }
231 | }
232 | }
233 |
234 |
--------------------------------------------------------------------------------
/src/main/java/hudson/plugins/analysis/collector/AnalysisPublisher.java:
--------------------------------------------------------------------------------
1 | package hudson.plugins.analysis.collector; // NOPMD
2 |
3 | import java.io.IOException;
4 | import java.util.ArrayList;
5 | import java.util.Collection;
6 | import java.util.List;
7 |
8 | import org.kohsuke.stapler.DataBoundConstructor;
9 | import org.kohsuke.stapler.DataBoundSetter;
10 |
11 | import hudson.FilePath;
12 | import hudson.Launcher;
13 | import hudson.matrix.MatrixAggregator;
14 | import hudson.matrix.MatrixBuild;
15 | import hudson.model.BuildListener;
16 | import hudson.model.Run;
17 | import hudson.plugins.analysis.collector.handler.AndroidLintHandler;
18 | import hudson.plugins.analysis.collector.handler.CheckStyleHandler;
19 | import hudson.plugins.analysis.collector.handler.DryHandler;
20 | import hudson.plugins.analysis.collector.handler.FindBugsHandler;
21 | import hudson.plugins.analysis.collector.handler.PmdHandler;
22 | import hudson.plugins.analysis.collector.handler.TasksHandler;
23 | import hudson.plugins.analysis.collector.handler.WarningsHandler;
24 | import hudson.plugins.analysis.core.BuildResult;
25 | import hudson.plugins.analysis.core.HealthAwarePublisher;
26 | import hudson.plugins.analysis.core.ParserResult;
27 | import hudson.plugins.analysis.core.ResultAction;
28 | import hudson.plugins.analysis.util.PluginLogger;
29 | import hudson.plugins.analysis.util.model.FileAnnotation;
30 |
31 | /**
32 | * Collects the results of the various analysis plug-ins.
33 | *
34 | * @author Ulli Hafner
35 | */
36 | // CHECKSTYLE:COUPLING-OFF
37 | public class AnalysisPublisher extends HealthAwarePublisher {
38 | private static final long serialVersionUID = 5512072640635006098L;
39 |
40 | private boolean isCheckStyleDeactivated;
41 | private boolean isDryDeactivated;
42 | private boolean isFindBugsDeactivated;
43 | private boolean isPmdDeactivated;
44 | private boolean isOpenTasksDeactivated;
45 | private boolean isWarningsDeactivated;
46 | private boolean isAndroidLintDeactivated;
47 |
48 | private static final String PLUGIN_ID = "ANALYSIS-COLLECTOR";
49 |
50 | /**
51 | * Default constructor.
52 | * Use setter to initialize fields if needed.
53 | */
54 | @DataBoundConstructor
55 | public AnalysisPublisher() {
56 | super(PLUGIN_ID);
57 | }
58 |
59 | /**
60 | * Returns whether CheckStyle results should be collected.
61 | *
62 | * @return true if CheckStyle results should be collected, false otherwise
63 | */
64 | public boolean isCheckStyleActivated() {
65 | return !isCheckStyleDeactivated;
66 | }
67 |
68 | /**
69 | * @see #isCheckStyleActivated()
70 | */
71 | @DataBoundSetter
72 | public void setCheckStyleActivated(final boolean checkStyleActivated) {
73 | isCheckStyleDeactivated = !checkStyleActivated;
74 | }
75 |
76 | /**
77 | * Returns whether DRY results should be collected.
78 | *
79 | * @return true if DRY results should be collected, false otherwise
80 | */
81 | public boolean isDryActivated() {
82 | return !isDryDeactivated;
83 | }
84 |
85 | /**
86 | * @see #isDryActivated()
87 | */
88 | @DataBoundSetter
89 | public void setDryActivated(final boolean dryActivated) {
90 | isDryDeactivated = !dryActivated;
91 | }
92 |
93 | /**
94 | * Returns whether FindBugs results should be collected.
95 | *
96 | * @return true if FindBugs results should be collected, false otherwise
97 | */
98 | public boolean isFindBugsActivated() {
99 | return !isFindBugsDeactivated;
100 | }
101 |
102 | /**
103 | * @see #isFindBugsActivated()
104 | */
105 | @DataBoundSetter
106 | public void setFindBugsActivated(final boolean findBugsActivated) {
107 | isFindBugsDeactivated = !findBugsActivated;
108 | }
109 |
110 | /**
111 | * Returns whether PMD results should be collected.
112 | *
113 | * @return true if PMD results should be collected, false otherwise
114 | */
115 | public boolean isPmdActivated() {
116 | return !isPmdDeactivated;
117 | }
118 |
119 | /**
120 | * @see #isPmdActivated()
121 | */
122 | @DataBoundSetter
123 | public void setPmdActivated(final boolean pmdActivated) {
124 | isPmdDeactivated = !pmdActivated;
125 | }
126 |
127 | /**
128 | * Returns whether open tasks should be collected.
129 | *
130 | * @return true if open tasks should be collected, false otherwise
131 | */
132 | public boolean isOpenTasksActivated() {
133 | return !isOpenTasksDeactivated;
134 | }
135 |
136 | /**
137 | * @see #isOpenTasksActivated()
138 | */
139 | @DataBoundSetter
140 | public void setOpenTasksActivated(final boolean openTasksActivated) {
141 | isOpenTasksDeactivated = !openTasksActivated;
142 | }
143 |
144 | /**
145 | * Returns whether compiler warnings results should be collected.
146 | *
147 | * @return true if compiler warnings results should be collected, false otherwise
148 | */
149 | public boolean isWarningsActivated() {
150 | return !isWarningsDeactivated;
151 | }
152 |
153 | /**
154 | * @see #isWarningsActivated()
155 | */
156 | @DataBoundSetter
157 | public void setWarningsActivated(final boolean warningsActivated) {
158 | isWarningsDeactivated = !warningsActivated;
159 | }
160 |
161 | /**
162 | * Returns whether Android lint results should be collected.
163 | *
164 | * @return true if Android lint results should be collected, false otherwise
165 | */
166 | public boolean isAndroidLintActivated() {
167 | return !isAndroidLintDeactivated;
168 | }
169 |
170 | /**
171 | * @see #isAndroidLintActivated()
172 | */
173 | @DataBoundSetter
174 | public void setAndroidLintActivated(final boolean lintActivated) {
175 | isAndroidLintDeactivated = !lintActivated;
176 | }
177 |
178 | /**
179 | * Initializes the plug-ins that should participate in the results of this
180 | * analysis collector.
181 | *
182 | * @return the plug-in actions to read the results from
183 | */
184 | @SuppressWarnings({"PMD.NPathComplexity", "PMD.CyclomaticComplexity"})
185 | private Listtrue if CheckStyle results should be shown, false otherwise
60 | */
61 | public boolean isCheckStyleActivated() {
62 | return warningsAggregator.isCheckStyleActivated();
63 | }
64 |
65 | /**
66 | * Returns whether DRY results should be shown.
67 | *
68 | * @return true if DRY results should be shown, false otherwise
69 | */
70 | public boolean isDryActivated() {
71 | return warningsAggregator.isDryActivated();
72 | }
73 |
74 | /**
75 | * Returns whether FindBugs results should be shown.
76 | *
77 | * @return true if FindBugs results should be shown, false otherwise
78 | */
79 | public boolean isFindBugsActivated() {
80 | return warningsAggregator.isFindBugsActivated();
81 | }
82 |
83 | /**
84 | * Returns whether PMD results should be shown.
85 | *
86 | * @return true if PMD results should be shown, false otherwise
87 | */
88 | public boolean isPmdActivated() {
89 | return warningsAggregator.isPmdActivated();
90 | }
91 |
92 | /**
93 | * Returns whether open tasks should be shown.
94 | *
95 | * @return true if open tasks should be shown, false otherwise
96 | */
97 | public boolean isOpenTasksActivated() {
98 | return warningsAggregator.isOpenTasksActivated();
99 | }
100 |
101 | /**
102 | * Returns whether compiler warnings results should be shown.
103 | *
104 | * @return true if compiler warnings results should be shown, false otherwise
105 | */
106 | public boolean isWarningsActivated() {
107 | return warningsAggregator.isWarningsActivated();
108 | }
109 |
110 | /**
111 | * Returns whether Android Lint results should be shown.
112 | *
113 | * @return true if Android lint results should be shown, false otherwise
114 | */
115 | public boolean isAndroidLintActivated() {
116 | return warningsAggregator.isAndroidLintActivated();
117 | }
118 |
119 | /**
120 | * Returns the total number of annotations for the selected job.
121 | *
122 | * @param project
123 | * the selected project
124 | * @return the total number of annotations
125 | */
126 | public String getNumberOfAnnotations(final Job, ?> project) {
127 | return warningsAggregator.getTotal(project);
128 | }
129 |
130 | @Override
131 | protected Classtrue if the Checkstyle plug-in is installed,
196 | * false if not.
197 | */
198 | public boolean isCheckStyleInstalled() {
199 | return AnalysisDescriptor.isCheckStyleInstalled();
200 | }
201 |
202 | /**
203 | * Returns whether the Dry plug-in is installed.
204 | *
205 | * @return true if the Dry plug-in is installed,
206 | * false if not.
207 | */
208 | public boolean isDryInstalled() {
209 | return AnalysisDescriptor.isDryInstalled();
210 | }
211 |
212 | /**
213 | * Returns whether the FindBugs plug-in is installed.
214 | *
215 | * @return true if the FindBugs plug-in is installed,
216 | * false if not.
217 | */
218 | public boolean isFindBugsInstalled() {
219 | return AnalysisDescriptor.isFindBugsInstalled();
220 | }
221 |
222 | /**
223 | * Returns whether the PMD plug-in is installed.
224 | *
225 | * @return true if the PMD plug-in is installed,
226 | * false if not.
227 | */
228 | public boolean isPmdInstalled() {
229 | return AnalysisDescriptor.isPmdInstalled();
230 | }
231 |
232 | /**
233 | * Returns whether the Open Tasks plug-in is installed.
234 | *
235 | * @return true if the Open Tasks plug-in is installed,
236 | * false if not.
237 | */
238 | public boolean isOpenTasksInstalled() {
239 | return AnalysisDescriptor.isOpenTasksInstalled();
240 | }
241 |
242 | /**
243 | * Returns whether the Warnings plug-in is installed.
244 | *
245 | * @return true if the Warnings plug-in is installed,
246 | * false if not.
247 | */
248 | public boolean isWarningsInstalled() {
249 | return AnalysisDescriptor.isWarningsInstalled();
250 | }
251 |
252 | /**
253 | * Returns whether the Android Lint plug-in is installed.
254 | *
255 | * @return true if the Android Lint plug-in is installed,
256 | * false if not.
257 | */
258 | public boolean isAndroidLintInstalled() {
259 | return AnalysisDescriptor.isAndroidLintInstalled();
260 | }
261 |
262 | @Override
263 | public String getDisplayName() {
264 | return Messages.Analysis_Warnings_Column();
265 | }
266 | }
267 | }
268 |
--------------------------------------------------------------------------------
/.settings/org.eclipse.jdt.ui.prefs:
--------------------------------------------------------------------------------
1 | cleanup.add_default_serial_version_id=true
2 | cleanup.add_generated_serial_version_id=false
3 | cleanup.add_missing_annotations=true
4 | cleanup.add_missing_deprecated_annotations=true
5 | cleanup.add_missing_methods=false
6 | cleanup.add_missing_nls_tags=false
7 | cleanup.add_missing_override_annotations=true
8 | cleanup.add_missing_override_annotations_interface_methods=true
9 | cleanup.add_serial_version_id=false
10 | cleanup.always_use_blocks=true
11 | cleanup.always_use_parentheses_in_expressions=false
12 | cleanup.always_use_this_for_non_static_field_access=false
13 | cleanup.always_use_this_for_non_static_method_access=false
14 | cleanup.convert_to_enhanced_for_loop=false
15 | cleanup.correct_indentation=false
16 | cleanup.format_comment=true
17 | cleanup.format_javadoc=true
18 | cleanup.format_multi_line_comment=true
19 | cleanup.format_single_line_comment=false
20 | cleanup.format_source_code=false
21 | cleanup.format_source_code_changes_only=false
22 | cleanup.make_local_variable_final=false
23 | cleanup.make_parameters_final=true
24 | cleanup.make_private_fields_final=true
25 | cleanup.make_type_abstract_if_missing_method=false
26 | cleanup.make_variable_declarations_final=true
27 | cleanup.never_use_blocks=false
28 | cleanup.never_use_parentheses_in_expressions=true
29 | cleanup.organize_imports=true
30 | cleanup.qualify_static_field_accesses_with_declaring_class=false
31 | cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
32 | cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
33 | cleanup.qualify_static_member_accesses_with_declaring_class=true
34 | cleanup.qualify_static_method_accesses_with_declaring_class=false
35 | cleanup.remove_private_constructors=true
36 | cleanup.remove_trailing_whitespaces=true
37 | cleanup.remove_trailing_whitespaces_all=true
38 | cleanup.remove_trailing_whitespaces_ignore_empty=false
39 | cleanup.remove_unnecessary_casts=true
40 | cleanup.remove_unnecessary_nls_tags=true
41 | cleanup.remove_unused_imports=true
42 | cleanup.remove_unused_local_variables=false
43 | cleanup.remove_unused_private_fields=true
44 | cleanup.remove_unused_private_members=false
45 | cleanup.remove_unused_private_methods=true
46 | cleanup.remove_unused_private_types=true
47 | cleanup.sort_members=false
48 | cleanup.sort_members_all=false
49 | cleanup.use_blocks=true
50 | cleanup.use_blocks_only_for_return_and_throw=false
51 | cleanup.use_parentheses_in_expressions=false
52 | cleanup.use_this_for_non_static_field_access=true
53 | cleanup.use_this_for_non_static_field_access_only_if_necessary=true
54 | cleanup.use_this_for_non_static_method_access=true
55 | cleanup.use_this_for_non_static_method_access_only_if_necessary=true
56 | cleanup_profile=_Ulli
57 | cleanup_settings_version=2
58 | eclipse.preferences.version=1
59 | editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
60 | formatter_profile=_Ulli
61 | formatter_settings_version=12
62 | org.eclipse.jdt.ui.exception.name=exception
63 | org.eclipse.jdt.ui.gettersetter.use.is=true
64 | org.eclipse.jdt.ui.ignorelowercasenames=true
65 | org.eclipse.jdt.ui.importorder=java;javax;org;com;hudson.model;hudson.plugins;
66 | org.eclipse.jdt.ui.javadoc=true
67 | org.eclipse.jdt.ui.keywordthis=false
68 | org.eclipse.jdt.ui.ondemandthreshold=99
69 | org.eclipse.jdt.ui.overrideannotation=true
70 | org.eclipse.jdt.ui.staticondemandthreshold=0
71 | org.eclipse.jdt.ui.text.custom_code_templates=true if CheckStyle results should be shown, false otherwise
83 | */
84 | public boolean isCheckStyleActivated() {
85 | return isCheckStyleActivated;
86 | }
87 |
88 | /**
89 | * Returns whether DRY results should be shown.
90 | *
91 | * @return true if DRY results should be shown, false otherwise
92 | */
93 | public boolean isDryActivated() {
94 | return isDryActivated;
95 | }
96 |
97 | /**
98 | * Returns whether FindBugs results should be shown.
99 | *
100 | * @return true if FindBugs results should be shown, false otherwise
101 | */
102 | public boolean isFindBugsActivated() {
103 | return isFindBugsActivated;
104 | }
105 |
106 | /**
107 | * Returns whether PMD results should be shown.
108 | *
109 | * @return true if PMD results should be shown, false otherwise
110 | */
111 | public boolean isPmdActivated() {
112 | return isPmdActivated;
113 | }
114 |
115 | /**
116 | * Returns whether open tasks should be shown.
117 | *
118 | * @return true if open tasks should be shown, false otherwise
119 | */
120 | public boolean isOpenTasksActivated() {
121 | return isOpenTasksActivated;
122 | }
123 |
124 | /**
125 | * Returns whether compiler warnings results should be shown.
126 | *
127 | * @return true if compiler warnings results should be shown, false otherwise
128 | */
129 | public boolean isWarningsActivated() {
130 | return isWarningsActivated;
131 | }
132 |
133 | public boolean isAndroidLintActivated() {
134 | return isAndroidLintActivated;
135 | }
136 |
137 | /**
138 | * Returns the number of Checkstyle warnings for the specified job.
139 | *
140 | * @param job
141 | * the job to get the warnings for
142 | * @return the number of Checkstyle warnings
143 | */
144 | public String getCheckStyle(final Job, ?> job) {
145 | if (isCheckStyleActivated()) {
146 | return getWarnings(job, new CheckStyleHandler());
147 | }
148 | return NO_RESULTS_FOUND;
149 | }
150 |
151 | /**
152 | * Returns the number of duplicate code warnings for the specified job.
153 | *
154 | * @param job
155 | * the job to get the warnings for
156 | * @return the number of duplicate code warnings
157 | */
158 | public String getDry(final Job, ?> job) {
159 | if (isDryActivated()) {
160 | return getWarnings(job, new DryHandler());
161 | }
162 | return NO_RESULTS_FOUND;
163 | }
164 |
165 | /**
166 | * Returns the number of FindBugs warnings for the specified job.
167 | *
168 | * @param job
169 | * the job to get the warnings for
170 | * @return the number of FindBugs warnings
171 | */
172 | public String getFindBugs(final Job, ?> job) {
173 | if (isFindBugsActivated()) {
174 | return getWarnings(job, new FindBugsHandler());
175 | }
176 | return NO_RESULTS_FOUND;
177 | }
178 |
179 | /**
180 | * Returns the number of PMD warnings for the specified job.
181 | *
182 | * @param job
183 | * the job to get the warnings for
184 | * @return the number of PMD warnings
185 | */
186 | public String getPmd(final Job, ?> job) {
187 | if (isPmdActivated()) {
188 | return getWarnings(job, new PmdHandler());
189 | }
190 | return NO_RESULTS_FOUND;
191 | }
192 |
193 | /**
194 | * Returns the number of open tasks for the specified job.
195 | *
196 | * @param job
197 | * the job to get the tasks for
198 | * @return the number of open tasks
199 | */
200 | public String getTasks(final Job, ?> job) {
201 | if (isOpenTasksActivated()) {
202 | return getWarnings(job, new TasksHandler());
203 | }
204 | return NO_RESULTS_FOUND;
205 | }
206 |
207 | /**
208 | * Returns the total number of warnings for the specified job.
209 | *
210 | * @param job
211 | * the job to get the warnings for
212 | * @return the number of compiler warnings
213 | */
214 | public String getCompilerWarnings(final Job, ?> job) {
215 | if (isWarningsActivated()) {
216 | return getWarnings(job, new WarningsHandler());
217 | }
218 | return NO_RESULTS_FOUND;
219 | }
220 |
221 | /**
222 | * Returns the total number of Android lint warnings for the specified job.
223 | *
224 | * @param job
225 | * the job to get the warnings for
226 | * @return the number of Android lint warnings
227 | */
228 | public String getAndroidLint(final Job, ?> job) {
229 | if (isAndroidLintActivated()) {
230 | return getWarnings(job, new AndroidLintHandler());
231 | }
232 | return NO_RESULTS_FOUND;
233 | }
234 |
235 | /**
236 | * Returns the number of warnings for the specified job.
237 | *
238 | * @param job
239 | * the job to get the warnings for
240 | * @return the number of warnings
241 | */
242 | public String getTotal(final Job, ?> job) {
243 | return String.valueOf(toInt(getCheckStyle(job))
244 | + toInt(getDry(job))
245 | + toInt(getFindBugs(job))
246 | + toInt(getPmd(job))
247 | + toInt(getTasks(job))
248 | + toInt(getCompilerWarnings(job))
249 | + toInt(getAndroidLint(job)));
250 | }
251 |
252 | /**
253 | * Returns the warnings for the specified action.
254 | *
255 | *
256 | * @param job
257 | * the job to get the action from
258 | * @param handler
259 | * the analysis plug-in handler
260 | * @return the number of warnings
261 | */
262 | @SuppressWarnings("NP")
263 | private String getWarnings(final Job, ?> job, final AnalysisHandler handler) {
264 | AbstractProjectAction> action = job.getAction(handler.getProjectActionType());
265 | if (action != null && action.hasValidResults()) {
266 | BuildResult result = action.getLastAction().getResult();
267 | int numberOfAnnotations = result.getNumberOfAnnotations();
268 | String value;
269 | if (numberOfAnnotations > 0) {
270 | value = String.format("%d", getJobPrefix(job), handler.getUrl(), numberOfAnnotations);
271 | }
272 | else {
273 | value = String.valueOf(numberOfAnnotations);
274 | }
275 | if (result.isSuccessfulTouched() && !result.isSuccessful()) {
276 | return value + result.getResultIcon();
277 | }
278 | return value;
279 | }
280 | return NO_RESULTS_FOUND;
281 | }
282 |
283 | private String getJobPrefix(final Job, ?> job) {
284 | return hideJobPrefix ? StringUtils.EMPTY : job.getUrl();
285 | }
286 |
287 | /**
288 | * Returns whether Checkstyle results are available for the specified job.
289 | *
290 | * @param job
291 | * the job to get the warnings for
292 | * @return true if there are results, false otherwise
293 | */
294 | public boolean hasCheckStyle(final Job, ?> job) {
295 | if (isCheckStyleActivated()) {
296 | return hasAction(job, new CheckStyleHandler());
297 | }
298 | return false;
299 | }
300 |
301 | /**
302 | * Returns whether DRY results are available for the specified job.
303 | *
304 | * @param job
305 | * the job to get the warnings for
306 | * @return true if there are results, false otherwise
307 | */
308 | public boolean hasDry(final Job, ?> job) {
309 | if (isDryActivated()) {
310 | return hasAction(job, new DryHandler());
311 | }
312 | return false;
313 | }
314 |
315 | /**
316 | * Returns whether FindBugs results are available for the specified job.
317 | *
318 | * @param job
319 | * the job to get the warnings for
320 | * @return true if there are results, false otherwise
321 | */
322 | public boolean hasFindBugs(final Job, ?> job) {
323 | if (isFindBugsActivated()) {
324 | return hasAction(job, new FindBugsHandler());
325 | }
326 | return false;
327 | }
328 |
329 | /**
330 | * Returns whether PMD results are available for the specified job.
331 | *
332 | * @param job
333 | * the job to get the warnings for
334 | * @return true if there are results, false otherwise
335 | */
336 | public boolean hasPmd(final Job, ?> job) {
337 | if (isPmdActivated()) {
338 | return hasAction(job, new PmdHandler());
339 | }
340 | return false;
341 | }
342 |
343 | /**
344 | * Returns whether open tasks results are available for the specified job.
345 | *
346 | * @param job
347 | * the job to get the warnings for
348 | * @return true if there are results, false otherwise
349 | */
350 | public boolean hasTasks(final Job, ?> job) {
351 | if (isOpenTasksActivated()) {
352 | return hasAction(job, new TasksHandler());
353 | }
354 | return false;
355 | }
356 |
357 | /**
358 | * Returns whether compiler warning results are available for the specified job.
359 | *
360 | * @param job
361 | * the job to get the warnings for
362 | * @return true if there are results, false otherwise
363 | */
364 | public boolean hasCompilerWarnings(final Job, ?> job) {
365 | if (isWarningsActivated()) {
366 | return hasAction(job, new WarningsHandler());
367 | }
368 | return false;
369 | }
370 |
371 | /**
372 | * Returns whether Android lint results are available for the specified job.
373 | *
374 | * @param job
375 | * the job to get the warnings for
376 | * @return true if there are results, false otherwise
377 | */
378 | public boolean hasAndroidLint(final Job, ?> job) {
379 | if (isAndroidLintActivated()) {
380 | return hasAction(job, new AndroidLintHandler());
381 | }
382 | return false;
383 | }
384 |
385 | private boolean hasAction(final Job, ?> job, final AnalysisHandler handler) {
386 | AbstractProjectAction> action = job.getAction(handler.getProjectActionType());
387 |
388 | return action != null && action.hasValidResults();
389 | }
390 |
391 | /**
392 | * Removes the job/job-name prefix in the URL.
393 | */
394 | public void hideJobPrefix() {
395 | hideJobPrefix = true;
396 | }
397 | }
398 |
--------------------------------------------------------------------------------
/src/main/java/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet.java:
--------------------------------------------------------------------------------
1 | package hudson.plugins.analysis.collector.dashboard;
2 |
3 | import java.util.Collection;
4 |
5 | import org.apache.commons.lang.StringUtils;
6 | import org.kohsuke.stapler.DataBoundConstructor;
7 |
8 | import hudson.Extension;
9 |
10 | import hudson.model.Descriptor;
11 | import hudson.model.Job;
12 |
13 | import hudson.plugins.analysis.collector.AnalysisDescriptor;
14 | import hudson.plugins.analysis.collector.AnalysisProjectAction;
15 | import hudson.plugins.analysis.collector.Messages;
16 | import hudson.plugins.analysis.collector.WarningsAggregator;
17 | import hudson.plugins.analysis.core.AbstractProjectAction;
18 | import hudson.plugins.analysis.dashboard.AbstractWarningsTablePortlet;
19 | import hudson.plugins.view.dashboard.DashboardPortlet;
20 |
21 | /**
22 | * A portlet that shows a table with the number of warnings in a job.
23 | *
24 | * @author Ulli Hafner
25 | */
26 | public class WarningsTablePortlet extends AbstractWarningsTablePortlet {
27 | /** Determines whether images should be used in the table header. */
28 | private final boolean useImages;
29 |
30 | /**
31 | * Aggregates the warnings in participating analysis plug-ins.
32 | *
33 | * @since 1.37
34 | */
35 | private WarningsAggregator warningsAggregator;
36 |
37 | /**
38 | * Creates a new instance of {@link WarningsTablePortlet}.
39 | *
40 | * @param name
41 | * the name of the portlet
42 | * @param useImages
43 | * determines whether images should be used in the table header.
44 | * @param checkStyleActivated
45 | * determines whether to show the warnings from Checkstyle
46 | * @param dryActivated
47 | * determines whether to show the warnings from DRY
48 | * @param findBugsActivated
49 | * determines whether to show the warnings from FindBugs
50 | * @param pmdActivated
51 | * determines whether to show the warnings from PMD
52 | * @param openTasksActivated
53 | * determines whether to show open tasks
54 | * @param warningsActivated
55 | * determines whether to show compiler warnings
56 | * @param canHideZeroWarningsProjects
57 | * determines if zero warnings projects should be hidden in the table
58 | */
59 | @DataBoundConstructor
60 | // CHECKSTYLE:OFF
61 | public WarningsTablePortlet(final String name, final boolean useImages, final boolean checkStyleActivated,
62 | final boolean dryActivated, final boolean findBugsActivated, final boolean pmdActivated,
63 | final boolean openTasksActivated, final boolean warningsActivated,
64 | final boolean androidLintActivated, final boolean canHideZeroWarningsProjects) {
65 | // CHECKSTYLE:ON
66 | super(name, canHideZeroWarningsProjects);
67 |
68 | this.useImages = useImages;
69 |
70 | warningsAggregator = new WarningsAggregator(checkStyleActivated, dryActivated, findBugsActivated,
71 | pmdActivated, openTasksActivated, warningsActivated, androidLintActivated);
72 | }
73 |
74 | /**
75 | * Upgrade for release 1.36 or older.
76 | *
77 | * @return this
78 | */
79 | @SuppressWarnings("deprecation")
80 | protected Object readResolve() {
81 | if (warningsAggregator == null) {
82 | warningsAggregator = new WarningsAggregator(!isCheckStyleDeactivated, !isDryDeactivated,
83 | !isFindBugsDeactivated, !isPmdDeactivated, !isOpenTasksDeactivated, !isWarningsDeactivated, !isAndroidLintDeactivated);
84 | }
85 | return this;
86 | }
87 |
88 | @Override
89 | protected Class extends AbstractProjectAction>> getAction() {
90 | return AnalysisProjectAction.class;
91 | }
92 |
93 | /**
94 | * Returns whether images should be used in the table header.
95 | *
96 | * @return true if images should be used, false if
97 | * text should be used
98 | */
99 | public boolean getUseImages() {
100 | return useImages;
101 | }
102 |
103 | /**
104 | * Returns whether icons should be used in the table header.
105 | *
106 | * @return true if icons should be used, false if
107 | * text should be used
108 | */
109 | public boolean useIcons() {
110 | return useImages;
111 | }
112 |
113 | /**
114 | * Returns whether the totals column should be shown.
115 | *
116 | * @return true if the totals column should be shown, false otherwise
117 | */
118 | public boolean isTotalsVisible() {
119 | return toInt(isCheckStyleActivated())
120 | + toInt(isDryActivated())
121 | + toInt(isFindBugsActivated())
122 | + toInt(isPmdActivated())
123 | + toInt(isOpenTasksActivated())
124 | + toInt(isWarningsActivated())
125 | + toInt(isAndroidLintActivated()) > 1;
126 | }
127 |
128 | private int toInt(final boolean isActivated) {
129 | return isActivated ? 1 : 0;
130 | }
131 |
132 | /**
133 | * Returns whether CheckStyle results should be shown.
134 | *
135 | * @return true if CheckStyle results should be shown, false otherwise
136 | */
137 | public boolean isCheckStyleActivated() {
138 | return warningsAggregator.isCheckStyleActivated();
139 | }
140 |
141 | /**
142 | * Returns whether DRY results should be shown.
143 | *
144 | * @return true if DRY results should be shown, false otherwise
145 | */
146 | public boolean isDryActivated() {
147 | return warningsAggregator.isDryActivated();
148 | }
149 |
150 | /**
151 | * Returns whether FindBugs results should be shown.
152 | *
153 | * @return true if FindBugs results should be shown, false otherwise
154 | */
155 | public boolean isFindBugsActivated() {
156 | return warningsAggregator.isFindBugsActivated();
157 | }
158 |
159 | /**
160 | * Returns whether PMD results should be shown.
161 | *
162 | * @return true if PMD results should be shown, false otherwise
163 | */
164 | public boolean isPmdActivated() {
165 | return warningsAggregator.isPmdActivated();
166 | }
167 |
168 | /**
169 | * Returns whether open tasks should be shown.
170 | *
171 | * @return true if open tasks should be shown, false otherwise
172 | */
173 | public boolean isOpenTasksActivated() {
174 | return warningsAggregator.isOpenTasksActivated();
175 | }
176 |
177 | /**
178 | * Returns whether compiler warnings results should be shown.
179 | *
180 | * @return true if compiler warnings results should be shown, false otherwise
181 | */
182 | public boolean isWarningsActivated() {
183 | return warningsAggregator.isWarningsActivated();
184 | }
185 |
186 | /**
187 | * Returns whether Android lint results should be shown.
188 | *
189 | * @return true if Android lint results should be shown, false otherwise
190 | */
191 | public boolean isAndroidLintActivated() {
192 | return warningsAggregator.isAndroidLintActivated();
193 | }
194 |
195 | @Override
196 | protected boolean isVisibleJob(final Job, ?> job) {
197 | return toInt(getTotal(job)) > 0;
198 | }
199 |
200 | /**
201 | * Returns the number of warnings for the specified job.
202 | *
203 | * @param job
204 | * the job to get the warnings for
205 | * @return the number of warnings
206 | */
207 | public String getTotal(final Job, ?> job) {
208 | return warningsAggregator.getTotal(job);
209 | }
210 |
211 | private String filterUrl(final String link) {
212 | String prefix = getDashboard().getUrl();
213 | return link.replaceFirst(prefix, StringUtils.EMPTY);
214 | }
215 |
216 | /**
217 | * Returns the number of Checkstyle warnings for the specified job.
218 | *
219 | * @param job
220 | * the job to get the warnings for
221 | * @return the number of Checkstyle warnings
222 | */
223 | public String getCheckStyle(final Job, ?> job) {
224 | return filterUrl(warningsAggregator.getCheckStyle(job));
225 | }
226 |
227 | /**
228 | * Returns the number of duplicate code warnings for the specified job.
229 | *
230 | * @param job
231 | * the job to get the warnings for
232 | * @return the number of duplicate code warnings
233 | */
234 | public String getDry(final Job, ?> job) {
235 | return filterUrl(warningsAggregator.getDry(job));
236 | }
237 |
238 | /**
239 | * Returns the number of FindBugs warnings for the specified job.
240 | *
241 | * @param job
242 | * the job to get the warnings for
243 | * @return the number of FindBugs warnings
244 | */
245 | public String getFindBugs(final Job, ?> job) {
246 | return filterUrl(warningsAggregator.getFindBugs(job));
247 | }
248 |
249 | /**
250 | * Returns the number of PMD warnings for the specified job.
251 | *
252 | * @param job
253 | * the job to get the warnings for
254 | * @return the number of PMD warnings
255 | */
256 | public String getPmd(final Job, ?> job) {
257 | return filterUrl(warningsAggregator.getPmd(job));
258 | }
259 |
260 | /**
261 | * Returns the number of open tasks for the specified job.
262 | *
263 | * @param job
264 | * the job to get the tasks for
265 | * @return the number of open tasks
266 | */
267 | public String getTasks(final Job, ?> job) {
268 | return filterUrl(warningsAggregator.getTasks(job));
269 | }
270 |
271 | /**
272 | * Returns the total number of warnings for the specified job.
273 | *
274 | * @param job
275 | * the job to get the warnings for
276 | * @return the number of compiler warnings
277 | */
278 | public String getCompilerWarnings(final Job, ?> job) {
279 | return filterUrl(warningsAggregator.getCompilerWarnings(job));
280 | }
281 |
282 | /**
283 | * Returns the total number of Android lint warnings for the specified job.
284 | *
285 | * @param job
286 | * the job to get the warnings for
287 | * @return the number of Android lint warnings
288 | */
289 | public String getAndroidLint(final Job, ?> job) {
290 | return filterUrl(warningsAggregator.getAndroidLint(job));
291 | }
292 |
293 | /**
294 | * Returns the number of Checkstyle warnings for the specified jobs.
295 | *
296 | * @param jobs
297 | * the jobs to get the warnings for
298 | * @return the number of Checkstyle warnings
299 | */
300 | public String getCheckStyle(final Collectiontrue if the Checkstyle plug-in is installed,
457 | * false if not.
458 | */
459 | public boolean isCheckStyleInstalled() {
460 | return AnalysisDescriptor.isCheckStyleInstalled();
461 | }
462 |
463 | /**
464 | * Returns whether the Dry plug-in is installed.
465 | *
466 | * @return true if the Dry plug-in is installed,
467 | * false if not.
468 | */
469 | public boolean isDryInstalled() {
470 | return AnalysisDescriptor.isDryInstalled();
471 | }
472 |
473 | /**
474 | * Returns whether the FindBugs plug-in is installed.
475 | *
476 | * @return true if the FindBugs plug-in is installed,
477 | * false if not.
478 | */
479 | public boolean isFindBugsInstalled() {
480 | return AnalysisDescriptor.isFindBugsInstalled();
481 | }
482 |
483 | /**
484 | * Returns whether the PMD plug-in is installed.
485 | *
486 | * @return true if the PMD plug-in is installed,
487 | * false if not.
488 | */
489 | public boolean isPmdInstalled() {
490 | return AnalysisDescriptor.isPmdInstalled();
491 | }
492 |
493 | /**
494 | * Returns whether the Open Tasks plug-in is installed.
495 | *
496 | * @return true if the Open Tasks plug-in is installed,
497 | * false if not.
498 | */
499 | public boolean isOpenTasksInstalled() {
500 | return AnalysisDescriptor.isOpenTasksInstalled();
501 | }
502 |
503 | /**
504 | * Returns whether the Warnings plug-in is installed.
505 | *
506 | * @return true if the Warnings plug-in is installed,
507 | * false if not.
508 | */
509 | public boolean isWarningsInstalled() {
510 | return AnalysisDescriptor.isWarningsInstalled();
511 | }
512 |
513 | /**
514 | * Returns whether the Android Lint plug-in is installed.
515 | *
516 | * @return true if the Android Lint plug-in is installed,
517 | * false if not.
518 | */
519 | public boolean isAndroidLintInstalled() {
520 | return AnalysisDescriptor.isAndroidLintInstalled();
521 | }
522 |
523 | @Override
524 | public String getDisplayName() {
525 | return Messages.Portlet_WarningsTable();
526 | }
527 | }
528 | }
529 |
530 |
--------------------------------------------------------------------------------