Skip to content

Commit 6ad5584

Browse files
velokdavisk6
authored andcommitted
Enforce format (OpenFeign#804)
* Enforce format * Applying feign code formatter
1 parent 989fbd7 commit 6ad5584

9 files changed

Lines changed: 42 additions & 32 deletions

File tree

core/src/test/java/feign/DefaultContractTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ public void headersOnTypeAddsContentTypeHeader() throws Exception {
159159
entry("Content-Type", asList("application/xml")),
160160
entry("Content-Length", asList(String.valueOf(md.template().body().length))));
161161
}
162-
162+
163163
@Test
164164
public void headersContainsWhitespaces() throws Exception {
165165
MethodMetadata md = parseAndValidateMetadata(HeadersContainsWhitespaces.class, "post");
@@ -463,7 +463,7 @@ interface HeadersContainsWhitespaces {
463463
@Body("<v01:getAccountsListOfUser/>")
464464
Response post();
465465
}
466-
466+
467467
interface WithURIParam {
468468

469469
@RequestLine("GET /{1}/{2}")

example-github/src/main/java/feign/example/github/GitHubExample.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ class Contributor {
4949
/** Lists all contributors for all repos owned by a user. */
5050
default List<String> contributors(String owner) {
5151
return repos(owner).stream()
52-
.flatMap(repo -> contributors(owner, repo.name).stream())
53-
.map(c -> c.login)
54-
.distinct()
55-
.collect(Collectors.toList());
52+
.flatMap(repo -> contributors(owner, repo.name).stream())
53+
.map(c -> c.login)
54+
.distinct()
55+
.collect(Collectors.toList());
5656
}
5757

5858
static GitHub connect() {

example-wikipedia/src/main/java/feign/example/wikipedia/ResponseAdapter.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,24 @@
1616
import com.google.gson.TypeAdapter;
1717
import com.google.gson.stream.JsonReader;
1818
import com.google.gson.stream.JsonWriter;
19-
2019
import java.io.IOException;
2120

2221
abstract class ResponseAdapter<X> extends TypeAdapter<WikipediaExample.Response<X>> {
2322

2423
/**
25-
* name of the key inside the {@code query} dict which holds the elements desired. ex. {@code
24+
* name of the key inside the {@code query} dict which holds the elements desired. ex. {@code
2625
* pages}.
2726
*/
2827
protected abstract String query();
2928

3029
/**
31-
* Parses the contents of a result object. <p/> <br> ex. If {@link #query()} is {@code pages},
32-
* then this would parse the value of each key in the dict {@code pages}. In the example below,
33-
* this would first start at line {@code 3}. <p/>
30+
* Parses the contents of a result object.
31+
* <p/>
32+
* <br>
33+
* ex. If {@link #query()} is {@code pages}, then this would parse the value of each key in the
34+
* dict {@code pages}. In the example below, this would first start at line {@code 3}.
35+
* <p/>
36+
*
3437
* <pre>
3538
* "pages": {
3639
* "2576129": {

example-wikipedia/src/main/java/feign/example/wikipedia/WikipediaExample.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@
1717
import com.google.gson.GsonBuilder;
1818
import com.google.gson.reflect.TypeToken;
1919
import com.google.gson.stream.JsonReader;
20-
2120
import java.io.IOException;
2221
import java.util.ArrayList;
2322
import java.util.Iterator;
24-
2523
import feign.Feign;
2624
import feign.Logger;
2725
import feign.Param;
@@ -56,8 +54,7 @@ protected Page build(JsonReader reader) throws IOException {
5654

5755
public static void main(String... args) throws InterruptedException {
5856
Gson gson = new GsonBuilder()
59-
.registerTypeAdapter(new TypeToken<Response<Page>>() {
60-
}.getType(), pagesAdapter)
57+
.registerTypeAdapter(new TypeToken<Response<Page>>() {}.getType(), pagesAdapter)
6158
.create();
6259

6360
Wikipedia wikipedia = Feign.builder()
@@ -77,7 +74,7 @@ public static void main(String... args) throws InterruptedException {
7774
* this will lazily continue searches, making new http calls as necessary.
7875
*
7976
* @param wikipedia used to search
80-
* @param query see {@link Wikipedia#search(String)}.
77+
* @param query see {@link Wikipedia#search(String)}.
8178
*/
8279
static Iterator<Page> lazySearch(final Wikipedia wikipedia, final String query) {
8380
final Response<Page> first = wikipedia.search(query);

jaxb/src/main/java/feign/jaxb/JAXBContextFactory.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
import javax.xml.bind.Unmarshaller;
2626

2727
/**
28-
* Creates and caches JAXB contexts as well as creates Marshallers and Unmarshallers for each context.
29-
* Since JAXB contexts creation can be an expensive task, JAXB context can be preloaded on factory creation
30-
* otherwise they will be created and cached dynamically when needed.
28+
* Creates and caches JAXB contexts as well as creates Marshallers and Unmarshallers for each
29+
* context. Since JAXB contexts creation can be an expensive task, JAXB context can be preloaded on
30+
* factory creation otherwise they will be created and cached dynamically when needed.
3131
*/
3232
public final class JAXBContextFactory {
3333

@@ -77,6 +77,7 @@ private JAXBContext getContext(Class<?> clazz) throws JAXBException {
7777

7878
/**
7979
* Will preload factory's cache with JAXBContext for provided classes
80+
*
8081
* @param classes
8182
* @throws JAXBException
8283
*/

jaxrs/src/main/java/feign/jaxrs/JAXRSContract.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.util.Arrays;
2424
import java.util.Collection;
2525
import java.util.Collections;
26-
2726
import static feign.Util.checkState;
2827
import static feign.Util.emptyToNull;
2928
import static feign.Util.removeValues;
@@ -58,7 +57,8 @@ protected void processAnnotationOnClass(MethodMetadata data, Class<?> clz) {
5857
// added
5958
pathValue = pathValue.substring(0, pathValue.length() - 1);
6059
}
61-
// jax-rs allows whitespace around the param name, as well as an optional regex. The contract should
60+
// jax-rs allows whitespace around the param name, as well as an optional regex. The contract
61+
// should
6262
// strip these out appropriately.
6363
pathValue = pathValue.replaceAll("\\{\\s*(.+?)\\s*(:.+?)?\\}", "\\{$1\\}");
6464
data.template().uri(pathValue);

jaxrs/src/test/java/feign/jaxrs/JAXRSContractTest.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,9 @@ public void regexPathOnMethodOrType() throws Exception {
265265
.hasUrl("/base/regex/{param1}/{param2}");
266266

267267
assertThat(parseAndValidateMetadata(
268-
ComplexPathOnType.class, "pathParamWithMultipleRegex", String.class, String.class).template())
269-
.hasUrl("/{baseparam}/regex/{param1}/{param2}");
268+
ComplexPathOnType.class, "pathParamWithMultipleRegex", String.class, String.class)
269+
.template())
270+
.hasUrl("/{baseparam}/regex/{param1}/{param2}");
270271
}
271272

272273
@Test
@@ -538,11 +539,12 @@ Response pathParamWithMultipleRegex(@PathParam("param1") String param1,
538539

539540
@Path("/{baseparam: [0-9]+}")
540541
interface ComplexPathOnType {
541-
542+
542543
@GET
543544
@Path("regex/{param1:[0-9]*}/{ param2 : .+}")
544-
Response pathParamWithMultipleRegex(@PathParam("param1") String param1, @PathParam("param2") String param2);
545-
}
545+
Response pathParamWithMultipleRegex(@PathParam("param1") String param1,
546+
@PathParam("param2") String param2);
547+
}
546548

547549
interface WithURIParam {
548550

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,11 +479,6 @@
479479

480480
<profile>
481481
<id>validateCodeFormat</id>
482-
<activation>
483-
<property>
484-
<name>validateFormat</name>
485-
</property>
486-
</activation>
487482

488483
<build>
489484
<plugins>

travis/publish.sh

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,19 @@ if ! is_pull_request && build_started_by_tag; then
159159
fi
160160

161161
# skip license on travis due to #1512
162-
./mvnw install -nsu -Dlicense.skip=true -DvalidateFormat
162+
./mvnw install -nsu -Dlicense.skip=true
163+
164+
# formatter errors:
165+
if [ -z $(git status --porcelain) ];
166+
then
167+
echo "No changes detected, all good"
168+
else
169+
echo "The following files have formatting changes:"
170+
git status --porcelain
171+
echo ""
172+
echo "Please run 'mvn clean install' locally to format files"
173+
exit 1
174+
fi
163175

164176
# If we are on a pull request, our only job is to run tests, which happened above via ./mvnw install
165177
if is_pull_request; then

0 commit comments

Comments
 (0)