Skip to content

Commit

Permalink
Merge branch 'update-prettier'
Browse files Browse the repository at this point in the history
  • Loading branch information
jqno committed Oct 10, 2023
2 parents edb8d70 + 89d8e67 commit 10f08ff
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 57 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
d698561e58fce0a498ccc9c43539046b5f9a6ddf
# Prettier (initial run)
a9aba4023da451dba32fcf7189348e3e063feaf4
# Reformats after prettier-java update
a3246612e0cb7173d4edd068eaa5bb017b0468da
8 changes: 1 addition & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,9 @@ jobs:
with:
distribution: ${{ matrix.dist }}
java-version: ${{ matrix.java }}
- name: 'Set up node' # Needed for formatting with prettier
if: ${{ !(matrix.experimental && github.event_name == 'pull_request') }}
uses: actions/setup-node@v3
with:
node-version: 12
- name: 'Display JDK version'
if: ${{ !(matrix.experimental && github.event_name == 'pull_request') }}
run: java -version
- name: 'Run Maven'
if: ${{ !(matrix.experimental && github.event_name == 'pull_request') }}
# Don't clean, or whatever was cached in target/spotless-node-modules-prettier-format is lost
run: mvn verify ${{ matrix.flags }}
run: mvn clean verify ${{ matrix.flags }}
1 change: 0 additions & 1 deletion .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# Changes here must be reflected in pom.xml
tabWidth: 4
printWidth: 100
trailingComma: "none"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ There are several Maven profiles that can be enabled or disabled:

## Formatting

