Skip to content

Commit b10b28a

Browse files
authored
Merge pull request #602 from PierreBtz/pbeitz/formatter
2 parents ac92f34 + 6a5536f commit b10b28a

File tree

128 files changed

+15744
-14123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+15744
-14123
lines changed

CONTRIBUTING.adoc

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@ Unless code has shipped to users, the initial value of the `serialVersionUID` fi
2626

2727
== Indentation
2828

29-
1. **Use spaces.** Tabs are banned.
30-
2. **Java blocks are 4 spaces.** JavaScript blocks as for Java. **XML nesting is 2 spaces**
29+
The project relies on [https://github.com/diffplug/spotless/tree/main/plugin-maven](the Spotless Maven Plugin) to manage its formatting.
30+
The [https://github.com/google/google-java-format](google-java-format) project was chosen, check it, it contains links to plugins for various IDEs.
31+
You can also run the formatter from command line: `mvn spotless:apply`.
3132

3233
== Field Naming Conventions
3334

@@ -41,42 +42,6 @@ If you need more than three, you are likely doing something wrong and as such yo
4142
6. It is acceptable to use `e` for the exception in a `try...catch` block.
4243
7. You shall never use `l` (i.e. lower case `L`) as a variable name.
4344

44-
== Line Length
45-
46-
To the greatest extent possible, please wrap lines to ensure that they do not exceed 120 characters.
47-
48-
== Maven POM file layout
49-
50-
* The `pom.xml` file shall use the sequencing of elements as defined by the `mvn tidy:pom` command (after any indenting fix-up).
51-
* 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.
52-
* If the `<plugin>` is in the groupId `org.apache.maven.plugins` you shall omit the `<groupId>`.
53-
* All `<plugin>` entries shall have an explicit version defined unless inherited from the parent.
54-
55-
== Java code style
56-
57-
=== Modifiers
58-
59-
* For fields, the order is:
60-
. `public` / `protected` / `private`
61-
. `static`
62-
. `final`
63-
. `transient`
64-
. `volatile`
65-
* For methods, the order is:
66-
. `public` / `protected` / `private`
67-
. `abstract`
68-
. `static`
69-
. `final`
70-
. `synchronized`
71-
. `native`
72-
. `strictfp`
73-
* For classes, the order is:
74-
. `public` / `protected` / `private`
75-
. `abstract`
76-
. `static`
77-
. `final`
78-
. `strictfp`
79-
8045
=== Imports
8146

8247
* For code in `src/main`:
@@ -89,11 +54,6 @@ To the greatest extent possible, please wrap lines to ensure that they do not ex
8954
. `import static org.hamcrest.Matchers.*`, `import static org.junit.Assert.*`, `import static org.junit.Assume.*` are expressly encouraged and permitted.
9055
Any other `static` `*` imports are discouraged unless code readability is significantly enhanced and the import is restricted to a single class.
9156

92-
=== Annotation placement
93-
94-
* 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.
95-
* 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)
96-
9757
=== Javadoc
9858

9959
* Each class shall have a Javadoc comment.
@@ -138,35 +98,6 @@ public void setWidgetCount(int widgetCount) {
13898
The version shall be `FIXME` to indicate that the person merging the change should replace the `FIXME` with the next release version number.
13999
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.
140100

141-
=== IDE Configuration
142-
143-
* Eclipse, by and large the IDE defaults are acceptable with the following changes:
144-
** Tab policy to `Spaces only`
145-
** Indent statements within `switch` body
146-
** Maximum line width `120`
147-
** Line wrapping, ensure all to `wrap where necessary`
148-
** Organize imports alphabetically, no grouping
149-
* NetBeans, by and large the IDE defaults are acceptable with the following changes:
150-
** Tabs and Indents
151-
*** Change Right Margin to `120`
152-
*** Indent case statements in switch
153-
** Wrapping
154-
*** Change all the `Never` values to `If Long`
155-
*** Select the checkbox for Wrap After Assignment Operators
156-
* IntelliJ, by and large the IDE defaults are acceptable with the following changes:
157-
** Wrapping and Braces
158-
*** Change `Do not wrap` to `Wrap if long`
159-
*** Change `Do not force` to `Always`
160-
** Javadoc
161-
*** Disable generating `<p/>` on empty lines
162-
** Imports
163-
*** Class count to use import with '*': `9999`
164-
*** Names count to use static import with '*': `99999`
165-
*** Import Layout
166-
**** import all other imports
167-
**** blank line
168-
**** import static all other imports
169-
170101
== Integration Tests
171102

172103
This library has a set of integration tests in the class `src/test/java/org/zendesk/client/v2/RealSmokeTest.java`. These tests are used to validate the API calls with a real Zendesk instance. The project never got access to a specific sandbox provided by @zendesk thus we are using the sandbox used by CloudBees.

pom.xml

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
12
<!--
23
~ Copyright 2013, CloudBees Inc.
34
~
@@ -13,7 +14,6 @@
1314
~ See the License for the specific language governing permissions and
1415
~ limitations under the License.
1516
-->
16-
1717
<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">
1818
<modelVersion>4.0.0</modelVersion>
1919

@@ -74,8 +74,8 @@
7474
<scm>
7575
<connection>scm:git:git://github.com/cloudbees-oss/zendesk-java-client.git</connection>
7676
<developerConnection>scm:git:[email protected]:cloudbees-oss/zendesk-java-client.git</developerConnection>
77-
<url>http://github.com/cloudbees-oss/zendesk-java-client/tree/master/</url>
7877
<tag>HEAD</tag>
78+
<url>http://github.com/cloudbees-oss/zendesk-java-client/tree/master/</url>
7979
</scm>
8080

8181
<issueManagement>
@@ -91,6 +91,7 @@
9191
<properties>
9292
<maven.compiler.source>1.8</maven.compiler.source>
9393
<maven.compiler.target>1.8</maven.compiler.target>
94+
<spotless.version>2.30.0</spotless.version>
9495
</properties>
9596

9697
<dependencyManagement>
@@ -108,7 +109,7 @@
108109
<version>4.1.95.Final</version>
109110
<type>pom</type>
110111
<scope>import</scope>
111-
</dependency>
112+
</dependency>
112113
</dependencies>
113114
</dependencyManagement>
114115

@@ -155,10 +156,10 @@
155156
<scope>test</scope>
156157
</dependency>
157158
<dependency>
158-
<groupId>com.github.tomakehurst</groupId>
159-
<artifactId>wiremock</artifactId>
160-
<version>2.27.2</version>
161-
<scope>test</scope>
159+
<groupId>com.github.tomakehurst</groupId>
160+
<artifactId>wiremock</artifactId>
161+
<version>2.27.2</version>
162+
<scope>test</scope>
162163
</dependency>
163164
<dependency>
164165
<groupId>org.assertj</groupId>
@@ -203,6 +204,18 @@
203204
<configuration>
204205
<fail>true</fail>
205206
</configuration>
207+
<dependencies>
208+
<dependency>
209+
<groupId>org.codehaus.mojo</groupId>
210+
<artifactId>animal-sniffer-enforcer-rule</artifactId>
211+
<version>1.23</version>
212+
</dependency>
213+
<dependency>
214+
<groupId>org.codehaus.mojo</groupId>
215+
<artifactId>extra-enforcer-rules</artifactId>
216+
<version>1.7.0</version>
217+
</dependency>
218+
</dependencies>
206219
<executions>
207220
<execution>
208221
<id>check-java-compat</id>
@@ -236,34 +249,59 @@
236249
</configuration>
237250
</execution>
238251
</executions>
239-
<dependencies>
240-
<dependency>
241-
<groupId>org.codehaus.mojo</groupId>
242-
<artifactId>animal-sniffer-enforcer-rule</artifactId>
243-
<version>1.23</version>
244-
</dependency>
245-
<dependency>
246-
<groupId>org.codehaus.mojo</groupId>
247-
<artifactId>extra-enforcer-rules</artifactId>
248-
<version>1.7.0</version>
249-
</dependency>
250-
</dependencies>
251252
</plugin>
252253
<plugin>
253-
<groupId>org.apache.maven.plugins</groupId>
254-
<artifactId>maven-jar-plugin</artifactId>
255-
<version>3.3.0</version>
256-
<configuration>
257-
<archive>
258-
<manifestEntries>
259-
<Automatic-Module-Name>org.zendesk.client.v2</Automatic-Module-Name>
260-
</manifestEntries>
261-
</archive>
262-
</configuration>
254+
<groupId>org.apache.maven.plugins</groupId>
255+
<artifactId>maven-jar-plugin</artifactId>
256+
<version>3.3.0</version>
257+
<configuration>
258+
<archive>
259+
<manifestEntries>
260+
<Automatic-Module-Name>org.zendesk.client.v2</Automatic-Module-Name>
261+
</manifestEntries>
262+
</archive>
263+
</configuration>
264+
</plugin>
265+
<plugin>
266+
<groupId>com.diffplug.spotless</groupId>
267+
<artifactId>spotless-maven-plugin</artifactId>
268+
<version>${spotless.version}</version>
269+
<configuration>
270+
<java>
271+
<toggleOffOn>
272+
<off>@formatter:off</off>
273+
<on>@formatter:on</on>
274+
</toggleOffOn>
275+
<googleJavaFormat/>
276+
<importOrder/>
277+
<removeUnusedImports/>
278+
<formatAnnotations/>
279+
</java>
280+
<pom>
281+
<sortPom>
282+
<expandEmptyElements>false</expandEmptyElements>
283+
</sortPom>
284+
</pom>
285+
</configuration>
286+
<executions>
287+
<execution>
288+
<goals>
289+
<goal>check</goal>
290+
</goals>
291+
</execution>
292+
</executions>
293+
</plugin>
294+
<plugin>
295+
<groupId>org.apache.maven.plugins</groupId>
296+
<artifactId>maven-release-plugin</artifactId>
297+
<configuration>
298+
<completionGoals>spotless:apply verify</completionGoals>
299+
<preparationGoals>spotless:apply verify</preparationGoals>
300+
</configuration>
263301
</plugin>
264302
</plugins>
265303
</build>
266-
304+
267305
<profiles>
268306
<profile>
269307
<id>coverage</id>
@@ -291,6 +329,6 @@
291329
</plugins>
292330
</build>
293331
</profile>
294-
</profiles>
332+
</profiles>
295333

296334
</project>

src/main/java/org/zendesk/client/v2/FixedUri.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
*/
77
class FixedUri extends Uri {
88

9-
private final String uri;
9+
private final String uri;
1010

11-
FixedUri(String uri) {
12-
this.uri = uri;
13-
}
11+
FixedUri(String uri) {
12+
this.uri = uri;
13+
}
1414

15-
@Override
16-
public String toString() {
17-
return uri;
18-
}
15+
@Override
16+
public String toString() {
17+
return uri;
18+
}
1919
}
Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.zendesk.client.v2;
22

33
import com.damnhandy.uri.template.UriTemplate;
4-
54
import java.util.Date;
65
import java.util.Map;
76

@@ -11,33 +10,33 @@
1110
*/
1211
class TemplateUri extends Uri {
1312

14-
private final UriTemplate uri;
13+
private final UriTemplate uri;
1514

16-
public TemplateUri(UriTemplate uri) {
17-
this.uri = uri;
18-
}
15+
public TemplateUri(UriTemplate uri) {
16+
this.uri = uri;
17+
}
1918

20-
public TemplateUri(String uri) {
21-
this.uri = UriTemplate.fromTemplate(uri);
22-
}
19+
public TemplateUri(String uri) {
20+
this.uri = UriTemplate.fromTemplate(uri);
21+
}
2322

24-
public TemplateUri set(Map<String, Object> values) {
25-
uri.set(values);
26-
return this;
27-
}
23+
public TemplateUri set(Map<String, Object> values) {
24+
uri.set(values);
25+
return this;
26+
}
2827

29-
public TemplateUri set(String variableName, Date value) {
30-
uri.set(variableName, value);
31-
return this;
32-
}
28+
public TemplateUri set(String variableName, Date value) {
29+
uri.set(variableName, value);
30+
return this;
31+
}
3332

34-
public TemplateUri set(String variableName, Object value) {
35-
uri.set(variableName, value);
36-
return this;
37-
}
33+
public TemplateUri set(String variableName, Object value) {
34+
uri.set(variableName, value);
35+
return this;
36+
}
3837

39-
@Override
40-
public String toString() {
41-
return uri.expand();
42-
}
38+
@Override
39+
public String toString() {
40+
return uri.expand();
41+
}
4342
}

src/main/java/org/zendesk/client/v2/Uri.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
* @since 05/04/2013 10:05
66
*/
77
abstract class Uri {
8-
@Override
9-
public abstract String toString();
8+
@Override
9+
public abstract String toString();
1010
}

0 commit comments

Comments
 (0)