Skip to content

Commit

Permalink
Merge pull request #9 from recena/JENKINS-29308
Browse files Browse the repository at this point in the history
[JENKINS-29308] Update project configuration. Clean up.
  • Loading branch information
recena committed Oct 20, 2015
2 parents 7cce021 + cbb7ecb commit 659f2ab
Show file tree
Hide file tree
Showing 21 changed files with 2,229 additions and 2,001 deletions.
152 changes: 152 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,152 @@
# Development Ideology

Truths which we believe to be self-evident (adapted from [TextSecure's](https://github.com/WhisperSystems/TextSecure/blob/master/contributing.md))

1. **The answer is not more options.** If you feel compelled to add a preference that's exposed to the user, it's very possible you've made a wrong turn somewhere.
2. **There are no power users.** The idea that some users "understand" concepts better than others has proven to be, for the post part, false. If anything, "power users" are more dangerous than the test, and we should avoid exposing dangerous functionality to them.
3. **If it's "like PGP," it's wrong.** PGP is our guide for what not to do.
4. **It's an asynchronous world.** We wary of anything that is anti-asynchronous: ACKs, protocol confirmations, or anly protocol-level "advisory" message.
5. **There is no such thing as time**. Protocol ideas that require synchonized clocks are doomed to failure.

# Code Style Guidelines

## Resulting from long experience

* To the largest extent possible, all fields shall be private. Use an IDE to generate the getters and setters.
* If a class has more than one `volatile` member field, it is probable that there are subtle race conditions. Please consider where appropriate encapsulation of the multiple fields into an immutable value object replace the multiple `volatile` member fields with a single `volatile` reference to the value object (or perhaps better yet an `AtomicReference` to allow for `compareAndSet` - if compare-and-set logic is appropriate).
* If it is `Serializable` it shall have a `serialVersionUID` field. Unless code has shipped to users, the initial value of the `serialVersionUID` field shall be `1L`.

## Indentation

1. **Use spaces.** Tabs are banned.
2. **Java blocks are 4 spaces.** JavaScript blocks as for Java. **XML nesting is 2 spaces**

## Field Naming Conventions

1. "hungarian"-style notation is banned (i.e. instance variable names preceded by an 'm', etc)
2. If the field is `static final` then it shall be named in `ALL_CAPS_WITH_UNDERSCORES`.
3. Start variable names with a lowercase letter and use camelCase rather than under_scores.
4. Spelling and abreviations: If the word is widely used in the JVM runtime, stick with the spelling/abreviation in the JVM runtime, e.g. `color` over `colour`, `sync` over `synch`, `async` over `asynch`, etc.
5. It is acceptable to use `i`, `j`, `k` for loop indices and iterators. If you need more than three, you are likely doing something wrong and as such you shall either use full descriptive names or refactor.
6. It is acceptable to use `e` for the exception in a `try...catch` block.
7. You shall never use `l` (i.e. lower case `L`) as a variable name.

## Line Length

To the greatest extent possible, please wrap lines to ensure that they do not exceed 120 characters.

## Maven POM file layout

* The `pom.xml` file shall use the sequencing of elements as defined by the `mvn tidy:pom` command (after any indenting fix-up).
* If you are introducing a property to the `pom.xml` the property must be used in at least two distinct places in the model or a comment justifying the use of a property shall be provided.
* If the `<plugin>` is in the groupId `org.apache.maven.plugins` you shall omit the `<groupId>`.
* All `<plugin>` entries shall have an explicit version defined unless inherited from the parent.

## Java code style

### Modifiers

* For fields, the order is:
- public / protected / private
- static
- final
- transient
- volatile
* For methods, the order is:
- public / protected / private
- abstract
- static
- final
- synchronized
- native
- strictfp
* For classes, the order is:
- public / protected / private
- abstract
- static
- final
- strictfp

### Imports

* For code in `src/main`:
- `*` imports are banned.
- `static` imports are strongly discouraged.
- `static` `*` imports are discouraged unless code readability is significantly enhanced and the import is restricted to a single class.
* For code in `src/test`:
- `*` imports of anything other than JUnit classes and Hamcrest matchers are banned.
- `static` imports of anything other than JUnit classes and Hamcrest matchers are strongly discouraged.
- `import static org.hamcrest.Matchers.*`, `import static org.junit.Assert.*` are expressly permitted. Any other `static` `*` imports are discouraged unless code readability is significantly enhanced and the import is restricted to a single class.

### Annotation placement

* Annotations on classes, interfaces, annotations, enums, methods, fields and local variables shall be on the lines immediately preceding the line where modifier(s) (e.g. `public` / `protected` / `private` / `final`, etc) would be appropriate.
* Annotations on method arguments shall, to the largest extent possible, be on the same line as the method argument (and, if present, before the `final` modifier)

### Javadoc

* Each class shall have a Javadoc comment.
* Each field shall have a Javadoc comment.
* Unless the method is `private`, it shall have a Javadoc comment.
* When a method is overriding a method from a super-class / interface, unless the semantics of the method have changed it is sufficient to document the intent of implementing the super-method's contract with:
```
/**
* {@inheritDoc}
*/
@Override
```
* Getters and Setters shall have a Javadoc comment. The following is prefered
```
/**
* The count of widgets
*/
private int widgetCount;
/**
* Returns the count of widgets.
*
* @return the count of widgets.
*/
public int getWidgetCount() {
return widgetCount;
}
/**
* Sets the count of widgets.
*
* @param widgetCount the count of widgets.
*/
public void setWidgetCount(int widgetCount) {
this.widgetCount = widgetCount;
}
```
* When adding a new class / interface / etc, it shall have a `@since` doc comment. The version shall be `FIXME` to indicate that the person merging the change should replace the `FIXME` with the next release version number. The fields and methods within a class/interface (but not nested classes) will be assumed to have the `@since` annotation of their class/interface unless a different `@since` annotation is present.

### IDE Configuration

* Eclipse, by and large the IDE defaults are acceptable with the following changes:
- Tab policy to `Spaces only`
- Indent statements within `switch` body
- Maximum line width `120`
- Line wrapping, ensure all to `wrap where necessary`
- Organize imports alphabetically, no grouping
* NetBeans, by and large the IDE defaults are acceptable with the following changes:
- Tabs and Indents
+ Change Right Margin to `120`
+ Indent case statements in switch
- Wrapping
+ Change all the `Never` values to `If Long`
+ Select the checkbox for Wrap After Assignement Operators
* IntelliJ, by and large the IDE defaults are acceptable with the following changes:
- Wrapping and Braces
+ Change `Do not wrap` to `Wrap if long`
+ Change `Do not force` to `Always`
- Javadoc
+ Disable generating `<p/>` on empty lines
- Imports
+ Class count to use import with '*': `9999`
+ Names count to use static import with '*': `99999`
+ Import Layout
* import all other imports
* blank line
* import static all other imports
70 changes: 59 additions & 11 deletions pom.xml
@@ -1,28 +1,39 @@
<?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">
<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.596.1</version>
</parent>

<artifactId>log-parser</artifactId>
<packaging>hpi</packaging>
<version>1.1-SNAPSHOT</version>
<name>Log Parser Plugin</name>
<version>1.1-SNAPSHOT</version>
<url>https://wiki.jenkins-ci.org/display/JENKINS/Log+Parser+Plugin</url>
<description>Parses the console log generated by a build</description>

<properties>
<project.build.outputEncoding>UTF-8</project.build.outputEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<workflow-jenkins-plugin.version>1.7</workflow-jenkins-plugin.version>
</properties>

<licenses>
<license>
<name>MIT license</name>
<comments>All source code is under the MIT license.</comments>
</license>
</licenses>

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.5</version>
<configuration>
<targetJdk>1.6</targetJdk>
<rulesets>
Expand All @@ -43,8 +54,7 @@
</plugin>
</plugins>
</reporting>
<!-- Hudson WIKI -->
<url>http://wiki.jenkins-ci.org/display/JENKINS/Log+Parser+Plugin</url>

<developers>
<developer>
<id>jborghi</id>
Expand All @@ -60,35 +70,73 @@
<version>${workflow-jenkins-plugin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>1.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<!-- see http://groups.google.com/group/hudson-dev/browse_thread/thread/83e34c639eec470a
for the rationale behind this -->

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<goals>deploy</goals>
<excludeFilterFile>src/findbugs/excludesFilter.xml</excludeFilterFile>
<failOnError>false</failOnError>
<xmlOutput>true</xmlOutput>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<scm>
<connection>scm:git:git://github.com/jenkinsci/log-parser-plugin.git</connection>
<developerConnection>scm:git:git@github.com:jenkinsci/log-parser-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/log-parser-plugin</url>
</scm>

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

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

</project>
29 changes: 29 additions & 0 deletions src/findbugs/excludesFilter.xml
@@ -0,0 +1,29 @@
<!--
~ The MIT License
~
~ Copyright (c) 2015, CloudBees, Inc.
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in
~ all copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
~ THE SOFTWARE.
-->

<FindBugsFilter>
<Match>
<Class name="~.*\.Messages"/>
</Match>
</FindBugsFilter>
70 changes: 37 additions & 33 deletions src/main/java/hudson/plugins/logparser/CompiledPatterns.java
@@ -1,33 +1,37 @@
package hudson.plugins.logparser;

import java.util.regex.Pattern;

public class CompiledPatterns {

private String errorMsg = null;
private Pattern[] compiledPatterns = null;

public CompiledPatterns() {
}

public String getError() {
return errorMsg;
}

public void setError(final String errorMsg) {
if (errorMsg == null || errorMsg.trim().length() == 0) {
this.errorMsg = null;
} else {
this.errorMsg = errorMsg.trim();
}
}

public Pattern[] getCompiledPatterns() {
return compiledPatterns;
}

public void setCompiledPatters(final Pattern[] compiledPatterns) {
this.compiledPatterns = compiledPatterns;
}

}
package hudson.plugins.logparser;

import javax.annotation.CheckForNull;
import java.util.regex.Pattern;

public class CompiledPatterns {

private String errorMsg;
private Pattern[] compiledPatterns;

public CompiledPatterns() {
this.errorMsg = null;
this.compiledPatterns = null;
}

public String getError() {
return errorMsg;
}

public void setError(final String errorMsg) {
if (errorMsg == null || errorMsg.trim().length() == 0) {
this.errorMsg = null;
} else {
this.errorMsg = errorMsg.trim();
}
}

@CheckForNull
public Pattern[] getCompiledPatterns() {
return compiledPatterns;
}

public void setCompiledPatters(final Pattern[] compiledPatterns) {
this.compiledPatterns = compiledPatterns;
}

}

0 comments on commit 659f2ab

Please sign in to comment.