├── .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 | 3 | ${%# Warnings} 4 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/Messages_de.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jenkinsci/analysis-collector-plugin/master/src/main/resources/hudson/plugins/analysis/collector/Messages_de.properties -------------------------------------------------------------------------------- /src/main/webapp/help_zh_TW.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | 啟用這個選項後,Jenkins 會把 Checkstyle, Dry, FindBugs, PMD, Tasks 及 Warnings 4 | 等靜態程式分析外掛程式全部彙總起來。彙總後的分析結果可以用來產出歷史結果趨勢、模組及套件 (Package) 5 | 統計、檢視分析報告及警告的網頁畫面、健康狀態報告及建置穩定性。 6 |

7 |
-------------------------------------------------------------------------------- /src/main/resources/index.jelly: -------------------------------------------------------------------------------- 1 |
2 | The Analysis Collector plug-in reached end-of-life. All functionality has been integrated 3 | into the Warnings Next Generation Plugin. 4 |
5 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet/portlet_de.properties: -------------------------------------------------------------------------------- 1 | Job=Job 2 | Duplicate\ Code=Duplizierter Quelltext 3 | Open\ Tasks=Offene Punkte 4 | Compiler\ Warnings=Compiler Warnungen 5 | Total=Gesamt 6 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet/WarningsPerJobDescriptor/local-config_ja.properties: -------------------------------------------------------------------------------- 1 | Name=\u540D\u79F0 2 | Show\ images\ in\ table\ header=\u8868\u306E\u30D8\u30C3\u30C0\u30FC\u306B\u30A4\u30E1\u30FC\u30B8\u3092\u8868\u793A -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=ISO-8859-1 3 | encoding//src/main/resources=ISO-8859-1 4 | encoding//src/test/java=ISO-8859-1 5 | encoding//src/test/resources=ISO-8859-1 6 | encoding/=ISO-8859-1 7 | -------------------------------------------------------------------------------- /src/main/resources/graph/tools_de.properties: -------------------------------------------------------------------------------- 1 | Checkstyle\ warnings=Checkstyle Warnungen 2 | Duplicate\ code\ warnings=Duplizierter Quelltext 3 | FindBugs\ warnings=FindBugs Warnungen 4 | PMD\ warnings=PMD Warnungen 5 | Open\ tasks=Offene Punkte 6 | Compiler\ warnings=Compiler Warnungen 7 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/tokens/WarningsCountTokenMacro/help.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
$${ANALYSIS_COUNT}
5 |
6 | Expands to the total number of warnings in a build. 7 |
8 | 9 |
-------------------------------------------------------------------------------- /src/main/resources/graph/deactivate_ja.properties: -------------------------------------------------------------------------------- 1 | disable.title=\u4ED6\u306E\u63A8\u79FB\u30B0\u30E9\u30D5\u3092\u7121\u52B9\u5316 2 | disable.description=\u4ED6\u306E\u9759\u7684\u89E3\u6790\u30D7\u30E9\u30B0\u30A4\u30F3\u306E\u63A8\u79FB\u30B0\u30E9\u30D5\u3092\u7121\u52B9\u5316\u3057\u307E\u3059\u3002 3 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/tokens/NewWarningsCountTokenMacro/help.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
$${ANALYSIS_NEW}
5 |
6 | Expands to the total number of new warnings in a build. 7 |
8 | 9 |
-------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | This plug-in is not supported anymore. It will be incorporated into "Jenkins Warnings Plug-in" and the 2 | associated "Static Analysis Model and Parsers" library soon. 3 | 4 | References: 5 | - https://github.com/jenkinsci/analysis-model 6 | - https://github.com/jenkinsci/warnings-plugin 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/AnalysisPublisher/global.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/tokens/FixedWarningsCountTokenMacro/help.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
$${ANALYSIS_FIXED}
5 |
6 | Expands to the total number of fixed warnings in a build. 7 |
8 | 9 |
-------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/tokens/WarningsResultTokenMacro/help.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
$${ANALYSIS_RESULT}
5 |
6 | Expands to the build result of the analysis collector plug-in. 7 |
8 | 9 |
-------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/AnalysisProjectAction/jobMain_de.properties: -------------------------------------------------------------------------------- 1 | Checkstyle\ Warnings=Checkstyle Warnungen 2 | Duplicate\ Code=Duplizierter Quelltext 3 | FindBugs\ Warnings=FindBugs Warnungen 4 | PMD\ Warnings=PMD Warnungen 5 | Open\ Tasks=Offene Punkte 6 | Compiler\ Warnings=Compiler Warnungen 7 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet/portlet_ja.properties: -------------------------------------------------------------------------------- 1 | Job=\u30B8\u30E7\u30D6 2 | Duplicate\ Code=\u91CD\u8907\u30B3\u30FC\u30C9 3 | Open\ Tasks=\u672A\u89E3\u6C7A\u30BF\u30B9\u30AF 4 | Compiler\ Warnings=\u30B3\u30F3\u30D1\u30A4\u30E9\u30FC\u306E\u8B66\u544A 5 | Total=\u5408\u8A08 6 | -------------------------------------------------------------------------------- /.pmd: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | ../analysis-config/etc/pmd-configuration.xml 5 | false 6 | false 7 | true 8 | 9 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/WarningsCountColumn/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/AnalysisUserGraphConfigurationView/local-config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/AnalysisDefaultGraphConfigurationView/local-config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsOriginGraphPortlet/WarningsGraphDescriptor/local-config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/main/webapp/help.html: -------------------------------------------------------------------------------- 1 |
2 |

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 |
-------------------------------------------------------------------------------- /src/main/resources/graph/deactivate.jelly: -------------------------------------------------------------------------------- 1 | 4 | 5 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet/WarningsPerJobDescriptor/local-config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/WarningsCountColumn/column.jelly: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ${it.getNumberOfAnnotations(job)} 6 | 7 | 8 | ${it.getNumberOfAnnotations(job)} 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/AnalysisPublisher/config.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/main/webapp/help_de.html: -------------------------------------------------------------------------------- 1 |
2 |

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 |
11 | -------------------------------------------------------------------------------- /.checkstyle: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/analysis/collector/AnalysisResultTest.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import hudson.model.AbstractBuild; 4 | import hudson.plugins.analysis.core.BuildHistory; 5 | import hudson.plugins.analysis.core.ParserResult; 6 | import hudson.plugins.analysis.test.BuildResultTest; 7 | 8 | /** 9 | * Tests the class {@link AnalysisResult}. 10 | */ 11 | public class AnalysisResultTest extends BuildResultTest { 12 | @Override 13 | protected AnalysisResult createBuildResult(final AbstractBuild build, final ParserResult project, final BuildHistory history) { 14 | return new AnalysisResult(build, history, project, "UTF8", false); 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /src/test/resources/checkstyle-result-build2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/tokens/WarningsResultTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.collector.AnalysisResultAction; 5 | import hudson.plugins.analysis.tokens.AbstractResultTokenMacro; 6 | 7 | /** 8 | * Provides a token that evaluates to the warnings collector build result. 9 | * 10 | * @author Ulli Hafner 11 | */ 12 | @Extension(optional = true) 13 | public class WarningsResultTokenMacro extends AbstractResultTokenMacro { 14 | /** 15 | * Creates a new instance of {@link WarningsResultTokenMacro}. 16 | */ 17 | @SuppressWarnings("unchecked") 18 | public WarningsResultTokenMacro() { 19 | super("ANALYSIS_RESULT", AnalysisResultAction.class); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/tokens/WarningsCountTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.collector.AnalysisResultAction; 5 | import hudson.plugins.analysis.tokens.AbstractAnnotationsCountTokenMacro; 6 | 7 | /** 8 | * Provides a token that evaluates to the number of warnings. 9 | * 10 | * @author Ulli Hafner 11 | */ 12 | @Extension(optional = true) 13 | public class WarningsCountTokenMacro extends AbstractAnnotationsCountTokenMacro { 14 | /** 15 | * Creates a new instance of {@link WarningsCountTokenMacro}. 16 | */ 17 | @SuppressWarnings("unchecked") 18 | public WarningsCountTokenMacro() { 19 | super("ANALYSIS_COUNT", AnalysisResultAction.class); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/tokens/NewWarningsCountTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.collector.AnalysisResultAction; 5 | import hudson.plugins.analysis.tokens.AbstractNewAnnotationsTokenMacro; 6 | 7 | /** 8 | * Provides a token that evaluates to the number of new warnings. 9 | * 10 | * @author Ulli Hafner 11 | */ 12 | @Extension(optional = true) 13 | public class NewWarningsCountTokenMacro extends AbstractNewAnnotationsTokenMacro { 14 | /** 15 | * Creates a new instance of {@link NewWarningsCountTokenMacro}. 16 | */ 17 | @SuppressWarnings("unchecked") 18 | public NewWarningsCountTokenMacro() { 19 | super("ANALYSIS_NEW", AnalysisResultAction.class); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/tokens/FixedWarningsCountTokenMacro.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.tokens; 2 | 3 | import hudson.Extension; 4 | import hudson.plugins.analysis.collector.AnalysisResultAction; 5 | import hudson.plugins.analysis.tokens.AbstractFixedAnnotationsTokenMacro; 6 | 7 | /** 8 | * Provides a token that evaluates to the number of new warnings. 9 | * 10 | * @author Ulli Hafner 11 | */ 12 | @Extension(optional = true) 13 | public class FixedWarningsCountTokenMacro extends AbstractFixedAnnotationsTokenMacro { 14 | /** 15 | * Creates a new instance of {@link FixedWarningsCountTokenMacro}. 16 | */ 17 | @SuppressWarnings("unchecked") 18 | public FixedWarningsCountTokenMacro() { 19 | super("ANALYSIS_FIXED", AnalysisResultAction.class); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008-2011 Dr. Ullrich Hafner 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet/WarningsPerJobDescriptor/local-config_fr.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2004-2010, Sun Microsystems, Inc. 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 | Name=Nom 24 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet/portlet_fr.properties: -------------------------------------------------------------------------------- 1 | # The MIT License 2 | # 3 | # Copyright (c) 2004-2010, Sun Microsystems, Inc. 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 | Compiler\ Warnings=Alertes du Compilateur 24 | Duplicate\ Code=Code Dupliqu\u00E9 25 | Open\ Tasks=T\u00E2ches ouvertes 26 | Total=Total 27 | -------------------------------------------------------------------------------- /src/main/resources/graph/deactivate_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 | disable.title=\u95dc\u9589\u5176\u4ed6\u8da8\u52e2\u5716 24 | disable.description=\u95dc\u9589\u5176\u4ed6\u975c\u614b\u5206\u6790\u5916\u639b\u7a0b\u5f0f\u7684\u8da8\u52e2\u5716 25 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet/WarningsPerJobDescriptor/local-config_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 | Show\ images\ in\ table\ header=\u5728\u8868\u683c\u6a19\u984c\u4e0a\u986f\u793a\u5f71\u50cf 24 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/handler/DryHandler.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.handler; 2 | 3 | import java.util.Collection; 4 | 5 | import org.jvnet.localizer.Localizable; 6 | 7 | import com.google.common.collect.Lists; 8 | 9 | import hudson.plugins.analysis.collector.AnalysisDescriptor; 10 | import hudson.plugins.analysis.core.AbstractProjectAction; 11 | import hudson.plugins.analysis.core.BuildResult; 12 | import hudson.plugins.analysis.core.PluginDescriptor; 13 | import hudson.plugins.analysis.core.ResultAction; 14 | import hudson.plugins.dry.*; 15 | 16 | /** 17 | * Handles access to the DRY plug-in. 18 | * 19 | * @author Ulli Hafner 20 | */ 21 | public class DryHandler implements AnalysisHandler { 22 | @Override 23 | public Class> getProjectActionType() { 24 | return DryProjectAction.class; 25 | } 26 | 27 | @Override 28 | public String getUrl() { 29 | return AnalysisDescriptor.DRY; 30 | } 31 | 32 | @Override 33 | public Localizable getDetailHeader() { 34 | return Messages._DRY_Detail_header(); 35 | } 36 | 37 | @Override 38 | public Class getDescriptor() { 39 | return DryDescriptor.class; 40 | } 41 | 42 | @Override 43 | public Collection>> getResultActions() { 44 | return Lists.newArrayList(DryResultAction.class, DryMavenResultAction.class); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/handler/PmdHandler.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.handler; 2 | 3 | import java.util.Collection; 4 | 5 | import org.jvnet.localizer.Localizable; 6 | 7 | import com.google.common.collect.Lists; 8 | 9 | import hudson.plugins.analysis.collector.AnalysisDescriptor; 10 | import hudson.plugins.analysis.core.AbstractProjectAction; 11 | import hudson.plugins.analysis.core.BuildResult; 12 | import hudson.plugins.analysis.core.PluginDescriptor; 13 | import hudson.plugins.analysis.core.ResultAction; 14 | import hudson.plugins.pmd.*; 15 | 16 | /** 17 | * Handles access to the PMD plug-in. 18 | * 19 | * @author Ulli Hafner 20 | */ 21 | public class PmdHandler implements AnalysisHandler { 22 | @Override 23 | public Class> getProjectActionType() { 24 | return PmdProjectAction.class; 25 | } 26 | 27 | @Override 28 | public String getUrl() { 29 | return AnalysisDescriptor.PMD; 30 | } 31 | 32 | @Override 33 | public Localizable getDetailHeader() { 34 | return Messages._PMD_Detail_header(); 35 | } 36 | 37 | @Override 38 | public Class getDescriptor() { 39 | return PmdDescriptor.class; 40 | } 41 | 42 | @Override 43 | public Collection>> getResultActions() { 44 | return Lists.newArrayList(PmdResultAction.class, PmdMavenResultAction.class); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/dashboard/WarningsTablePortlet/portlet_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 | Job=\u4f5c\u696d 24 | 25 | Duplicate\ Code=\u91cd\u8907\u7a0b\u5f0f\u78bc 26 | Open\ Tasks=\u672a\u89e3\u5de5\u4f5c 27 | Compiler\ Warnings=\u7de8\u8b6f\u5668\u8b66\u544a 28 | 29 | Total=\u7e3d\u8a08 30 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/handler/TasksHandler.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.handler; 2 | 3 | import java.util.Collection; 4 | 5 | import org.jvnet.localizer.Localizable; 6 | 7 | import com.google.common.collect.Lists; 8 | 9 | import hudson.plugins.analysis.collector.AnalysisDescriptor; 10 | import hudson.plugins.analysis.core.AbstractProjectAction; 11 | import hudson.plugins.analysis.core.BuildResult; 12 | import hudson.plugins.analysis.core.PluginDescriptor; 13 | import hudson.plugins.analysis.core.ResultAction; 14 | import hudson.plugins.tasks.*; 15 | 16 | /** 17 | * Handles access to the open tasks plug-in. 18 | * 19 | * @author Ulli Hafner 20 | */ 21 | public class TasksHandler implements AnalysisHandler { 22 | @Override 23 | public Class> getProjectActionType() { 24 | return TasksProjectAction.class; 25 | } 26 | 27 | @Override 28 | public String getUrl() { 29 | return AnalysisDescriptor.TASKS; 30 | } 31 | 32 | @Override 33 | public Localizable getDetailHeader() { 34 | return Messages._Tasks_ProjectAction_Name(); 35 | } 36 | 37 | @Override 38 | public Class getDescriptor() { 39 | return TasksDescriptor.class; 40 | } 41 | 42 | @Override 43 | public Collection>> getResultActions() { 44 | return Lists.newArrayList(TasksResultAction.class, TasksMavenResultAction.class); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/resources/graph/tools_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 | Checkstyle\ warnings=Checkstyle \u8b66\u544a 24 | Duplicate\ code\ warnings=\u91cd\u8907\u7a0b\u5f0f\u78bc\u8b66\u544a 25 | FindBugs\ warnings=FindBugs \u8b66\u544a 26 | PMD\ warnings=PMD \u8b66\u544a 27 | Open\ tasks=\u672a\u89e3\u5de5\u4f5c 28 | Compiler\ warnings=\u7de8\u8b6f\u5668\u8b66\u544a 29 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/handler/FindBugsHandler.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.handler; 2 | 3 | import java.util.Collection; 4 | 5 | import org.jvnet.localizer.Localizable; 6 | 7 | import com.google.common.collect.Lists; 8 | 9 | import hudson.plugins.analysis.collector.AnalysisDescriptor; 10 | import hudson.plugins.analysis.core.AbstractProjectAction; 11 | import hudson.plugins.analysis.core.BuildResult; 12 | import hudson.plugins.analysis.core.PluginDescriptor; 13 | import hudson.plugins.analysis.core.ResultAction; 14 | import hudson.plugins.findbugs.*; 15 | 16 | /** 17 | * Handles access to the FindBugs plug-in. 18 | * 19 | * @author Ulli Hafner 20 | */ 21 | public class FindBugsHandler implements AnalysisHandler { 22 | @Override 23 | public Class> getProjectActionType() { 24 | return FindBugsProjectAction.class; 25 | } 26 | 27 | @Override 28 | public String getUrl() { 29 | return AnalysisDescriptor.FINDBUGS; 30 | } 31 | 32 | @Override 33 | public Localizable getDetailHeader() { 34 | return Messages._FindBugs_Detail_header(); 35 | } 36 | 37 | @Override 38 | public Class getDescriptor() { 39 | return FindBugsDescriptor.class; 40 | } 41 | 42 | @Override 43 | public Collection>> getResultActions() { 44 | return Lists.newArrayList(FindBugsResultAction.class, FindBugsMavenResultAction.class); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/Messages.properties: -------------------------------------------------------------------------------- 1 | Analysis.Warnings.Column=Number of warnings 2 | Analysis.Publisher.Name=[Deprecated] Publish combined static analysis results 3 | 4 | Analysis.ProjectAction.Name=Static Analysis Warnings 5 | 6 | Analysis.Trend.Name=Static Analysis Trend 7 | 8 | Analysis.ResultAction.Header=Static Analysis Result 9 | 10 | Analysis.ResultAction.HealthReportNoItem=Static Analysis: no warnings found. 11 | Analysis.ResultAction.HealthReportSingleItem=Static Analysis: one warning found. 12 | Analysis.ResultAction.HealthReportMultipleItem=Static Analysis: {0} warnings found. 13 | 14 | Analysis.Detail.header=Static Analysis Warnings 15 | 16 | Analysis.FixedWarnings.Detail.header=Fixed Warnings 17 | Analysis.NewWarnings.Detail.header=New Warnings 18 | 19 | Analysis.Checkstyle.Warning.Origin=Checkstyle 20 | Analysis.Dry.Warning.Origin=Duplicate Code 21 | Analysis.FindBugs.Warning.Origin=FindBugs 22 | Analysis.PMD.Warning.Origin=PMD 23 | Analysis.Tasks.Warning.Origin=Open Task 24 | Analysis.Warnings.Warning.Origin=Compiler 25 | Analysis.AndroidLint.Warning.Origin=Android Lint 26 | 27 | Trend.type.analysis=Distribution of warnings by type 28 | 29 | Portlet.WarningsTable=Warnings per project 30 | Portlet.WarningsPriorityGraph=Warnings trend graph (priority distribution) 31 | Portlet.WarningsNewVsFixedGraph=Warnings trend graph (new vs. fixed) 32 | Portlet.WarningsOriginGraph=Warnings trend graph (type distribution) 33 | Portlet.WarningsTotalsGraph=Warnings trend graph (totals) 34 | Portlet.WarningsUserGraph=Warnings (priority per author) 35 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/handler/AnalysisHandler.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.handler; 2 | 3 | import java.util.Collection; 4 | 5 | import org.jvnet.localizer.Localizable; 6 | 7 | import hudson.plugins.analysis.core.AbstractProjectAction; 8 | import hudson.plugins.analysis.core.BuildResult; 9 | import hudson.plugins.analysis.core.PluginDescriptor; 10 | import hudson.plugins.analysis.core.ResultAction; 11 | 12 | /** 13 | * Handles access to the individual plug-in results. 14 | * 15 | * @author Ulli Hafner 16 | */ 17 | public interface AnalysisHandler { 18 | /** 19 | * Returns the class of the project action of the plug-in. 20 | * 21 | * @return project action class 22 | */ 23 | Class> getProjectActionType(); 24 | 25 | /** 26 | * Returns the URL of the plugin. 27 | * 28 | * @return plug-in URL 29 | */ 30 | String getUrl(); 31 | 32 | /** 33 | * Returns the header of the plug-in details. 34 | * 35 | * @return localized header of the details 36 | */ 37 | Localizable getDetailHeader(); 38 | 39 | /** 40 | * Returns the descriptor of the plug-in. 41 | * 42 | * @return plugin descriptor 43 | */ 44 | Class getDescriptor(); 45 | 46 | /** 47 | * Returns the class of the project action of the plug-in. 48 | * 49 | * @return project action class 50 | */ 51 | Collection>> getResultActions(); 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/handler/CheckStyleHandler.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.handler; 2 | 3 | import java.util.Collection; 4 | 5 | import org.jvnet.localizer.Localizable; 6 | 7 | import com.google.common.collect.Lists; 8 | 9 | import hudson.plugins.analysis.collector.AnalysisDescriptor; 10 | import hudson.plugins.analysis.core.AbstractProjectAction; 11 | import hudson.plugins.analysis.core.BuildResult; 12 | import hudson.plugins.analysis.core.PluginDescriptor; 13 | import hudson.plugins.analysis.core.ResultAction; 14 | import hudson.plugins.checkstyle.*; 15 | 16 | /** 17 | * Handles access to the Checkstyle plug-in. 18 | * 19 | * @author Ulli Hafner 20 | */ 21 | public class CheckStyleHandler implements AnalysisHandler { 22 | @Override 23 | public Class> getProjectActionType() { 24 | return CheckStyleProjectAction.class; 25 | } 26 | 27 | @Override 28 | public String getUrl() { 29 | return AnalysisDescriptor.CHECKSTYLE; 30 | } 31 | 32 | @Override 33 | public Localizable getDetailHeader() { 34 | return Messages._Checkstyle_Detail_header(); 35 | } 36 | 37 | @Override 38 | public Class getDescriptor() { 39 | return CheckStyleDescriptor.class; 40 | } 41 | 42 | @Override 43 | public Collection>> getResultActions() { 44 | return Lists.newArrayList(CheckStyleResultAction.class, CheckStyleMavenResultAction.class); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/AnalysisHealthDescriptor.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import hudson.plugins.analysis.core.AbstractHealthDescriptor; 4 | import hudson.plugins.analysis.core.HealthDescriptor; 5 | import hudson.plugins.analysis.util.model.AnnotationProvider; 6 | 7 | import org.jvnet.localizer.Localizable; 8 | 9 | /** 10 | * A health descriptor for the collected analysis results. 11 | * 12 | * @author Ulli Hafner 13 | */ 14 | public class AnalysisHealthDescriptor extends AbstractHealthDescriptor { 15 | /** Unique ID of this class. */ 16 | private static final long serialVersionUID = -4517492804694055774L; 17 | 18 | /** 19 | * Creates a new instance of {@link AnalysisHealthDescriptor} based on the 20 | * values of the specified descriptor. 21 | * 22 | * @param healthDescriptor the descriptor to copy the values from 23 | */ 24 | public AnalysisHealthDescriptor(final HealthDescriptor healthDescriptor) { 25 | super(healthDescriptor); 26 | } 27 | 28 | @Override 29 | protected Localizable createDescription(final AnnotationProvider result) { 30 | if (result.getNumberOfAnnotations() == 0) { 31 | return Messages._Analysis_ResultAction_HealthReportNoItem(); 32 | } 33 | else if (result.getNumberOfAnnotations() == 1) { 34 | return Messages._Analysis_ResultAction_HealthReportSingleItem(); 35 | } 36 | else { 37 | return Messages._Analysis_ResultAction_HealthReportMultipleItem(result.getNumberOfAnnotations()); 38 | } 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/handler/AndroidLintHandler.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.handler; 2 | 3 | import com.google.common.collect.Lists; 4 | 5 | import org.jenkinsci.plugins.android_lint.LintDescriptor; 6 | import org.jenkinsci.plugins.android_lint.LintMavenResultAction; 7 | import org.jenkinsci.plugins.android_lint.LintProjectAction; 8 | import org.jenkinsci.plugins.android_lint.LintResultAction; 9 | import org.jenkinsci.plugins.android_lint.Messages; 10 | import org.jvnet.localizer.Localizable; 11 | 12 | import java.util.Collection; 13 | 14 | import hudson.plugins.analysis.core.AbstractProjectAction; 15 | import hudson.plugins.analysis.core.BuildResult; 16 | import hudson.plugins.analysis.core.PluginDescriptor; 17 | import hudson.plugins.analysis.core.ResultAction; 18 | 19 | /** 20 | * Handles access to the Android Lint plug-in. 21 | */ 22 | public class AndroidLintHandler implements AnalysisHandler { 23 | @Override 24 | public Class> getProjectActionType() { 25 | return LintProjectAction.class; 26 | } 27 | 28 | @Override 29 | public String getUrl() { 30 | return "androidLint"; 31 | } 32 | 33 | @Override 34 | public Localizable getDetailHeader() { 35 | return Messages._AndroidLint_Warnings_ColumnHeader(); 36 | } 37 | 38 | @Override 39 | public Class getDescriptor() { 40 | return LintDescriptor.class; 41 | } 42 | 43 | @Override 44 | public Collection>> getResultActions() { 45 | return Lists.newArrayList(LintResultAction.class, LintMavenResultAction.class); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/handler/WarningsHandler.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.handler; 2 | 3 | import java.util.Collection; 4 | 5 | import org.jvnet.localizer.Localizable; 6 | 7 | import com.google.common.collect.Lists; 8 | 9 | import hudson.plugins.analysis.collector.AnalysisDescriptor; 10 | import hudson.plugins.analysis.core.AbstractProjectAction; 11 | import hudson.plugins.analysis.core.BuildResult; 12 | import hudson.plugins.analysis.core.PluginDescriptor; 13 | import hudson.plugins.analysis.core.ResultAction; 14 | import hudson.plugins.warnings.AggregatedWarningsProjectAction; 15 | import hudson.plugins.warnings.AggregatedWarningsResultAction; 16 | import hudson.plugins.warnings.Messages; 17 | import hudson.plugins.warnings.WarningsDescriptor; 18 | 19 | /** 20 | * Handles access to the warnings plug-in. 21 | * 22 | * @author Ulli Hafner 23 | */ 24 | public class WarningsHandler implements AnalysisHandler { 25 | @Override 26 | public Class> getProjectActionType() { 27 | return AggregatedWarningsProjectAction.class; 28 | } 29 | 30 | @Override 31 | public String getUrl() { 32 | return AnalysisDescriptor.WARNINGS; 33 | } 34 | 35 | @Override 36 | public Localizable getDetailHeader() { 37 | return Messages._Warnings_ProjectAction_Name(); 38 | } 39 | 40 | @Override 41 | public Class getDescriptor() { 42 | return WarningsDescriptor.class; 43 | } 44 | 45 | @Override 46 | public Collection>> getResultActions() { 47 | return Lists.newArrayList(AggregatedWarningsResultAction.class); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/resources/graph/tools.jelly: -------------------------------------------------------------------------------- 1 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/Messages_ja.properties: -------------------------------------------------------------------------------- 1 | Analysis.Publisher.Name=\u9759\u7684\u89E3\u6790\u7D50\u679C\u3092\u96C6\u7D04 2 | 3 | Analysis.ProjectAction.Name=\u9759\u7684\u89E3\u6790\u8B66\u544A 4 | 5 | Analysis.Trend.Name=\u9759\u7684\u89E3\u6790\u306E\u63A8\u79FB 6 | 7 | Analysis.ResultAction.Header=\u9759\u7684\u89E3\u6790\u306E\u7D50\u679C 8 | 9 | Analysis.ResultAction.HealthReportNoItem=Analysis:\u8B66\u544A\u306F\u3042\u308A\u307E\u305B\u3093\u3002 10 | Analysis.ResultAction.HealthReportSingleItem=Analysis: 1\u500B\u306E\u8B66\u544A\u3092\u691C\u51FA\u3057\u307E\u3057\u305F\u3002 11 | Analysis.ResultAction.HealthReportMultipleItem=Analysis: {0}\u500B\u306E\u8B66\u544A\u3092\u691C\u51FA\u3057\u307E\u3057\u305F\u3002 12 | 13 | Analysis.Detail.header=\u9759\u7684\u7D50\u679C\u8B66\u544A 14 | 15 | Analysis.FixedWarnings.Detail.header=\u4FEE\u6B63\u3055\u308C\u305F\u8B66\u544A 16 | Analysis.NewWarnings.Detail.header=\u65B0\u898F\u306E\u8B66\u544A 17 | 18 | Analysis.Checkstyle.Warning.Origin=Checkstyle 19 | Analysis.Dry.Warning.Origin=\u91CD\u8907\u30B3\u30FC\u30C9\u5206\u6790 20 | Analysis.FindBugs.Warning.Origin=FindBugs 21 | Analysis.PMD.Warning.Origin=PMD 22 | Analysis.Tasks.Warning.Origin=\u672A\u89E3\u6C7A\u30BF\u30B9\u30AF 23 | Analysis.Warnings.Warning.Origin=\u30B3\u30F3\u30D1\u30A4\u30E9\u30FC\u306E\u8B66\u544A 24 | 25 | Trend.type.analysis=\u3059\u3079\u3066\u306E\u8B66\u544A\u3092\u30BF\u30A4\u30D7\u3067\u5206\u5E03\u8868\u793A 26 | 27 | Portlet.WarningsTable=\u30D7\u30ED\u30B8\u30A7\u30AF\u30C8\u6BCE\u306E\u8B66\u544A 28 | Portlet.WarningsPriorityGraph=\u8B66\u544A\u63A8\u79FB\u30B0\u30E9\u30D5 (\u512A\u5148\u5EA6\u306E\u5206\u5E03) 29 | Portlet.WarningsNewVsFixedGraph=\u8B66\u544A\u63A8\u79FB\u30B0\u30E9\u30D5 (\u65B0\u898F vs. \u4FEE\u6B63\u6E08) 30 | Portlet.WarningsOriginGraph=\u8B66\u544A\u63A8\u79FB\u30B0\u30E9\u30D5 (\u30BF\u30A4\u30D7\u306E\u5206\u5E03) -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/AnalysisResultAction.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import java.util.Collection; 4 | 5 | import hudson.model.Action; 6 | import hudson.model.Run; 7 | 8 | import hudson.plugins.analysis.core.AbstractResultAction; 9 | import hudson.plugins.analysis.core.HealthDescriptor; 10 | import hudson.plugins.analysis.core.PluginDescriptor; 11 | 12 | /** 13 | * Controls the live cycle of the analysis results. This action persists the 14 | * results of the static analysis tools of a build and displays the results on the 15 | * build page. The actual visualization of the results is defined in the 16 | * matching 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 AbstractResultAction { 24 | /** 25 | * Creates a new instance of {@link AbstractResultAction}. 26 | * 27 | * @param owner 28 | * the associated build of this action 29 | * @param healthDescriptor 30 | * health descriptor to use 31 | * @param result 32 | * the result of this build 33 | */ 34 | public AnalysisResultAction(final Run owner, final HealthDescriptor healthDescriptor, final AnalysisResult result) { 35 | super(owner, new AnalysisHealthDescriptor(healthDescriptor), result); 36 | } 37 | 38 | @Override 39 | public String getDisplayName() { 40 | return Messages.Analysis_ProjectAction_Name(); 41 | } 42 | 43 | @Override 44 | protected PluginDescriptor getDescriptor() { 45 | return new AnalysisDescriptor(); 46 | } 47 | 48 | @Override 49 | public Collection getProjectActions() { 50 | return asSet(new AnalysisProjectAction(getJob())); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/analysis/collector/AnalysisHealthDescriptorTest.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import static org.junit.Assert.*; 4 | import static org.mockito.Mockito.*; 5 | import hudson.plugins.analysis.core.AbstractHealthDescriptor; 6 | import hudson.plugins.analysis.core.HealthDescriptor; 7 | import hudson.plugins.analysis.core.NullHealthDescriptor; 8 | import hudson.plugins.analysis.test.AbstractHealthDescriptorTest; 9 | import hudson.plugins.analysis.util.model.AnnotationProvider; 10 | 11 | import org.junit.Test; 12 | import org.jvnet.localizer.Localizable; 13 | 14 | /** 15 | * Tests the class {@link AnalysisHealthDescriptor}. 16 | * 17 | * @author Ulli Hafner 18 | */ 19 | public class AnalysisHealthDescriptorTest extends AbstractHealthDescriptorTest { 20 | /** 21 | * Verify number of items. 22 | */ 23 | @Test 24 | public void verifyNumberOfItems() { 25 | AnnotationProvider provider = mock(AnnotationProvider.class); 26 | AnalysisHealthDescriptor healthDescriptor = new AnalysisHealthDescriptor(NullHealthDescriptor.NULL_HEALTH_DESCRIPTOR); 27 | 28 | Localizable description = healthDescriptor.createDescription(provider); 29 | assertEquals(WRONG_DESCRIPTION, Messages.Analysis_ResultAction_HealthReportNoItem(), description.toString()); 30 | 31 | when(provider.getNumberOfAnnotations()).thenReturn(1); 32 | description = healthDescriptor.createDescription(provider); 33 | assertEquals(WRONG_DESCRIPTION, Messages.Analysis_ResultAction_HealthReportSingleItem(), description.toString()); 34 | 35 | when(provider.getNumberOfAnnotations()).thenReturn(2); 36 | description = healthDescriptor.createDescription(provider); 37 | assertEquals(WRONG_DESCRIPTION, Messages.Analysis_ResultAction_HealthReportMultipleItem(2), description.toString()); 38 | } 39 | 40 | @Override 41 | protected AbstractHealthDescriptor createHealthDescriptor(final HealthDescriptor healthDescriptor) { 42 | return new AnalysisHealthDescriptor(healthDescriptor); 43 | } 44 | } 45 | 46 | -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/analysis/collector/Main.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import hudson.util.DataSetBuilder; 4 | 5 | import org.jfree.chart.ChartPanel; 6 | import org.jfree.chart.JFreeChart; 7 | import org.jfree.chart.plot.CategoryPlot; 8 | import org.jfree.chart.renderer.category.CategoryItemRenderer; 9 | import org.jfree.ui.ApplicationFrame; 10 | import org.jfree.ui.RefineryUtilities; 11 | 12 | /** 13 | * Plots a graph. 14 | * 15 | * @author Ulli Hafner 16 | */ 17 | // CHECKSTYLE:OFF 18 | public class Main extends ApplicationFrame { 19 | /** Unique ID. */ 20 | private static final long serialVersionUID = -4097403148044461272L; 21 | 22 | /** 23 | * Creates a new instance of {@link Main}. 24 | */ 25 | public Main() { 26 | super("Hello Graph"); 27 | 28 | OriginGraph graph = new OriginGraph(); 29 | DataSetBuilder builder = new DataSetBuilder(); 30 | builder.add(100, "Checkstyle", "#1"); 31 | builder.add(120, "Checkstyle", "#2"); 32 | builder.add(50, "Checkstyle", "#3"); 33 | 34 | builder.add(10, "PMD", "#1"); 35 | builder.add(20, "PMD", "#2"); 36 | builder.add(50, "PMD", "#3"); 37 | 38 | builder.add(50, "FindBugs", "#1"); 39 | builder.add(90, "FindBugs", "#2"); 40 | builder.add(12, "FindBugs", "#3"); 41 | 42 | JFreeChart chart = graph.createChart(builder.build()); 43 | 44 | CategoryItemRenderer renderer = graph.createRenderer(null, "Hallo", null); 45 | CategoryPlot plot = chart.getCategoryPlot(); 46 | plot.setRenderer(renderer); 47 | graph.setColors(chart, graph.getColors()); 48 | 49 | ChartPanel chartPanel = new ChartPanel(chart); 50 | chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); 51 | setContentPane(chartPanel); 52 | } 53 | 54 | /** 55 | * Shows the graph. 56 | * 57 | * @param args 58 | * not used 59 | */ 60 | public static void main(final String[] args) { 61 | Main chart = new Main(); 62 | chart.pack(); 63 | RefineryUtilities.centerFrameOnScreen(chart); 64 | chart.setVisible(true); 65 | } 66 | } 67 | 68 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/dashboard/WarningsTotalsGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.dashboard; 2 | 3 | import hudson.Extension; 4 | import hudson.model.Descriptor; 5 | import hudson.plugins.analysis.collector.AnalysisProjectAction; 6 | import hudson.plugins.analysis.collector.Messages; 7 | import hudson.plugins.analysis.core.AbstractProjectAction; 8 | import hudson.plugins.analysis.dashboard.AbstractWarningsGraphPortlet; 9 | import hudson.plugins.analysis.graph.BuildResultGraph; 10 | import hudson.plugins.analysis.graph.TotalsGraph; 11 | import hudson.plugins.view.dashboard.DashboardPortlet; 12 | 13 | import org.kohsuke.stapler.DataBoundConstructor; 14 | 15 | /** 16 | * A portlet that shows the warnings trend graph by priority. 17 | * 18 | * @author Ulli Hafner 19 | */ 20 | public final class WarningsTotalsGraphPortlet extends AbstractWarningsGraphPortlet { 21 | /** 22 | * Creates a new instance of {@link WarningsTotalsGraphPortlet}. 23 | * 24 | * @param name 25 | * the name of the portlet 26 | * @param width 27 | * width of the graph 28 | * @param height 29 | * height of the graph 30 | * @param dayCountString 31 | * number of days to consider 32 | */ 33 | @DataBoundConstructor 34 | public WarningsTotalsGraphPortlet(final String name, final String width, final String height, final String dayCountString) { 35 | super(name, width, height, dayCountString); 36 | 37 | configureGraph(getGraphType()); 38 | } 39 | 40 | @Override 41 | protected Class> getAction() { 42 | return AnalysisProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "analysis"; 48 | } 49 | 50 | @Override 51 | protected BuildResultGraph getGraphType() { 52 | return new TotalsGraph(); 53 | } 54 | 55 | /** 56 | * Extension point registration. 57 | * 58 | * @author Ulli Hafner 59 | */ 60 | @Extension(optional = true) 61 | public static class WarningsGraphDescriptor extends Descriptor { 62 | @Override 63 | public String getDisplayName() { 64 | return Messages.Portlet_WarningsTotalsGraph(); 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/dashboard/WarningsPriorityGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.dashboard; 2 | 3 | import hudson.Extension; 4 | import hudson.model.Descriptor; 5 | import hudson.plugins.analysis.collector.AnalysisProjectAction; 6 | import hudson.plugins.analysis.collector.Messages; 7 | import hudson.plugins.analysis.core.AbstractProjectAction; 8 | import hudson.plugins.analysis.dashboard.AbstractWarningsGraphPortlet; 9 | import hudson.plugins.analysis.graph.BuildResultGraph; 10 | import hudson.plugins.analysis.graph.PriorityGraph; 11 | import hudson.plugins.view.dashboard.DashboardPortlet; 12 | 13 | import org.kohsuke.stapler.DataBoundConstructor; 14 | 15 | /** 16 | * A portlet that shows the warnings trend graph by priority. 17 | * 18 | * @author Ulli Hafner 19 | */ 20 | public final class WarningsPriorityGraphPortlet extends AbstractWarningsGraphPortlet { 21 | /** 22 | * Creates a new instance of {@link WarningsPriorityGraphPortlet}. 23 | * 24 | * @param name 25 | * the name of the portlet 26 | * @param width 27 | * width of the graph 28 | * @param height 29 | * height of the graph 30 | * @param dayCountString 31 | * number of days to consider 32 | */ 33 | @DataBoundConstructor 34 | public WarningsPriorityGraphPortlet(final String name, final String width, final String height, final String dayCountString) { 35 | super(name, width, height, dayCountString); 36 | 37 | configureGraph(getGraphType()); 38 | } 39 | 40 | @Override 41 | protected Class> getAction() { 42 | return AnalysisProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "analysis"; 48 | } 49 | 50 | @Override 51 | protected BuildResultGraph getGraphType() { 52 | return new PriorityGraph(); 53 | } 54 | 55 | /** 56 | * Extension point registration. 57 | * 58 | * @author Ulli Hafner 59 | */ 60 | @Extension(optional = true) 61 | public static class WarningsGraphDescriptor extends Descriptor { 62 | @Override 63 | public String getDisplayName() { 64 | return Messages.Portlet_WarningsPriorityGraph(); 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/dashboard/WarningsUserGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.dashboard; 2 | 3 | import org.kohsuke.stapler.DataBoundConstructor; 4 | 5 | import static hudson.plugins.analysis.collector.Messages.*; 6 | 7 | import hudson.Extension; 8 | import hudson.model.Descriptor; 9 | import hudson.plugins.analysis.collector.AnalysisProjectAction; 10 | import hudson.plugins.analysis.core.AbstractProjectAction; 11 | import hudson.plugins.analysis.dashboard.AbstractWarningsGraphPortlet; 12 | import hudson.plugins.analysis.graph.AnnotationsByUserGraph; 13 | import hudson.plugins.analysis.graph.BuildResultGraph; 14 | import hudson.plugins.view.dashboard.DashboardPortlet; 15 | 16 | /** 17 | * A portlet that shows the warnings of the last build by user and priority. 18 | * 19 | * @author Ulli Hafner 20 | */ 21 | public final class WarningsUserGraphPortlet extends AbstractWarningsGraphPortlet { 22 | /** 23 | * Creates a new instance of {@link WarningsUserGraphPortlet}. 24 | * 25 | * @param name 26 | * the name of the portlet 27 | * @param width 28 | * width of the graph 29 | * @param height 30 | * height of the graph 31 | * @param dayCountString 32 | * number of days to consider 33 | */ 34 | @DataBoundConstructor 35 | public WarningsUserGraphPortlet(final String name, final String width, final String height, final String dayCountString) { 36 | super(name, width, height, dayCountString); 37 | 38 | configureGraph(getGraphType()); 39 | } 40 | 41 | @Override 42 | protected Class> getAction() { 43 | return AnalysisProjectAction.class; 44 | } 45 | 46 | @Override 47 | protected String getPluginName() { 48 | return "analysis"; 49 | } 50 | 51 | @Override 52 | protected BuildResultGraph getGraphType() { 53 | return new AnnotationsByUserGraph(); 54 | } 55 | 56 | /** 57 | * Extension point registration. 58 | * 59 | * @author Ulli Hafner 60 | */ 61 | @Extension(optional = true) 62 | public static class WarningsGraphDescriptor extends Descriptor { 63 | @Override 64 | public String getDisplayName() { 65 | return Portlet_WarningsUserGraph(); 66 | } 67 | } 68 | } 69 | 70 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/dashboard/WarningsNewVersusFixedGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.dashboard; 2 | 3 | import hudson.Extension; 4 | import hudson.model.Descriptor; 5 | import hudson.plugins.analysis.collector.AnalysisProjectAction; 6 | import hudson.plugins.analysis.collector.Messages; 7 | import hudson.plugins.analysis.core.AbstractProjectAction; 8 | import hudson.plugins.analysis.dashboard.AbstractWarningsGraphPortlet; 9 | import hudson.plugins.analysis.graph.BuildResultGraph; 10 | import hudson.plugins.analysis.graph.NewVersusFixedGraph; 11 | import hudson.plugins.view.dashboard.DashboardPortlet; 12 | 13 | import org.kohsuke.stapler.DataBoundConstructor; 14 | 15 | /** 16 | * A portlet that shows the warnings trend graph of fixed versus new warnings. 17 | * 18 | * @author Ulli Hafner 19 | */ 20 | public final class WarningsNewVersusFixedGraphPortlet extends AbstractWarningsGraphPortlet { 21 | /** 22 | * Creates a new instance of {@link WarningsNewVersusFixedGraphPortlet}. 23 | * 24 | * @param name 25 | * the name of the portlet 26 | * @param width 27 | * width of the graph 28 | * @param height 29 | * height of the graph 30 | * @param dayCountString 31 | * number of days to consider 32 | */ 33 | @DataBoundConstructor 34 | public WarningsNewVersusFixedGraphPortlet(final String name, final String width, final String height, final String dayCountString) { 35 | super(name, width, height, dayCountString); 36 | 37 | configureGraph(getGraphType()); 38 | } 39 | 40 | @Override 41 | protected Class> getAction() { 42 | return AnalysisProjectAction.class; 43 | } 44 | 45 | @Override 46 | protected String getPluginName() { 47 | return "analysis"; 48 | } 49 | 50 | @Override 51 | protected BuildResultGraph getGraphType() { 52 | return new NewVersusFixedGraph(); 53 | } 54 | 55 | /** 56 | * Extension point registration. 57 | * 58 | * @author Ulli Hafner 59 | */ 60 | @Extension(optional = true) 61 | public static class WarningsGraphDescriptor extends Descriptor { 62 | @Override 63 | public String getDisplayName() { 64 | return Messages.Portlet_WarningsNewVsFixedGraph(); 65 | } 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /src/main/resources/hudson/plugins/analysis/collector/AnalysisProjectAction/jobMain.jelly: -------------------------------------------------------------------------------- 1 | 2 | 4 |

Analysis results

5 | 6 |
    7 | 8 |
  • 9 | Checkstyle 10 | ${%Checkstyle Warnings}: 11 |
  • 12 |
    13 | 14 |
  • 15 | ${%Duplicate Code} 16 | ${%Duplicate Code}: 17 |
  • 18 |
    19 | 20 |
  • 21 | FindBugs 22 | ${%FindBugs Warnings}: 23 |
  • 24 |
    25 | 26 |
  • 27 | PMD 28 | ${%PMD Warnings}: 29 |
  • 30 |
    31 | 32 |
  • 33 | ${%Open Tasks} 34 | ${%Open Tasks}: 35 |
  • 36 |
    37 | 38 |
  • 39 | ${%Compiler Warnings} 40 | ${%Compiler Warnings}: 41 |
  • 42 |
    43 | 44 |
  • 45 | ${%Android Lint} 46 | ${%Android Lint Warnings}: 47 |
  • 48 |
    49 |
50 |
51 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/AnalysisDefaultGraphConfigurationView.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import java.io.FileNotFoundException; 4 | import java.io.IOException; 5 | 6 | import org.kohsuke.stapler.StaplerRequest; 7 | import org.kohsuke.stapler.StaplerResponse; 8 | 9 | import hudson.model.Job; 10 | import hudson.plugins.analysis.core.BuildHistory; 11 | import hudson.plugins.analysis.graph.DefaultGraphConfigurationView; 12 | import hudson.plugins.analysis.graph.GraphConfiguration; 13 | 14 | /** 15 | * Adds some more parameters to the configuration view. 16 | * 17 | * @author Ulli Hafner 18 | */ 19 | public class AnalysisDefaultGraphConfigurationView extends DefaultGraphConfigurationView { 20 | /** The graph configuration. */ 21 | private final AnalysisGraphConfiguration analysisConfiguration; 22 | 23 | /** 24 | * Creates a new instance of {@link AnalysisDefaultGraphConfigurationView}. 25 | * 26 | * @param configuration 27 | * the graph configuration 28 | * @param job 29 | * the owning job to configure the graphs for 30 | * @param pluginName 31 | * The name of the plug-in. 32 | * @param buildHistory 33 | * the build history for this job 34 | */ 35 | public AnalysisDefaultGraphConfigurationView(final AnalysisGraphConfiguration configuration, final Job job, 36 | final String pluginName, final BuildHistory buildHistory) { 37 | super(configuration, job, pluginName, buildHistory); 38 | 39 | analysisConfiguration = configuration; 40 | } 41 | 42 | @Override 43 | protected void persistValue(final String value, final String pluginName, final StaplerRequest request, 44 | final StaplerResponse response) throws FileNotFoundException, IOException { 45 | super.persistValue(value, pluginName, request, response); 46 | 47 | GraphConfiguration configuration; 48 | if (analysisConfiguration.canDeacticateOtherTrendGraphs()) { 49 | configuration = GraphConfiguration.createDeactivated(); 50 | } 51 | else { 52 | configuration = GraphConfiguration.createDefault(); 53 | } 54 | for (String plugin : AnalysisDescriptor.getPlugins()) { 55 | super.persistValue(configuration.serializeToString(), plugin, request, response); 56 | } 57 | } 58 | 59 | /** 60 | * Returns whether the trend graphs of the other plug-ins could be deactivated. 61 | * 62 | * @return true 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 Collection availableGraphs) { 28 | super(availableGraphs); 29 | } 30 | 31 | @Override 32 | protected boolean initializeLocal(final String[] localConfiguration) { 33 | if (localConfiguration.length >= 1) { 34 | if ("0".equals(localConfiguration[localConfiguration.length - 1])) { 35 | canDeactivateGraphs = false; 36 | return true; 37 | } 38 | else if ("1".equals(localConfiguration[localConfiguration.length - 1])) { 39 | canDeactivateGraphs = true; 40 | return true; 41 | } 42 | } 43 | return false; 44 | } 45 | 46 | @Override 47 | protected boolean initializeLocal(final JSONObject localConfiguration) { 48 | try { 49 | canDeactivateGraphs = localConfiguration.getBoolean("canDeacticateOtherTrendGraphs"); 50 | 51 | return true; 52 | } 53 | catch (JSONException exception) { 54 | canDeactivateGraphs = false; 55 | 56 | return false; 57 | } 58 | } 59 | 60 | /** 61 | * Returns whether the trend graphs of the other plug-ins could be deactivated. 62 | * 63 | * @return true 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 | 2 | 4.0.0 3 | 4 | 5 | org.jvnet.hudson.plugins 6 | analysis-pom 7 | 1.68 8 | ../analysis-pom 9 | 10 | 11 | analysis-collector 12 | hpi 13 | Static Analysis Collector Plug-in 14 | 2.0.1-SNAPSHOT 15 | http://wiki.jenkins-ci.org/x/tgeIAg 16 | 17 | 18 | This plug-in is an add-on for the plug-ins Checkstyle, Dry, FindBugs, PMD, Tasks, and Warnings: 19 | the plug-in collects the different analysis results and shows the results in a combined trend graph. 20 | Additionally, the plug-in provides health reporting and build stability based on these combined results. 21 | 22 | 23 | 24 | 25 | org.jvnet.hudson.plugins 26 | analysis-core 27 | 1.94 28 | 29 | 30 | org.jvnet.hudson.plugins 31 | analysis-test 32 | 1.20 33 | test 34 | 35 | 36 | org.jvnet.hudson.plugins 37 | checkstyle 38 | 3.43 39 | true 40 | 41 | 42 | org.jvnet.hudson.plugins 43 | dry 44 | 2.42 45 | true 46 | 47 | 48 | org.jvnet.hudson.plugins 49 | findbugs 50 | 4.62 51 | true 52 | 53 | 54 | org.jvnet.hudson.plugins 55 | pmd 56 | 3.42 57 | true 58 | 59 | 60 | org.jvnet.hudson.plugins 61 | tasks 62 | 4.46 63 | true 64 | 65 | 66 | org.jvnet.hudson.plugins 67 | warnings 68 | 4.49 69 | true 70 | 71 | 72 | org.jvnet.hudson.plugins 73 | android-lint 74 | 2.4 75 | true 76 | 77 | 78 | 79 | 80 | 81 | 82 | org.apache.maven.plugins 83 | maven-enforcer-plugin 84 | 85 | 86 | 87 | 88 | jaxen:jaxen 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | scm:git:git://github.com/jenkinsci/${project.artifactId}-plugin.git 99 | scm:git:git@github.com:jenkinsci/${project.artifactId}-plugin.git 100 | https://github.com/jenkinsci/${project.artifactId}-plugin 101 | HEAD 102 | 103 | 104 | 105 | 106 | repo.jenkins-ci.org 107 | https://repo.jenkins-ci.org/public/ 108 | 109 | 110 | 111 | 112 | 113 | repo.jenkins-ci.org 114 | https://repo.jenkins-ci.org/public/ 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /src/test/java/hudson/plugins/analysis/collector/AnalysisGraphConfigurationTest.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import org.junit.Test; 4 | 5 | import com.google.common.collect.Sets; 6 | 7 | import net.sf.json.JSONObject; 8 | import static org.junit.Assert.*; 9 | 10 | import hudson.plugins.analysis.graph.EmptyGraph; 11 | import hudson.plugins.analysis.graph.GraphConfiguration; 12 | import hudson.plugins.analysis.graph.PriorityGraph; 13 | 14 | /** 15 | * Tests the class {@link AnalysisGraphConfiguration}. 16 | * 17 | * @author Ulli Hafner 18 | */ 19 | public class AnalysisGraphConfigurationTest { 20 | /** Error message. */ 21 | private static final String WRONG_VALUE_OF_DEACTIVATE_PROPERTY = "Wrong value of deactivate property"; 22 | /** Error message. */ 23 | private static final String VALID_CONFIGURATION_REJECTED = "Valid configuration rejected"; 24 | 25 | /** 26 | * Asserts that the provided initialization value is correctly rejected and 27 | * the configuration is initialized by default values. 28 | * 29 | * @param initializationValue 30 | * initialization value 31 | */ 32 | private void assertInvalidInitializationValue(final String initializationValue) { 33 | GraphConfiguration configuration = createConfigurationUnderTest(); 34 | 35 | assertFalse("Invalid configuration accepted.", configuration.initializeFrom(initializationValue)); 36 | assertTrue("Invalid configuration state.", configuration.isDefault()); 37 | } 38 | 39 | /** 40 | * Creates the configuration under test. 41 | * 42 | * @return the configuration under test 43 | */ 44 | private AnalysisGraphConfiguration createConfigurationUnderTest() { 45 | return new AnalysisGraphConfiguration(Sets.newHashSet(new PriorityGraph(), new OriginGraph(), new EmptyGraph())); 46 | } 47 | 48 | /** 49 | * Ensures that invalid string values are rejected. 50 | */ 51 | @Test 52 | public void testInvalidConfiguations() { 53 | assertInvalidInitializationValue("50!50!12!13!PRIORITY"); 54 | assertInvalidInitializationValue("50!50!12!13!ORIGIN"); 55 | assertInvalidInitializationValue("50!50!12!13!ORIGIN!2"); 56 | assertInvalidInitializationValue("50!50!12!13!ORIGIN!q"); 57 | } 58 | 59 | /** 60 | * Ensures that a valid configuration is correctly parsed. 61 | */ 62 | @Test 63 | public void testValidConfiguations() { 64 | AnalysisGraphConfiguration configuration = createConfigurationUnderTest(); 65 | 66 | assertTrue(VALID_CONFIGURATION_REJECTED, configuration.initializeFrom("50!50!12!13!ORIGIN!1!!!0")); 67 | assertFalse(WRONG_VALUE_OF_DEACTIVATE_PROPERTY, configuration.canDeacticateOtherTrendGraphs()); 68 | 69 | AnalysisGraphConfiguration other = createConfigurationUnderTest(); 70 | assertTrue(VALID_CONFIGURATION_REJECTED, other.initializeFrom(configuration.serializeToString())); 71 | assertEquals("Wrong serialization", configuration, other); 72 | 73 | assertTrue(VALID_CONFIGURATION_REJECTED, configuration.initializeFrom("50!50!12!13!ORIGIN!1!!!1")); 74 | assertTrue(WRONG_VALUE_OF_DEACTIVATE_PROPERTY, configuration.canDeacticateOtherTrendGraphs()); 75 | } 76 | 77 | /** 78 | * Ensures that a valid JSON configuration is correctly parsed. 79 | */ 80 | @Test 81 | public void testValidJSONConfiguations() { 82 | JSONObject jsonObject = JSONObject.fromObject("{\"\":\"\",\"buildCountString\":\"\",\"useBuildDateAsDomain\":true,\"canDeacticateOtherTrendGraphs\":true,\"dayCountString\":\"\",\"graphType\":\"ORIGIN\",\"height\":\"200\",\"width\":\"500\"}"); 83 | 84 | AnalysisGraphConfiguration configuration = createConfigurationUnderTest(); 85 | 86 | assertTrue(VALID_CONFIGURATION_REJECTED, configuration.initializeFrom(jsonObject)); 87 | assertTrue(WRONG_VALUE_OF_DEACTIVATE_PROPERTY, configuration.canDeacticateOtherTrendGraphs()); 88 | 89 | jsonObject = JSONObject.fromObject("{\"\":\"\",\"buildCountString\":\"\",\"useBuildDateAsDomain\":true,\"canDeacticateOtherTrendGraphs\":false,\"dayCountString\":\"\",\"graphType\":\"ORIGIN\",\"height\":\"200\",\"width\":\"500\"}"); 90 | 91 | assertTrue(VALID_CONFIGURATION_REJECTED, configuration.initializeFrom(jsonObject)); 92 | assertFalse(WRONG_VALUE_OF_DEACTIVATE_PROPERTY, configuration.canDeacticateOtherTrendGraphs()); 93 | } 94 | } 95 | 96 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/AnalysisResult.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; // NOPMD 2 | 3 | import java.io.IOException; 4 | import java.util.Map; 5 | 6 | import com.google.common.collect.Maps; 7 | 8 | import hudson.model.AbstractBuild; 9 | import hudson.model.Run; 10 | 11 | import hudson.plugins.analysis.core.BuildHistory; 12 | import hudson.plugins.analysis.core.BuildResult; 13 | import hudson.plugins.analysis.core.ParserResult; 14 | import hudson.plugins.analysis.core.ResultAction; 15 | import hudson.plugins.analysis.util.model.FileAnnotation; 16 | 17 | /** 18 | * Stores the results of the analysis plug-ins. One instance of this class is 19 | * persisted for each build via an XML file. 20 | * 21 | * @author Ulli Hafner 22 | */ 23 | public class AnalysisResult extends BuildResult { 24 | /** Unique identifier of this class. */ 25 | private static final long serialVersionUID = 847650789493429154L; 26 | 27 | /** Number of annotations by origin mapping. Serialized @since 1.20. */ 28 | private Map annotationsByOrigin; 29 | 30 | private transient Object mappingLock = new Object(); 31 | 32 | /** 33 | * Creates a new instance of {@link AnalysisResult}. 34 | * 35 | * @param build 36 | * the current build as owner of this action 37 | * @param defaultEncoding 38 | * the default encoding to be used when reading and parsing files 39 | * @param result 40 | * the parsed result with all annotations 41 | * @param usePreviousBuildAsReference 42 | * determines whether the previous build should be used as the 43 | * reference build 44 | * @param useStableBuildAsReference 45 | * determines whether only stable builds should be used as 46 | * reference builds or not 47 | */ 48 | public AnalysisResult(final Run build, final String defaultEncoding, final ParserResult result, 49 | final boolean usePreviousBuildAsReference, final boolean useStableBuildAsReference) { 50 | this(build, new BuildHistory(build, AnalysisResultAction.class, usePreviousBuildAsReference, useStableBuildAsReference), 51 | result, defaultEncoding, true); 52 | } 53 | 54 | AnalysisResult(final Run build, final BuildHistory history, 55 | final ParserResult result, final String defaultEncoding, final boolean canSerialize) { 56 | super(build, history, result, defaultEncoding); 57 | 58 | annotationsByOrigin = countAnnotations(); 59 | if (canSerialize) { 60 | serializeAnnotations(result.getAnnotations()); 61 | } 62 | } 63 | 64 | @Override 65 | public String getHeader() { 66 | return Messages.Analysis_ResultAction_Header(); 67 | } 68 | 69 | @Override 70 | protected Object readResolve() { 71 | super.readResolve(); 72 | 73 | mappingLock = new Object(); 74 | 75 | return this; 76 | } 77 | 78 | /** 79 | * Count the annotations by origin. 80 | * 81 | * @return the mapping 82 | */ 83 | private Map countAnnotations() { 84 | Map mapping = Maps.newHashMap(); 85 | for (FileAnnotation annotation : getAnnotations()) { 86 | if (!mapping.containsKey(annotation.getOrigin())) { 87 | mapping.put(annotation.getOrigin(), 0); 88 | } 89 | mapping.put(annotation.getOrigin(), 90 | mapping.get(annotation.getOrigin()) + 1); 91 | } 92 | return mapping; 93 | } 94 | 95 | @Override 96 | public String getSummary() { 97 | return Messages.Analysis_ProjectAction_Name() + ": " 98 | + createDefaultSummary(AnalysisDescriptor.RESULT_URL, getNumberOfAnnotations(), getNumberOfModules()); 99 | } 100 | 101 | @Override 102 | protected String createDeltaMessage() { 103 | return createDefaultDeltaMessage(AnalysisDescriptor.RESULT_URL, getNumberOfNewWarnings(), getNumberOfFixedWarnings()); 104 | } 105 | 106 | @Override 107 | protected String getSerializationFileName() { 108 | return "analysis.xml"; 109 | } 110 | 111 | @Override 112 | public String getDisplayName() { 113 | return Messages.Analysis_ProjectAction_Name(); 114 | } 115 | 116 | @Override 117 | protected Class> getResultActionType() { 118 | return AnalysisResultAction.class; 119 | } 120 | 121 | /** 122 | * Returns the number of annotations from the specified origin. If there are 123 | * no annotations, then 0 is returned. 124 | * 125 | * @param origin 126 | * the origin 127 | * @return the number of annotations from the specified origin 128 | */ 129 | public int getNumberOfAnnotationsByOrigin(final String origin) { 130 | synchronized (mappingLock) { 131 | if (annotationsByOrigin == null) { 132 | annotationsByOrigin = countAnnotations(); 133 | try { 134 | getOwner().save(); 135 | } 136 | catch (IOException exception) { 137 | // ignore 138 | } 139 | } 140 | } 141 | if (annotationsByOrigin.containsKey(origin)) { 142 | return annotationsByOrigin.get(origin); 143 | } 144 | return 0; 145 | } 146 | } -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/AnalysisDescriptor.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import java.util.Collection; 4 | import java.util.HashSet; 5 | 6 | import com.google.common.collect.Sets; 7 | 8 | import hudson.Extension; 9 | import hudson.model.AbstractProject; 10 | import hudson.plugins.analysis.core.PluginDescriptor; 11 | 12 | /** 13 | * Descriptor for the class {@link AnalysisPublisher}. Used as a singleton. The 14 | * class is marked as public so that it can be accessed from views. 15 | * 16 | * @author Ulli Hafner 17 | */ 18 | @Extension(ordinal = 1) 19 | public final class AnalysisDescriptor extends PluginDescriptor { 20 | private static final String ICONS_PREFIX = "/plugin/analysis-collector/icons/"; 21 | /** The ID of this plug-in is used as URL. */ 22 | static final String PLUGIN_ID = "analysis"; 23 | /** The URL of the result action. */ 24 | static final String RESULT_URL = PluginDescriptor.createResultUrlName(PLUGIN_ID); 25 | /** Icon to use for the result and project action. */ 26 | static final String ICON_URL = ICONS_PREFIX + "analysis-24x24.png"; 27 | 28 | public static final String CHECKSTYLE = "checkstyle"; 29 | public static final String DRY = "dry"; 30 | public static final String FINDBUGS = "findbugs"; 31 | public static final String PMD = "pmd"; 32 | public static final String TASKS = "tasks"; 33 | public static final String WARNINGS = "warnings"; 34 | public static final String ANDROID_LINT = "android-lint"; 35 | 36 | /** 37 | * Returns the activated plug-ins. 38 | * 39 | * @return the activated plug-ins 40 | */ 41 | public static Collection getPlugins() { 42 | HashSet plugins = Sets.newHashSet(); 43 | 44 | if (isCheckStyleInstalled()) { 45 | plugins.add(CHECKSTYLE); 46 | } 47 | if (isDryInstalled()) { 48 | plugins.add(DRY); 49 | } 50 | if (isFindBugsInstalled()) { 51 | plugins.add(FINDBUGS); 52 | } 53 | if (isPmdInstalled()) { 54 | plugins.add(PMD); 55 | } 56 | if (isOpenTasksInstalled()) { 57 | plugins.add(TASKS); 58 | } 59 | if (isWarningsInstalled()) { 60 | plugins.add(WARNINGS); 61 | } 62 | if (isAndroidLintInstalled()) { 63 | plugins.add(ANDROID_LINT); 64 | } 65 | return plugins; 66 | } 67 | 68 | /** 69 | * Returns whether the Checkstyle plug-in is installed. 70 | * 71 | * @return 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 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 List originsKeys = Lists.newArrayList(); 29 | private final List originLabels = Lists.newArrayList(); 30 | private static final Color ORANGE = new Color(0xFF, 0xA5, 0x00); 31 | private static final Color GRAY = new Color(0x4D, 0x4D, 0x4D); 32 | private static final Color PINK = new Color(0xA0, 0x20, 0xF0); 33 | 34 | /** 35 | * Creates a new instance of {@link OriginGraph}. 36 | */ 37 | public OriginGraph() { 38 | this(AnalysisDescriptor.isCheckStyleInstalled(), AnalysisDescriptor.isDryInstalled(), 39 | AnalysisDescriptor.isFindBugsInstalled(), AnalysisDescriptor.isPmdInstalled(), 40 | AnalysisDescriptor.isOpenTasksInstalled(), AnalysisDescriptor.isWarningsInstalled(), 41 | AnalysisDescriptor.isAndroidLintInstalled()); 42 | } 43 | 44 | /** 45 | * Creates a new instance of {@link OriginGraph}. 46 | * 47 | * @param isCheckStyleActivated 48 | * determines whether to show the warnings from Checkstyle 49 | * @param isDryActivated 50 | * determines whether to show the warnings from DRY 51 | * @param isFindBugsActivated 52 | * determines whether to show the warnings from FindBugs 53 | * @param isPmdActivated 54 | * determines whether to show the warnings from PMD 55 | * @param isOpenTasksActivated 56 | * determines whether to show open tasks 57 | * @param isWarningsActivated 58 | * determines whether to show compiler warnings 59 | */ 60 | public OriginGraph(final boolean isCheckStyleActivated, final boolean isDryActivated, 61 | final boolean isFindBugsActivated, final boolean isPmdActivated, 62 | final boolean isOpenTasksActivated, final boolean isWarningsActivated, 63 | final boolean isAndroidLintActivated) { 64 | super(); 65 | 66 | if (isCheckStyleActivated) { 67 | originsKeys.add(hudson.plugins.checkstyle.parser.Warning.ORIGIN); 68 | originLabels.add(Messages.Analysis_Checkstyle_Warning_Origin()); 69 | } 70 | if (isDryActivated) { 71 | originsKeys.add(hudson.plugins.dry.parser.DuplicateCode.ORIGIN); 72 | originLabels.add(Messages.Analysis_Dry_Warning_Origin()); 73 | } 74 | if (isFindBugsActivated) { 75 | originsKeys.add(hudson.plugins.findbugs.parser.Bug.ORIGIN); 76 | originLabels.add(Messages.Analysis_FindBugs_Warning_Origin()); 77 | } 78 | if (isPmdActivated) { 79 | originsKeys.add(hudson.plugins.pmd.parser.Bug.ORIGIN); 80 | originLabels.add(Messages.Analysis_PMD_Warning_Origin()); 81 | } 82 | if (isOpenTasksActivated) { 83 | originsKeys.add(hudson.plugins.tasks.parser.Task.ORIGIN); 84 | originLabels.add(Messages.Analysis_Tasks_Warning_Origin()); 85 | } 86 | if (isWarningsActivated) { 87 | originsKeys.add(hudson.plugins.warnings.parser.Warning.ORIGIN); 88 | originLabels.add(Messages.Analysis_Warnings_Warning_Origin()); 89 | } 90 | if (isAndroidLintActivated) { 91 | originsKeys.add("android-lint"); // org.jenkinsci.plugins.android_lint.parser.LintAnnotation.ORIGIN is private 92 | originLabels.add(Messages.Analysis_AndroidLint_Warning_Origin()); 93 | } 94 | } 95 | 96 | @Override 97 | public String getId() { 98 | return "ORIGIN"; 99 | } 100 | 101 | /** 102 | * Returns the plug-in that owns this graph and provides an example image. 103 | * 104 | * @return the plug-in that owns this graph and provides an example image 105 | */ 106 | @Override 107 | protected String getPlugin() { 108 | return "analysis-collector"; 109 | } 110 | 111 | @Override 112 | public String getLabel() { 113 | return Messages.Trend_type_analysis(); 114 | } 115 | 116 | @Override 117 | protected List computeSeries(final BuildResult current) { 118 | List series = new ArrayList(); 119 | if (current instanceof AnalysisResult) { 120 | AnalysisResult result = (AnalysisResult)current; 121 | for (String origin : originsKeys) { 122 | series.add(result.getNumberOfAnnotationsByOrigin(origin)); 123 | } 124 | } 125 | return series; 126 | } 127 | 128 | @Override 129 | protected JFreeChart createChart(final CategoryDataset dataSet) { 130 | return createLineGraph(dataSet, true); 131 | } 132 | 133 | @Override 134 | protected Color[] getColors() { 135 | List colors = Lists.newArrayList(ColorPalette.LINE_GRAPH); 136 | while (colors.size() > HUDSON_GREEN_INDEX) { 137 | colors.remove(HUDSON_GREEN_INDEX); 138 | } 139 | colors.add(ORANGE); 140 | colors.add(GRAY); 141 | colors.add(PINK); 142 | colors.add(ColorPalette.RED); 143 | colors.add(ColorPalette.YELLOW); 144 | return colors.toArray(new Color[colors.size()]); 145 | } 146 | 147 | @Override 148 | protected String getRowId(final int level) { 149 | return originLabels.get(level); 150 | } 151 | 152 | @Override 153 | protected CategoryItemRenderer createRenderer(final GraphConfiguration configuration, final String pluginName, final ToolTipProvider toolTipProvider) { 154 | return createLineRenderer(); 155 | } 156 | } 157 | 158 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/AnalysisProjectAction.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import java.util.List; 4 | 5 | import org.kohsuke.stapler.StaplerRequest; 6 | 7 | import hudson.model.Job; 8 | import hudson.plugins.analysis.core.AbstractProjectAction; 9 | import hudson.plugins.analysis.graph.BuildResultGraph; 10 | import hudson.plugins.analysis.graph.GraphConfigurationView; 11 | 12 | /** 13 | * Entry point to visualize the trend graph in the project screen. Drawing of the graph is delegated to the associated 14 | * {@link AnalysisResultAction}. 15 | * 16 | * @author Ulli Hafner 17 | */ 18 | public class AnalysisProjectAction extends AbstractProjectAction { 19 | private transient WarningsAggregator warningsAggregator; 20 | 21 | /** 22 | * Instantiates a new {@link AnalysisProjectAction}. 23 | * 24 | * @param job 25 | * the job that owns this action 26 | */ 27 | public AnalysisProjectAction(final Job job) { 28 | this(job, AnalysisResultAction.class); 29 | } 30 | 31 | /** 32 | * Instantiates a new {@link AnalysisProjectAction}. 33 | * 34 | * @param job 35 | * the job that owns this action 36 | * @param type 37 | * the result action type 38 | */ 39 | public AnalysisProjectAction(final Job job, final Class type) { 40 | super(job, type, Messages._Analysis_ProjectAction_Name(), Messages._Analysis_Trend_Name(), 41 | AnalysisDescriptor.PLUGIN_ID, AnalysisDescriptor.ICON_URL, AnalysisDescriptor.RESULT_URL); 42 | 43 | createAggregator(); 44 | } 45 | 46 | private void createAggregator() { 47 | warningsAggregator = new WarningsAggregator( 48 | AnalysisDescriptor.isCheckStyleInstalled(), 49 | AnalysisDescriptor.isDryInstalled(), 50 | AnalysisDescriptor.isFindBugsInstalled(), 51 | AnalysisDescriptor.isPmdInstalled(), 52 | AnalysisDescriptor.isOpenTasksInstalled(), 53 | AnalysisDescriptor.isWarningsInstalled(), 54 | AnalysisDescriptor.isAndroidLintInstalled()); 55 | warningsAggregator.hideJobPrefix(); 56 | } 57 | 58 | /** 59 | * Restores the transient fields. 60 | * 61 | * @return this 62 | */ 63 | protected Object readResolve() { 64 | createAggregator(); 65 | 66 | return this; 67 | } 68 | 69 | @Override 70 | protected GraphConfigurationView createDefaultConfiguration() { 71 | return new AnalysisDefaultGraphConfigurationView(createConfiguration(), getOwner(), getUrlName(), 72 | createBuildHistory()); 73 | } 74 | 75 | @Override 76 | protected GraphConfigurationView createUserConfiguration(final StaplerRequest request) { 77 | return new AnalysisUserGraphConfigurationView(createConfiguration(), getOwner(), getUrlName(), 78 | request.getCookies(), createBuildHistory()); 79 | } 80 | 81 | /** 82 | * Creates the graph configuration. 83 | * 84 | * @return the graph configuration 85 | */ 86 | protected AnalysisGraphConfiguration createConfiguration() { 87 | List availableGraphs = getAvailableGraphs(); 88 | availableGraphs.add(0, new OriginGraph()); 89 | 90 | return new AnalysisGraphConfiguration(availableGraphs); 91 | } 92 | 93 | /** 94 | * Returns whether CheckStyle results should be shown. 95 | * 96 | * @return true 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 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 70 | 71 | 74 | 75 | 76 | 79 | 80 | 81 | 84 | 85 | 86 | 89 | 90 | 91 | 94 | 95 | 96 | 99 | 100 | 101 | 104 | 105 | 106 | 115 | 116 | 117 | 118 | 119 | 122 | 123 | 126 | 127 | 128 | 131 | 132 | 133 | 136 | 137 | 138 | 141 | 142 | 143 | 146 | 147 | 148 | 151 | 152 | 153 | 156 | 157 | 158 | 161 | 162 | 163 | 164 |
${%Job}Checkstyle${%Duplicate Code}FindBugsPMD${%Open Tasks}${%Compiler Warnings}${%Android Lint}Checkstyle${%Duplicate Code}FindBugsPMD${%Open Tasks}${%Compiler Warnings}${%Android Lint}${%Total}
68 | 69 | 72 | 73 | 77 | 78 | 82 | 83 | 87 | 88 | 92 | 93 | 97 | 98 | 102 | 103 | 107 | 108 | 109 | ${total} 110 | 111 | 112 | ${total} 113 | 114 |
120 | ${%Total} 121 | 124 | ${it.getCheckStyle(jobs)} 125 | 129 | ${it.getDry(jobs)} 130 | 134 | ${it.getFindBugs(jobs)} 135 | 139 | ${it.getPmd(jobs)} 140 | 144 | ${it.getTasks(jobs)} 145 | 149 | ${it.getWarnings(jobs)} 150 | 154 | ${it.getAndroidLint(jobs)} 155 | 159 | ${it.getTotal(jobs)} 160 |
165 | 166 | 167 |
168 |
169 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/dashboard/WarningsOriginGraphPortlet.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector.dashboard; 2 | 3 | import hudson.Extension; 4 | import hudson.model.Descriptor; 5 | import hudson.plugins.analysis.collector.AnalysisDescriptor; 6 | import hudson.plugins.analysis.collector.AnalysisProjectAction; 7 | import hudson.plugins.analysis.collector.Messages; 8 | import hudson.plugins.analysis.collector.OriginGraph; 9 | import hudson.plugins.analysis.core.AbstractProjectAction; 10 | import hudson.plugins.analysis.dashboard.AbstractWarningsGraphPortlet; 11 | import hudson.plugins.analysis.graph.BuildResultGraph; 12 | import hudson.plugins.view.dashboard.DashboardPortlet; 13 | 14 | import org.kohsuke.stapler.DataBoundConstructor; 15 | 16 | /** 17 | * A portlet that shows the warnings trend graph of warnings by type. 18 | * 19 | * @author Ulli Hafner 20 | */ 21 | public final class WarningsOriginGraphPortlet extends AbstractWarningsGraphPortlet { 22 | private final boolean isCheckStyleDeactivated; 23 | private final boolean isDryDeactivated; 24 | private final boolean isFindBugsDeactivated; 25 | private final boolean isPmdDeactivated; 26 | private final boolean isOpenTasksDeactivated; 27 | private final boolean isWarningsDeactivated; 28 | private final boolean isAndroidLintDeactivated; 29 | 30 | /** 31 | * Creates a new instance of {@link WarningsOriginGraphPortlet}. 32 | * 33 | * @param name 34 | * the name of the portlet 35 | * @param width 36 | * width of the graph 37 | * @param height 38 | * height of the graph 39 | * @param dayCountString 40 | * number of days to consider 41 | * @param checkStyleActivated 42 | * determines whether to show the warnings from Checkstyle 43 | * @param dryActivated 44 | * determines whether to show the warnings from DRY 45 | * @param findBugsActivated 46 | * determines whether to show the warnings from FindBugs 47 | * @param pmdActivated 48 | * determines whether to show the warnings from PMD 49 | * @param openTasksActivated 50 | * determines whether to show open tasks 51 | * @param warningsActivated 52 | * determines whether to show compiler warnings 53 | */ 54 | // CHECKSTYLE:OFF 55 | @DataBoundConstructor @SuppressWarnings("PMD.ExcessiveParameterList") 56 | public WarningsOriginGraphPortlet(final String name, final String width, final String height, final String dayCountString, 57 | final boolean checkStyleActivated, final boolean dryActivated, 58 | final boolean findBugsActivated, final boolean pmdActivated, 59 | final boolean openTasksActivated, final boolean warningsActivated, final boolean androidLintActivated) { 60 | super(name, width, height, dayCountString); 61 | 62 | isDryDeactivated = !dryActivated; 63 | isFindBugsDeactivated = !findBugsActivated; 64 | isPmdDeactivated = !pmdActivated; 65 | isOpenTasksDeactivated = !openTasksActivated; 66 | isWarningsDeactivated = !warningsActivated; 67 | isCheckStyleDeactivated = !checkStyleActivated; 68 | isAndroidLintDeactivated = !androidLintActivated; 69 | 70 | configureGraph(getGraphType()); 71 | } 72 | // CHECKSTYLE:ON 73 | 74 | /** 75 | * Returns whether CheckStyle results should be collected. 76 | * 77 | * @return 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> 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 Descriptor { 157 | /** 158 | * Returns whether the Checkstyle plug-in is installed. 159 | * 160 | * @return true 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 List>> getParticipatingPlugins() { 186 | ArrayList>> pluginResults; 187 | pluginResults = new ArrayList>>(); 188 | 189 | if (AnalysisDescriptor.isCheckStyleInstalled() && isCheckStyleActivated()) { 190 | pluginResults.addAll(new CheckStyleHandler().getResultActions()); 191 | } 192 | if (AnalysisDescriptor.isDryInstalled() && isDryActivated()) { 193 | pluginResults.addAll(new DryHandler().getResultActions()); 194 | } 195 | if (AnalysisDescriptor.isFindBugsInstalled() && isFindBugsActivated()) { 196 | pluginResults.addAll(new FindBugsHandler().getResultActions()); 197 | } 198 | if (AnalysisDescriptor.isPmdInstalled() && isPmdActivated()) { 199 | pluginResults.addAll(new PmdHandler().getResultActions()); 200 | } 201 | if (AnalysisDescriptor.isOpenTasksInstalled() && isOpenTasksActivated()) { 202 | pluginResults.addAll(new TasksHandler().getResultActions()); 203 | } 204 | if (AnalysisDescriptor.isWarningsInstalled() && isWarningsActivated()) { 205 | pluginResults.addAll(new WarningsHandler().getResultActions()); 206 | } 207 | if (AnalysisDescriptor.isAndroidLintInstalled() && isAndroidLintActivated()) { 208 | pluginResults.addAll(new AndroidLintHandler().getResultActions()); 209 | } 210 | 211 | return pluginResults; 212 | } 213 | 214 | @Override 215 | public BuildResult perform(final Run build, final FilePath workspace, final PluginLogger logger) throws InterruptedException, IOException { 216 | ParserResult overallResult = new ParserResult(workspace); 217 | for (Class> result : getParticipatingPlugins()) { 218 | ResultAction action = build.getAction(result); 219 | if (action != null) { 220 | BuildResult actualResult = action.getResult(); 221 | Collection annotations = actualResult.getAnnotations(); 222 | overallResult.addAnnotations(annotations); 223 | } 224 | } 225 | 226 | AnalysisResult result = new AnalysisResult(build, getDefaultEncoding(), overallResult, 227 | usePreviousBuildAsReference(), useOnlyStableBuildsAsReference()); 228 | build.addAction(new AnalysisResultAction(build, this, result)); 229 | 230 | return result; 231 | } 232 | 233 | @Override 234 | public AnalysisDescriptor getDescriptor() { 235 | return (AnalysisDescriptor)super.getDescriptor(); 236 | } 237 | 238 | @Override 239 | public MatrixAggregator createAggregator(final MatrixBuild build, final Launcher launcher, 240 | final BuildListener listener) { 241 | return new AnalysisAnnotationsAggregator(build, launcher, listener, this, getDefaultEncoding(), 242 | usePreviousBuildAsReference(), useOnlyStableBuildsAsReference()); 243 | } 244 | } 245 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/WarningsCountColumn.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import org.jvnet.localizer.Localizable; 4 | import org.kohsuke.stapler.DataBoundConstructor; 5 | 6 | import jenkins.model.Jenkins; 7 | 8 | import hudson.Extension; 9 | import hudson.model.Job; 10 | import hudson.plugins.analysis.collector.handler.AnalysisHandler; 11 | import hudson.plugins.analysis.collector.handler.AndroidLintHandler; 12 | import hudson.plugins.analysis.collector.handler.CheckStyleHandler; 13 | import hudson.plugins.analysis.collector.handler.DryHandler; 14 | import hudson.plugins.analysis.collector.handler.FindBugsHandler; 15 | import hudson.plugins.analysis.collector.handler.PmdHandler; 16 | import hudson.plugins.analysis.collector.handler.TasksHandler; 17 | import hudson.plugins.analysis.collector.handler.WarningsHandler; 18 | import hudson.plugins.analysis.core.PluginDescriptor; 19 | import hudson.plugins.analysis.util.HtmlPrinter; 20 | import hudson.views.ListViewColumnDescriptor; 21 | 22 | /** 23 | * A column that shows the total number of warnings in a job. 24 | * 25 | * @author Ulli Hafner 26 | */ 27 | public class WarningsCountColumn extends hudson.plugins.analysis.views.WarningsCountColumn { 28 | private final WarningsAggregator warningsAggregator; 29 | 30 | /** 31 | * Creates a new instance of {@link WarningsCountColumn}. 32 | * 33 | * @param checkStyleActivated 34 | * determines whether to show the warnings from Checkstyle 35 | * @param dryActivated 36 | * determines whether to show the warnings from DRY 37 | * @param findBugsActivated 38 | * determines whether to show the warnings from FindBugs 39 | * @param pmdActivated 40 | * determines whether to show the warnings from PMD 41 | * @param openTasksActivated 42 | * determines whether to show open tasks 43 | * @param warningsActivated 44 | * determines whether to show compiler warnings 45 | */ 46 | @DataBoundConstructor 47 | public WarningsCountColumn(final boolean checkStyleActivated, 48 | final boolean dryActivated, final boolean findBugsActivated, final boolean pmdActivated, 49 | final boolean openTasksActivated, final boolean warningsActivated, final boolean androidLintActivated) { 50 | super(); 51 | 52 | warningsAggregator = new WarningsAggregator(checkStyleActivated, dryActivated, 53 | findBugsActivated, pmdActivated, openTasksActivated, warningsActivated, androidLintActivated); 54 | } 55 | 56 | /** 57 | * Returns whether CheckStyle results should be shown. 58 | * 59 | * @return true 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 Class getProjectAction() { 132 | return AnalysisProjectAction.class; 133 | } 134 | 135 | /** 136 | * Returns the number of warnings for the specified job separated by each plug-in. 137 | * 138 | * @param job 139 | * the job to get the warnings for 140 | * @return the number of warnings, formatted as HTML string 141 | */ 142 | public String getDetails(final Job job) { 143 | HtmlPrinter printer = new HtmlPrinter(); 144 | printer.append(""); 145 | if (isCheckStyleActivated()) { 146 | printLine(printer, new CheckStyleHandler(), warningsAggregator.getCheckStyle(job)); 147 | } 148 | if (isDryActivated()) { 149 | printLine(printer, new DryHandler(), warningsAggregator.getDry(job)); 150 | } 151 | if (isFindBugsActivated()) { 152 | printLine(printer, new FindBugsHandler(), warningsAggregator.getFindBugs(job)); 153 | } 154 | if (isPmdActivated()) { 155 | printLine(printer, new PmdHandler(), warningsAggregator.getPmd(job)); 156 | } 157 | if (isOpenTasksActivated()) { 158 | printLine(printer, new TasksHandler(), warningsAggregator.getTasks(job)); 159 | } 160 | if (isWarningsActivated()) { 161 | printLine(printer, new WarningsHandler(), warningsAggregator.getCompilerWarnings(job)); 162 | } 163 | if (isAndroidLintActivated()) { 164 | printLine(printer, new AndroidLintHandler(), warningsAggregator.getAndroidLint(job)); 165 | } 166 | printer.append("
"); 167 | return printer.toString(); 168 | } 169 | 170 | private void printLine(final HtmlPrinter printer, final AnalysisHandler handler, final String warnings) { 171 | printLine(printer, handler.getDetailHeader(), warnings, handler.getDescriptor()); 172 | } 173 | 174 | private void printLine(final HtmlPrinter printer, final Localizable header, final String warnings, 175 | final Class descriptor) { 176 | PluginDescriptor pluginDescriptor = Jenkins.getInstance().getDescriptorByType(descriptor); 177 | String image = ""; 179 | printer.append(printer.line(image + header + ": " + warnings)); 180 | } 181 | 182 | /** 183 | * Descriptor for the column. 184 | */ 185 | @Extension 186 | public static class ColumnDescriptor extends ListViewColumnDescriptor { 187 | @Override 188 | public boolean shownByDefault() { 189 | return false; 190 | } 191 | 192 | /** 193 | * Returns whether the Checkstyle plug-in is installed. 194 | * 195 | * @return true 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= 72 | sp_cleanup.add_default_serial_version_id=true 73 | sp_cleanup.add_generated_serial_version_id=false 74 | sp_cleanup.add_missing_annotations=true 75 | sp_cleanup.add_missing_deprecated_annotations=true 76 | sp_cleanup.add_missing_methods=false 77 | sp_cleanup.add_missing_nls_tags=false 78 | sp_cleanup.add_missing_override_annotations=true 79 | sp_cleanup.add_missing_override_annotations_interface_methods=false 80 | sp_cleanup.add_serial_version_id=false 81 | sp_cleanup.always_use_blocks=true 82 | sp_cleanup.always_use_parentheses_in_expressions=false 83 | sp_cleanup.always_use_this_for_non_static_field_access=false 84 | sp_cleanup.always_use_this_for_non_static_method_access=false 85 | sp_cleanup.convert_to_enhanced_for_loop=false 86 | sp_cleanup.correct_indentation=false 87 | sp_cleanup.format_source_code=false 88 | sp_cleanup.format_source_code_changes_only=false 89 | sp_cleanup.make_local_variable_final=false 90 | sp_cleanup.make_parameters_final=true 91 | sp_cleanup.make_private_fields_final=true 92 | sp_cleanup.make_type_abstract_if_missing_method=false 93 | sp_cleanup.make_variable_declarations_final=true 94 | sp_cleanup.never_use_blocks=false 95 | sp_cleanup.never_use_parentheses_in_expressions=true 96 | sp_cleanup.on_save_use_additional_actions=true 97 | sp_cleanup.organize_imports=true 98 | sp_cleanup.qualify_static_field_accesses_with_declaring_class=false 99 | sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true 100 | sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true 101 | sp_cleanup.qualify_static_member_accesses_with_declaring_class=false 102 | sp_cleanup.qualify_static_method_accesses_with_declaring_class=false 103 | sp_cleanup.remove_private_constructors=true 104 | sp_cleanup.remove_trailing_whitespaces=true 105 | sp_cleanup.remove_trailing_whitespaces_all=true 106 | sp_cleanup.remove_trailing_whitespaces_ignore_empty=false 107 | sp_cleanup.remove_unnecessary_casts=true 108 | sp_cleanup.remove_unnecessary_nls_tags=false 109 | sp_cleanup.remove_unused_imports=true 110 | sp_cleanup.remove_unused_local_variables=false 111 | sp_cleanup.remove_unused_private_fields=true 112 | sp_cleanup.remove_unused_private_members=false 113 | sp_cleanup.remove_unused_private_methods=true 114 | sp_cleanup.remove_unused_private_types=true 115 | sp_cleanup.sort_members=false 116 | sp_cleanup.sort_members_all=false 117 | sp_cleanup.use_blocks=true 118 | sp_cleanup.use_blocks_only_for_return_and_throw=false 119 | sp_cleanup.use_parentheses_in_expressions=false 120 | sp_cleanup.use_this_for_non_static_field_access=true 121 | sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true 122 | sp_cleanup.use_this_for_non_static_method_access=true 123 | sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true 124 | -------------------------------------------------------------------------------- /src/main/java/hudson/plugins/analysis/collector/WarningsAggregator.java: -------------------------------------------------------------------------------- 1 | package hudson.plugins.analysis.collector; 2 | 3 | import org.apache.commons.lang.StringUtils; 4 | 5 | import hudson.model.Job; 6 | import hudson.plugins.analysis.collector.handler.AnalysisHandler; 7 | import hudson.plugins.analysis.collector.handler.AndroidLintHandler; 8 | import hudson.plugins.analysis.collector.handler.CheckStyleHandler; 9 | import hudson.plugins.analysis.collector.handler.DryHandler; 10 | import hudson.plugins.analysis.collector.handler.FindBugsHandler; 11 | import hudson.plugins.analysis.collector.handler.PmdHandler; 12 | import hudson.plugins.analysis.collector.handler.TasksHandler; 13 | import hudson.plugins.analysis.collector.handler.WarningsHandler; 14 | import hudson.plugins.analysis.core.AbstractProjectAction; 15 | import hudson.plugins.analysis.core.BuildResult; 16 | 17 | /** 18 | * Aggregates the warnings of the analysis plug-in from a single job. 19 | * 20 | * @author Ulli Hafner 21 | */ 22 | public class WarningsAggregator { 23 | /** Message to be shown if no result action is found. */ 24 | private static final String NO_RESULTS_FOUND = "-"; 25 | private static final String CLOSE_TAG = ">"; 26 | private static final String OPEN_TAG = "<"; 27 | 28 | private final boolean isCheckStyleActivated; 29 | private final boolean isDryActivated; 30 | private final boolean isFindBugsActivated; 31 | private final boolean isPmdActivated; 32 | private final boolean isOpenTasksActivated; 33 | private final boolean isWarningsActivated; 34 | private final boolean isAndroidLintActivated; 35 | private boolean hideJobPrefix; 36 | 37 | /** 38 | * Creates a new instance of {@link WarningsAggregator}. 39 | * 40 | * @param isCheckStyleActivated 41 | * determines whether to show the warnings from Checkstyle 42 | * @param isDryActivated 43 | * determines whether to show the warnings from DRY 44 | * @param isFindBugsActivated 45 | * determines whether to show the warnings from FindBugs 46 | * @param isPmdActivated 47 | * determines whether to show the warnings from PMD 48 | * @param isOpenTasksActivated 49 | * determines whether to show open tasks 50 | * @param isWarningsActivated 51 | * determines whether to show compiler warnings 52 | */ 53 | public WarningsAggregator(final boolean isCheckStyleActivated, 54 | final boolean isDryActivated, final boolean isFindBugsActivated, final boolean isPmdActivated, 55 | final boolean isOpenTasksActivated, final boolean isWarningsActivated, final boolean isAndroidLintActivated) { 56 | this.isCheckStyleActivated = isCheckStyleActivated; 57 | this.isDryActivated = isDryActivated; 58 | this.isFindBugsActivated = isFindBugsActivated; 59 | this.isPmdActivated = isPmdActivated; 60 | this.isOpenTasksActivated = isOpenTasksActivated; 61 | this.isWarningsActivated = isWarningsActivated; 62 | this.isAndroidLintActivated = isAndroidLintActivated; 63 | } 64 | 65 | private int toInt(final String value) { 66 | try { 67 | if (value.contains(OPEN_TAG)) { 68 | return Integer.parseInt(StringUtils.substringBetween(value, CLOSE_TAG, OPEN_TAG)); 69 | } 70 | else { 71 | return Integer.parseInt(value); 72 | } 73 | } 74 | catch (NumberFormatException exception) { 75 | return 0; 76 | } 77 | } 78 | 79 | /** 80 | * Returns whether CheckStyle results should be shown. 81 | * 82 | * @return 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> 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 Collection> jobs) { 301 | int sum = 0; 302 | for (Job job : jobs) { 303 | sum += toInt(warningsAggregator.getCheckStyle(job)); 304 | } 305 | return String.valueOf(sum); 306 | } 307 | 308 | /** 309 | * Returns the number of Dry warnings for the specified jobs. 310 | * 311 | * @param jobs 312 | * the jobs to get the warnings for 313 | * @return the number of Dry warnings 314 | */ 315 | public String getDry(final Collection> jobs) { 316 | int sum = 0; 317 | for (Job job : jobs) { 318 | sum += toInt(warningsAggregator.getDry(job)); 319 | } 320 | return String.valueOf(sum); 321 | } 322 | 323 | /** 324 | * Returns the number of FindBugs warnings for the specified jobs. 325 | * 326 | * @param jobs 327 | * the jobs to get the warnings for 328 | * @return the number of FindBugs warnings 329 | */ 330 | public String getFindBugs(final Collection> jobs) { 331 | int sum = 0; 332 | for (Job job : jobs) { 333 | sum += toInt(warningsAggregator.getFindBugs(job)); 334 | } 335 | return String.valueOf(sum); 336 | } 337 | 338 | /** 339 | * Returns the number of PMD warnings for the specified jobs. 340 | * 341 | * @param jobs 342 | * the jobs to get the warnings for 343 | * @return the number of PMD warnings 344 | */ 345 | public String getPmd(final Collection> jobs) { 346 | int sum = 0; 347 | for (Job job : jobs) { 348 | sum += toInt(warningsAggregator.getPmd(job)); 349 | } 350 | return String.valueOf(sum); 351 | } 352 | 353 | /** 354 | * Returns the number of open tasks for the specified jobs. 355 | * 356 | * @param jobs 357 | * the jobs to get the warnings for 358 | * @return the number of open tasks warnings 359 | */ 360 | public String getTasks(final Collection> jobs) { 361 | int sum = 0; 362 | for (Job job : jobs) { 363 | sum += toInt(warningsAggregator.getTasks(job)); 364 | } 365 | return String.valueOf(sum); 366 | } 367 | 368 | /** 369 | * Returns the number of compiler warnings for the specified jobs. 370 | * 371 | * @param jobs 372 | * the jobs to get the warnings for 373 | * @return the number of compiler warnings 374 | */ 375 | @Override 376 | public String getWarnings(final Collection> jobs) { 377 | int sum = 0; 378 | for (Job job : jobs) { 379 | sum += toInt(warningsAggregator.getCompilerWarnings(job)); 380 | } 381 | return String.valueOf(sum); 382 | } 383 | 384 | /** 385 | * Returns the number of Android lint warnings for the specified jobs. 386 | * 387 | * @param jobs 388 | * the jobs to get the warnings for 389 | * @return the number of Android lint warnings 390 | */ 391 | public String getAndroidLint(final Collection> jobs) { 392 | int sum = 0; 393 | for (Job job : jobs) { 394 | sum += toInt(warningsAggregator.getAndroidLint(job)); 395 | } 396 | return String.valueOf(sum); 397 | } 398 | 399 | /** 400 | * Returns the total number of warnings for all jobs. 401 | * 402 | * @param jobs 403 | * the jobs to get the warnings for 404 | * @return the total number of warnings 405 | */ 406 | public String getTotal(final Collection> jobs) { 407 | int sum = 0; 408 | for (Job job : jobs) { 409 | sum += Integer.parseInt(warningsAggregator.getTotal(job)); 410 | } 411 | return String.valueOf(sum); 412 | 413 | } 414 | 415 | /** 416 | * Returns the URL of the referenced project action for the selected job. 417 | * 418 | * @param project 419 | * the selected project 420 | * @return the URL of the project action 421 | */ 422 | public String getUrl(final Job project) { 423 | return project.getUrl() + new AnalysisProjectAction(project).getUrlName(); 424 | } 425 | 426 | /** Backward compatibility. @deprecated replaced by {@link WarningsAggregator} */ 427 | @Deprecated 428 | private transient boolean isCheckStyleDeactivated; 429 | /** Backward compatibility. @deprecated replaced by {@link WarningsAggregator} */ 430 | @Deprecated 431 | private transient boolean isDryDeactivated; 432 | /** Backward compatibility. @deprecated replaced by {@link WarningsAggregator} */ 433 | @Deprecated 434 | private transient boolean isFindBugsDeactivated; 435 | /** Backward compatibility. @deprecated replaced by {@link WarningsAggregator} */ 436 | @Deprecated 437 | private transient boolean isPmdDeactivated; 438 | /** Backward compatibility. @deprecated replaced by {@link WarningsAggregator} */ 439 | @Deprecated 440 | private transient boolean isOpenTasksDeactivated; 441 | /** Backward compatibility. @deprecated replaced by {@link WarningsAggregator} */ 442 | @Deprecated 443 | private transient boolean isWarningsDeactivated; 444 | @Deprecated 445 | private transient boolean isAndroidLintDeactivated; 446 | /** 447 | * Extension point registration. 448 | * 449 | * @author Ulli Hafner 450 | */ 451 | @Extension(optional = true) 452 | public static class WarningsPerJobDescriptor extends Descriptor { 453 | /** 454 | * Returns whether the Checkstyle plug-in is installed. 455 | * 456 | * @return true 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 | --------------------------------------------------------------------------------