Skip to content
Permalink
Browse files

first commit. forked clover-plugin.

  • Loading branch information...
ssogabe committed May 15, 2011
0 parents commit c768bb5f1239db297965f457700f4668081af634
Showing with 2,710 additions and 0 deletions.
  1. +8 −0 .gitignore
  2. +145 −0 pom.xml
  3. +162 −0 src/main/java/org/jenkinsci/plugins/cloverphp/CloverBuildAction.java
  4. +93 −0 src/main/java/org/jenkinsci/plugins/cloverphp/CloverCoverageParser.java
  5. +41 −0 src/main/java/org/jenkinsci/plugins/cloverphp/CloverHtmlBuildAction.java
  6. +130 −0 src/main/java/org/jenkinsci/plugins/cloverphp/CloverProjectAction.java
  7. +393 −0 src/main/java/org/jenkinsci/plugins/cloverphp/CloverPublisher.java
  8. +17 −0 src/main/java/org/jenkinsci/plugins/cloverphp/CoverageBarProvider.java
  9. +154 −0 src/main/java/org/jenkinsci/plugins/cloverphp/Ratio.java
  10. +44 −0 src/main/java/org/jenkinsci/plugins/cloverphp/results/AbstractClassAggregatedMetrics.java
  11. +321 −0 src/main/java/org/jenkinsci/plugins/cloverphp/results/AbstractCloverMetrics.java
  12. +20 −0 src/main/java/org/jenkinsci/plugins/cloverphp/results/AbstractFileAggregatedMetrics.java
  13. +42 −0 src/main/java/org/jenkinsci/plugins/cloverphp/results/ClassCoverage.java
  14. +66 −0 src/main/java/org/jenkinsci/plugins/cloverphp/results/FileCoverage.java
  15. +63 −0 src/main/java/org/jenkinsci/plugins/cloverphp/results/ProjectCoverage.java
  16. +25 −0 src/main/java/org/jenkinsci/plugins/cloverphp/targets/CoverageMetric.java
  17. +158 −0 src/main/java/org/jenkinsci/plugins/cloverphp/targets/CoverageTarget.java
  18. +3 −0 src/main/resources/index.jelly
  19. +14 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/CloverBuildAction/summary.jelly
  20. +2 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/CloverBuildAction/summary.properties
  21. +2 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/CloverBuildAction/summary_ja.properties
  22. +68 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/CloverProjectAction/floatingBox.jelly
  23. +2 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/CloverProjectAction/floatingBox.properties
  24. +4 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/CloverProjectAction/floatingBox_ja.properties
  25. +75 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/CloverPublisher/config.jelly
  26. +19 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/CloverPublisher/config.properties
  27. +25 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/CloverPublisher/config_ja.properties
  28. +17 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/Messages.properties
  29. +15 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/Messages_ja.properties
  30. +18 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/results/ClassCoverage/index.jelly
  31. +2 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/results/ClassCoverage/index_ja.properties
  32. +20 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/results/FileCoverage/index.jelly
  33. +4 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/results/FileCoverage/index_ja.properties
  34. +2 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/results/Messages.properties
  35. +2 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/results/Messages_ja.properties
  36. +21 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/results/ProjectCoverage/index.jelly
  37. +4 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/results/ProjectCoverage/index_ja.properties
  38. +30 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/breakdownTable.jelly
  39. +13 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/captionLine.jelly
  40. +4 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/captionLine_ja.properties
  41. +31 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/coverage-bar.jelly
  42. +3 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/coverage-bar_ja.properties
  43. +28 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/shortBreakdownTable.jelly
  44. +11 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/shortCaptionLine.jelly
  45. +4 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/shortCaptionLine_ja.properties
  46. +23 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/shortSummaryTable.jelly
  47. +25 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/summaryTable.jelly
  48. 0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/taglib
  49. +4 −0 src/main/resources/org/jenkinsci/plugins/cloverphp/tags/trendGraph.jelly
  50. BIN src/main/webapp/clover.png
  51. BIN src/main/webapp/clover_48x48.png
  52. +12 −0 src/main/webapp/css/style.css
  53. +5 −0 src/main/webapp/help-cloverConfig.html
  54. +5 −0 src/main/webapp/help-cloverConfig_ja.html
  55. +4 −0 src/main/webapp/help-historical.html
  56. +4 −0 src/main/webapp/help-historical_ja.html
  57. +3 −0 src/main/webapp/help-json.html
  58. +3 −0 src/main/webapp/help-json_ja.html
  59. +5 −0 src/main/webapp/help-license.html
  60. +5 −0 src/main/webapp/help-license_ja.html
  61. +60 −0 src/test/java/org/jenkinsci/plugins/cloverphp/CloverCoverageParserTest.java
  62. +23 −0 src/test/java/org/jenkinsci/plugins/cloverphp/ConfigurationRoundtripTest.java
  63. +24 −0 src/test/java/org/jenkinsci/plugins/cloverphp/RatioTest.java
  64. +164 −0 src/test/resources/org/jenkinsci/plugins/cloverphp/clover-two-packages.xml
  65. +16 −0 src/test/resources/org/jenkinsci/plugins/cloverphp/clover.xml
