Skip to content

Commit

Permalink
Format source code with spotless, add contributing guide
Browse files Browse the repository at this point in the history
jenkinsci/plugin-pom#733 describes the benefits of
automated source code formatting and how automated source code formatting
is now provided by the Jenkins plugin POM.
  • Loading branch information
MarkEWaite committed Dec 16, 2023
1 parent 2b3c215 commit 0ae22fd
Show file tree
Hide file tree
Showing 9 changed files with 1,330 additions and 1,261 deletions.
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing to the plugin

Plugin source code is hosted on [GitHub](https://github.com/jenkinsci/apache-httpcomponents-client-4-api-plugin).
New feature proposals and bug fix proposals should be submitted as
[GitHub pull requests](https://help.github.com/articles/creating-a-pull-request).
Your pull request will be evaluated by the [Jenkins job](https://ci.jenkins.io/job/Plugins/job/apache-httpcomponents-client-4-api-plugin/).

Before submitting your change, please assure that you've added tests which verify your change.

## Code formatting

Source code and pom file formatting is maintained by the `spotless` maven plugin.
Before submitting a pull request, confirm the formatting is correct with:

* `mvn spotless:apply`

## Code Coverage

[JaCoCo code coverage](https://www.jacoco.org/jacoco/) reporting is available as a maven target and can be displayed by the [Jenkins warnings next generation plugin](https://plugins.jenkins.io/warnings-ng/).
Please try to improve code coverage with tests when you submit.
* `mvn -P enable-jacoco clean install jacoco:report` to report code coverage with JaCoCo.

Please don't introduce new spotbugs output.
* `mvn spotbugs:check` to analyze project using [Spotbugs](https://spotbugs.github.io)
* `mvn spotbugs:gui` to review report using GUI

### Reviewing code coverage

The code coverage report is a set of HTML files that show methods and lines executed.
The following commands will open the `index.html` file in the browser.

* Windows - `start target\site\jacoco\index.html`
* Linux - `xdg-open target/site/jacoco/index.html`
* Gitpod - `cd target/site/jacoco && python -m http.server 8000`

The file will have a list of package names.
Click on them to find a list of class names.

The lines of the code will be covered in three different colors, red, green, and orange.
Red lines are not covered in the tests.
Green lines are covered with tests.

## Maintaining automated tests

Automated tests are run as part of the `verify` phase.
Run automated tests with multiple Java virtual machines in a development environment with the command:

```
$ mvn clean -DforkCount=1C verify
```

## Report an Issue

Use the ["Report an issue" page](https://www.jenkins.io/participate/report-issue/redirect/#23052) to submit bug reports.
Please use the link:https://www.jenkins.io/participate/report-issue/["How to Report an Issue"] guidelines when reporting issues.
158 changes: 80 additions & 78 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
Expand All @@ -6,98 +7,99 @@
<version>4.76</version>
<relativePath />
</parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>groovy-postbuild</artifactId>
<version>2.6-SNAPSHOT</version>
<packaging>hpi</packaging>

<name>Groovy Postbuild</name>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>groovy-postbuild</artifactId>
<version>2.6-SNAPSHOT</version>
<packaging>hpi</packaging>
<url>https://wiki.jenkins.io/display/JENKINS/Groovy+Postbuild+Plugin</url>
<name>Groovy Postbuild</name>
<url>https://wiki.jenkins.io/display/JENKINS/Groovy+Postbuild+Plugin</url>

<developers>
<developer>
<id>wolfs</id>
<name>Stefan Wolf</name>
</developer>
<developer>
<id>beryx</id>
<name>Serban Iordache</name>
</developer>
</developers>
<licenses>
<license>
<name>The MIT license</name>
<url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<licenses>
<license>
<name>The MIT license</name>
<url>https://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>

<properties>
<jenkins.version>2.361.4</jenkins.version>
</properties>
<developers>
<developer>
<id>markewaite</id>
<name>Mark Waite</name>
<email>[email protected]</email>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>

<scm>
<connection>scm:git:https://github.com/jenkinsci/groovy-postbuild-plugin.git</connection>
<developerConnection>scm:git:[email protected]:jenkinsci/groovy-postbuild-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/groovy-postbuild-plugin</url>
<tag>HEAD</tag>
<url>https://github.com/jenkinsci/groovy-postbuild-plugin</url>
</scm>

<properties>
<jenkins.version>2.361.4</jenkins.version>
<spotless.check.skip>false</spotless.check.skip>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.361.x</artifactId>
<version>2102.v854b_fec19c92</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>badge</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.jenkins.tools.bom</groupId>
<artifactId>bom-2.361.x</artifactId>
<version>2102.v854b_fec19c92</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>badge</artifactId>
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>matrix-project</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>script-security</artifactId>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package org.jvnet.hudson.plugins.groovypostbuild;

import com.jenkinsci.plugins.badge.action.BadgeAction;

import hudson.model.BuildBadgeAction;

/**
Expand All @@ -39,16 +38,47 @@ public class GroovyPostbuildAction implements BuildBadgeAction {
private GroovyPostbuildAction() {}

/* Action methods */
public String getUrlName() { return ""; }
public String getDisplayName() { return ""; }
public String getIconFileName() { return null; }

public boolean isTextOnly() { return false; }
public String getIconPath() { return null; }
public String getText() { return ""; }
public String getColor() { return "#000000"; }
public String getBackground() { return "#FFFF00"; }
public String getBorder() { return "1px"; }
public String getBorderColor() { return "#C0C000"; }
public String getLink() { return null; }
public String getUrlName() {
return "";
}

public String getDisplayName() {
return "";
}

public String getIconFileName() {
return null;
}

public boolean isTextOnly() {
return false;
}

public String getIconPath() {
return null;
}

public String getText() {
return "";
}

public String getColor() {
return "#000000";
}

public String getBackground() {
return "#FFFF00";
}

public String getBorder() {
return "1px";
}

public String getBorderColor() {
return "#C0C000";
}

public String getLink() {
return null;

Check warning on line 82 in src/main/java/org/jvnet/hudson/plugins/groovypostbuild/GroovyPostbuildAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 42-82 are not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
*/
package org.jvnet.hudson.plugins.groovypostbuild;


import org.kohsuke.stapler.StaplerRequest;

import com.jenkinsci.plugins.badge.action.BadgeAction;

import hudson.Extension;
import hudson.init.InitMilestone;
import hudson.init.Initializer;
Expand All @@ -36,6 +32,7 @@
import hudson.model.Run;
import hudson.tasks.BuildStepDescriptor;
import hudson.tasks.Publisher;
import org.kohsuke.stapler.StaplerRequest;

@Extension
public class GroovyPostbuildDescriptor extends BuildStepDescriptor<Publisher> {
Expand Down Expand Up @@ -68,7 +65,7 @@ public String getHelpFile() {
* @return true
*/
@SuppressWarnings("unchecked")
@Override
@Override
public final boolean isApplicable(final Class<? extends AbstractProject> clazz) {
return true;
}
Expand All @@ -90,7 +87,10 @@ public boolean isMatrixProject(Object it) {
@Initializer(before = InitMilestone.PLUGINS_STARTED)
public static void addAliases() {
// migration from groovy-postbuild 2.3.1- to badge-plugin
Run.XSTREAM2.addCompatibilityAlias("org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildAction", BadgeAction.class);
Run.XSTREAM2.addCompatibilityAlias("org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildSummaryAction", GroovyPostbuildSummaryActionMigrator.class);
Run.XSTREAM2.addCompatibilityAlias(
"org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildAction", BadgeAction.class);
Run.XSTREAM2.addCompatibilityAlias(
"org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildSummaryAction",
GroovyPostbuildSummaryActionMigrator.class);
}
}
Loading

0 comments on commit 0ae22fd

Please sign in to comment.