EqualsVerifier uses [Prettier-Java](https://github.com/jhipster/prettier-java) through [Spotless](https://github.com/diffplug/spotless) to format Java files. You can call it using `mvn` (without any parameters), which will also run the tests and all the other static analysis. Or run `mvn spotless:apply` to only run the formatter.
EqualsVerifier uses [Prettier-Java](https://github.com/jhipster/prettier-java) through [prettier-maven-plugin](https://github.com/HubSpot/prettier-maven-plugin) to format Java files. You can call it using `mvn clean verify`, or run `mvn prettier:write` to only run the formatter.

## Modules

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ public SealedTypeContainer(
@Override
public boolean equals(Object obj) {
return (
obj instanceof SealedTypeContainer other &&
obj instanceof
SealedTypeContainer other &&
Objects.equals(sealedWithFinalChild, other.sealedWithFinalChild) &&
Objects.equals(sealedWithNonsealedChild, other.sealedWithNonsealedChild)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,8 @@ private void assertFieldShouldBeIgnored(
private boolean shouldAllFieldsBeUsed(FieldAccessor fieldAccessor) {
return (
!warningsToSuppress.contains(Warning.ALL_FIELDS_SHOULD_BE_USED) &&
!(
warningsToSuppress.contains(Warning.ALL_NONFINAL_FIELDS_SHOULD_BE_USED) &&
!fieldAccessor.fieldIsFinal()
)
!(warningsToSuppress.contains(Warning.ALL_NONFINAL_FIELDS_SHOULD_BE_USED) &&
!fieldAccessor.fieldIsFinal())
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ private String buildMessage(Throwable e, Class<?> type, List<?> params) {
String msg = prefix;
if (hasZeros) {
msg +=
"\n If the record does not accept 0 or false as a value for its constructor parameters," +
" consider suppressing Warning.ZERO_FIELDS.";
"\n If the record does not accept 0 or false as a value for its constructor parameters," +
" consider suppressing Warning.ZERO_FIELDS.";
}
if (hasSomethingElse) {
msg +=
"\n If the record does not accept any of the given values for its constructor parameters," +
" consider providing prefab values for the types of those fields.";
"\n If the record does not accept any of the given values for its constructor parameters," +
" consider providing prefab values for the types of those fields.";
}
return msg;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ public boolean equals(Object obj) {
}
ThreeFieldsUsingAndOr other = (ThreeFieldsUsingAndOr) obj;
return (
Objects.equals(f, other.f) &&
Objects.equals(g, other.g) ||
(Objects.equals(f, other.f) && Objects.equals(g, other.g)) ||
Objects.equals(h, other.h)
);
}
Expand Down Expand Up @@ -300,8 +299,7 @@ public boolean equals(Object obj) {
ThreeFieldsUsingOrAnd other = (ThreeFieldsUsingOrAnd) obj;
return (
Objects.equals(f, other.f) ||
Objects.equals(g, other.g) &&
Objects.equals(h, other.h)
(Objects.equals(g, other.g) && Objects.equals(h, other.h))
);
}

Expand Down Expand Up @@ -372,10 +370,8 @@ public boolean equals(Object obj) {
FiveFieldsUsingAndsAndOrs other = (FiveFieldsUsingAndsAndOrs) obj;
return (
Objects.equals(f, other.f) ||
Objects.equals(g, other.g) &&
Objects.equals(h, other.h) ||
Objects.equals(i, other.i) &&
Objects.equals(j, other.j)
(Objects.equals(g, other.g) && Objects.equals(h, other.h)) ||
(Objects.equals(i, other.i) && Objects.equals(j, other.j))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public class TypeTagParameterizedTest<T> {
private final Map<String, List<String>> fieldWithNestedTypeParameters = null;

@SuppressWarnings("unused")
private final Map<List<Integer>, Map<List<Double>, Map<String, Float>>> fieldWithRidiculousTypeParameters =
null;
private final Map<
List<Integer>,
Map<List<Double>, Map<String, Float>>
> fieldWithRidiculousTypeParameters = null;

@SuppressWarnings({ "unused", "rawtypes" })
private final Map rawMapField = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,9 @@ public boolean equals(Object obj) {
result &= Objects.equals(_Byte, other._Byte);
result &= _Char == other._Char;
result &=
_Double == null
? other._Double == null
: Double.compare(_Double, other._Double) == 0;
_Double == null ? other._Double == null : Double.compare(_Double, other._Double) == 0;
result &=
_Float == null ? other._Float == null : Float.compare(_Float, other._Float) == 0;
_Float == null ? other._Float == null : Float.compare(_Float, other._Float) == 0;
result &= Objects.equals(_Int, other._Int);
result &= Objects.equals(_Long, other._Long);
result &= Objects.equals(_Short, other._Short);
Expand Down
33 changes: 8 additions & 25 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@
<version.pitest.maven>1.15.0</version.pitest.maven>
<version.spotbugs.maven>4.7.3.6</version.spotbugs.maven>
<version.spotbugs>4.7.3</version.spotbugs>
<version.spotless.maven>2.40.0</version.spotless.maven>
<version.spotless.prettier-java>2.2.0</version.spotless.prettier-java>
<version.spotless.prettier>2.8.8</version.spotless.prettier>
<version.prettier.maven>0.21</version.prettier.maven>
<version.prettier-java.maven>2.3.1</version.prettier-java.maven>
</properties>

<build>
Expand Down Expand Up @@ -290,38 +289,22 @@
</plugin>

<plugin>
<groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId>
<version>${version.spotless.maven}</version>
<groupId>com.hubspot.maven.plugins</groupId>
<artifactId>prettier-maven-plugin</artifactId>
<version>${version.prettier.maven}</version>
<configuration>
<formats>
<format>
<includes>
<include>src/*/java/**/*.java</include>
</includes>
<prettier>
<devDependencies>
<prettier>${version.spotless.prettier}</prettier>
<prettier-plugin-java>${version.spotless.prettier-java}</prettier-plugin-java>
</devDependencies>
<config>
<!-- Changes here must be reflected in .prettierrc.yml -->
<tabWidth>4</tabWidth>
<printWidth>100</printWidth>
<trailingComma>none</trailingComma>
</config>
</prettier>
</format>
</formats>
<prettierJavaVersion>${version.prettier-java.maven}</prettierJavaVersion>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<!-- provides the pitest-git:aggregate goal to aggregate json files to be stored as artifact when accepting PRs from untrusted forks -->
<groupId>com.groupcdg</groupId>
Expand Down

0 comments on commit 10f08ff

Please sign in to comment.