@@ -0,0 +1,8 @@
target
.classpath
.settings
.project
*.iml
*.ipr
*.iws
work
145 pom.xml
@@ -0,0 +1,145 @@

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.410</version>

This comment has been minimized.

Copy link
@abayer

abayer Jul 27, 2011

Member

Any chance this could get rolled back to 1.409 with a new release? With it set to 1.410, the plugin won't install on the 1.409.x LTS releases.

This comment has been minimized.

Copy link
@ssogabe

ssogabe Jul 28, 2011

Author Member

You are right. I'll roll back it to 1.409.

</parent>

<artifactId>cloverphp</artifactId>
<packaging>hpi</packaging>
<version>0.1-SNAPSHOT</version>
<name>Jenkins Clover PHP plugin</name>
<url>http://wiki.jenkins-ci.org/display/JENKINS/Clover+PHP+Plugin</url>

<developers>
<developer>
<id>ssogabe</id>
<name>Seiji Sogabe</name>
</developer>
</developers>

<scm>
<connection>scm:git:git://github.com/ssogabe/clover-php-plugin.git</connection>
<developerConnection>scm:git:git@github.com:ssogabe/clover-php-plugin.git</developerConnection>
<url>http://github.com/ssogabe/clover-php-plugin</url>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<extensions>
<extension>
<groupId>jp.ddo.bacons</groupId>
<artifactId>check-rules</artifactId>
<version>0.2</version>
</extension>
</extensions>
</build>

<profiles>
<profile>
<id>report</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<locales>ja</locales>
<inputEncoding>${project.build.sourceEncoding}</inputEncoding>
<outputEncoding>${project.build.sourceEncoding}</outputEncoding>
</configuration>
</plugin>
</plugins>
</build>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.3</version>
<configuration>
<consoleOutput>false</consoleOutput>
<configLocation>default/checkstyle/checkstyle.xml</configLocation>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.4</version>
<configuration>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
<targetJdk>${jdk.version}</targetJdk>
<rulesets>
<ruleset>default/pmd/pmd.xml</ruleset>
</rulesets>
<excludes>
<exclude>**/Messages.java</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<includeFilterFile>default/findbugs/include_filter.xml</includeFilterFile>
<findbugsXmlOutput>true</findbugsXmlOutput>
<xmlOutput>true</xmlOutput>
<debug>true</debug>
<effort>Max</effort>
<onlyAnalyze>org.jenkinsci.plugins.*</onlyAnalyze>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5</version>
<configuration>
<formats>
<format>xml</format>
<format>html</format>
</formats>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.6</version>
<reportSets>
<reportSet>
<reports>
<report>report-only</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.0</version>
<configuration>
<dependencyLocationEnabled>false</dependencyLocationEnabled>
</configuration>
</plugin>
</plugins>
</reporting>
</profile>
</profiles>

<repositories>
<repository>
<id>m.g.o-public</id>
<url>http://maven.glassfish.org/content/groups/public/</url>
</repository>
</repositories>

</project>
@@ -0,0 +1,162 @@
package org.jenkinsci.plugins.cloverphp;

import hudson.model.AbstractBuild;
import hudson.model.HealthReport;
import hudson.model.HealthReportingAction;
import hudson.model.Result;
import org.jenkinsci.plugins.cloverphp.results.ProjectCoverage;
import org.jenkinsci.plugins.cloverphp.targets.CoverageMetric;
import org.jenkinsci.plugins.cloverphp.targets.CoverageTarget;
import org.kohsuke.stapler.StaplerProxy;

import java.io.File;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.jvnet.localizer.Localizable;

/**
* A health reporter for the individual build page.
*
*
* @author connollys
* @since 03-Jul-2007 08:43:08
*/
public class CloverBuildAction implements HealthReportingAction, StaplerProxy {

private final AbstractBuild owner;

private String buildBaseDir;

private CoverageTarget healthyTarget;

private CoverageTarget unhealthyTarget;

private transient WeakReference<ProjectCoverage> report;

public HealthReport getBuildHealth() {
if (healthyTarget == null || unhealthyTarget == null) {
return null;
}
ProjectCoverage projectCoverage = getResult();
Map<CoverageMetric, Integer> scores = healthyTarget.getRangeScores(unhealthyTarget, projectCoverage);
int minValue = 100;
CoverageMetric minKey = null;
for (Map.Entry<CoverageMetric, Integer> e : scores.entrySet()) {
if (e.getValue() < minValue) {
minKey = e.getKey();
minValue = e.getValue();
}
}
if (minKey == null) {
return null;
}

Localizable description = null;
switch (minKey) {
case METHOD:
description = Messages._CloverBuildAction_MethodCoverage(
projectCoverage.getMethodCoverage().getPercentage(),
projectCoverage.getMethodCoverage().toString());
break;
case STATEMENT:
description = Messages._CloverBuildAction_StatementCoverage(
projectCoverage.getStatementCoverage().getPercentage(),
projectCoverage.getStatementCoverage().toString());
break;
case ELEMENT:
description = Messages._CloverBuildAction_ElementCoverage(
projectCoverage.getElementCoverage().getPercentage(),
projectCoverage.getElementCoverage().toString());
break;
default:
return null;
}
return new HealthReport(minValue, description);
}

public String getIconFileName() {
return CloverProjectAction.ICON;
}

public String getDisplayName() {
return Messages.CloverBuildAction_DisplayName();
}

public String getUrlName() {
// TODO: more shorter
return "clover-php-report";
}

public Object getTarget() {
return getResult();
}

public CloverBuildAction getPreviousResult() {
return getPreviousResult(owner);
}

/** Gets the previous {@link CloverBuildAction} of the given build. */
/*package*/
static CloverBuildAction getPreviousResult(AbstractBuild start) {
AbstractBuild<?, ?> b = start;
while (true) {
b = b.getPreviousBuild();
if (b == null) {
return null;
}
if (b.getResult() == Result.FAILURE) {
continue;
}
CloverBuildAction r = b.getAction(CloverBuildAction.class);
if (r != null) {
return r;
}
}
}

CloverBuildAction(AbstractBuild owner, String workspacePath, ProjectCoverage r, CoverageTarget healthyTarget,
CoverageTarget unhealthyTarget) {
this.owner = owner;
this.report = new WeakReference<ProjectCoverage>(r);
this.buildBaseDir = workspacePath;
if (this.buildBaseDir == null) {
this.buildBaseDir = File.separator;
} else if (!this.buildBaseDir.endsWith(File.separator)) {
this.buildBaseDir += File.separator;
}
this.healthyTarget = healthyTarget;
this.unhealthyTarget = unhealthyTarget;
r.setOwner(owner);
}

/** Obtains the detailed {@link CoverageReport} instance. */
public synchronized ProjectCoverage getResult() {
if (report != null) {
ProjectCoverage r = report.get();
if (r != null) {
return r;
}
}

File reportFile = CloverPublisher.getCloverXmlReport(owner);
try {
ProjectCoverage r = CloverCoverageParser.parse(reportFile, buildBaseDir);
r.setOwner(owner);
report = new WeakReference<ProjectCoverage>(r);
return r;
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Failed to load " + reportFile, e);
return null;
}
}

private static final Logger LOGGER = Logger.getLogger(CloverBuildAction.class.getName());

public static CloverBuildAction load(AbstractBuild<?, ?> build, String workspacePath, ProjectCoverage result,
CoverageTarget healthyTarget, CoverageTarget unhealthyTarget) {
return new CloverBuildAction(build, workspacePath, result, healthyTarget, unhealthyTarget);
}
}
Oops, something went wrong.

0 comments on commit c768bb5

Please sign in to comment.
You can’t perform that action at this time.