Skip to content

Commit 4010b1d

Browse files
chore: Align formatting with Spring Framework and Spring Boot. (#3017)
We use the Spring Formatter already in many Neo4j projects and are quite happy with it. It feels natural to use it with a Spring project, too. We take the opportunity to apply the formatter to the upcoming 8.0.x release. We think that the now increased difficulty of back porting things to the 7.x lines is outweighed by the better format and the simpler tooling. Signed-off-by: Michael Simons <[email protected]>
1 parent 7fcacb7 commit 4010b1d

File tree

865 files changed

+36835
-30232
lines changed

Some content is hidden

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

865 files changed

+36835
-30232
lines changed

.editorconfig

Lines changed: 0 additions & 6 deletions
This file was deleted.

.mvn/extensions.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2011-2025 the original author or authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
219
<extensions>
320
<extension>
421
<groupId>io.spring.develocity.conventions</groupId>

CONTRIBUTING.adoc

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,97 @@
1-
= Spring Data contribution guidelines
1+
= Contributing
2+
3+
== Spring Data contribution guidelines
24

35
You find the contribution guidelines for Spring Data projects https://github.com/spring-projects/spring-data-build/blob/main/CONTRIBUTING.adoc[here].
6+
7+
== Building
8+
9+
JDK 17, Maven and Docker are required to build Spring Data Neo4j.
10+
A full build will be started with:
11+
12+
[source,bash]
13+
----
14+
./mvnw verify
15+
----
16+
17+
SDN uses https://jspecify.dev[JSpecify] annotations and the build can optionally run https://github.com/uber/NullAway[NullAway] in a dedicated profile that can be enabled like this:
18+
19+
[source,bash]
20+
----
21+
./mvnw verify -Pnullaway
22+
----
23+
24+
The above builds will use the Develocity build-caches. You can disable them as follows:
25+
26+
[source,bash]
27+
----
28+
./mvnw verify \
29+
-Ddevelocity.cache.local.enabled=false \
30+
-Ddevelocity.cache.remote.enabled=false
31+
----
32+
33+
The integration tests are able to use a locally running Neo4j instance, too:
34+
35+
[source,bash]
36+
----
37+
SDN_NEO4J_URL=bolt://localhost:7687 \
38+
SDN_NEO4J_PASSWORD=verysecret \
39+
./mvnw verify
40+
----
41+
42+
There's a `fast` profile that will skip all the tests and validations:
43+
44+
[source,bash]
45+
----
46+
./mvnw package -Pfast
47+
----
48+
49+
Build the documentation as follows:
50+
51+
[source,bash]
52+
----
53+
./mvnw process-resources -Pantora-process-resources
54+
./mvnw antora:antora -Pfast,antora
55+
----
56+
57+
58+
== Tasks
59+
60+
=== Keep the build descriptor (`pom.xml`) sorted
61+
62+
[source,bash]
63+
----
64+
./mvnw sortpom:sort
65+
----
66+
67+
=== Formatting sources / adding headers
68+
69+
When you add new files, you can run
70+
71+
[source,bash]
72+
----
73+
./mvnw license:format
74+
----
75+
76+
to add required headers automatically.
77+
78+
We use https://github.com/spring-io/spring-javaformat[spring-javaformat] to format the source files.
79+
80+
[source,bash]
81+
----
82+
./mvnw spring-javaformat:apply
83+
----
84+
85+
TIP: The Spring Developers write: "The source formatter does not fundamentally change your code. For example, it will not change the order of import statements. It is effectively limited to adding or removing whitespace and line feeds."
86+
This means the following checkstyle check might still fail.
87+
Some common errors:
88+
+
89+
Static imports, import `javax.*` and `java.*` before others
90+
+
91+
Static imports are helpful, yes, but when working with 2 builders in the same project (here jOOQ and Cypher-DSL), they can be quite confusing.
92+
93+
There are plugins for https://github.com/spring-io/spring-javaformat#eclipse[Eclipse] and https://github.com/spring-io/spring-javaformat#intellij-idea[IntelliJ IDEA] and the Checkstyle settings https://github.com/spring-io/spring-javaformat#checkstyle-idea-plugin[can be imported as well].
94+
We took those "as is" and just disabled the lambda check (requiring even single parameters to have parenthesis).
95+
96+
Public classes do require an author tag.
97+
Please add yourself as an `@author` to the `.java` files you added or that modified substantially (more than cosmetic changes).

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class MyService {
139139
Person michael = new Person("Michael");
140140
141141
// Persist entities and relationships to graph database
142-
return repository.saveAll(Flux.just(emil, gerrit, michael));
142+
return this.repository.saveAll(Flux.just(emil, gerrit, michael));
143143
}
144144
}
145145
----

ci/clean.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
#!/bin/bash -x
2+
#
3+
# Copyright 2011-2025 the original author or authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
218

319
set -euo pipefail
420

ci/pipeline.properties

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
#
2+
# Copyright 2011-2025 the original author or authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# https://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
117
# Java versions
218
java.main.tag=24.0.1_9-jdk-noble
319
java.next.tag=24.0.1_9-jdk-noble

ci/test.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
#!/bin/bash -x
2+
#
3+
# Copyright 2011-2025 the original author or authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
218

319
set -euo pipefail
420

etc/checkstyle/config.xml

Lines changed: 54 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,66 @@
11
<?xml version="1.0"?>
2-
<!DOCTYPE module PUBLIC
3-
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4-
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5-
6-
<module name="Checker">
7-
<!-- Most of them took inspiration from https://github.com/spring-io/spring-javaformat/blob/500ef15dc3dabb79298968d2d323ef3c4230fc44/src/checkstyle/checkstyle.xml -->
8-
9-
<property name="fileExtensions" value="java, properties, xml"/>
10-
11-
<module name="BeforeExecutionExclusionFileFilter">
12-
<property name="fileNamePattern" value="module\-info\.java$"/>
13-
</module>
14-
15-
<module name="RegexpHeader">
16-
<property name="headerFile" value="${checkstyle.header.file}" />
17-
<property name="fileExtensions" value="java" />
18-
</module>
19-
<module name="com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheck">
20-
<property name="lineSeparator" value="lf"/>
21-
</module>
22-
23-
<module name="NewlineAtEndOfFile"/>
24-
<module name="SuppressWarningsFilter" />
25-
26-
<module name="io.spring.nohttp.checkstyle.check.NoHttpCheck">
27-
<!-- XML requires double escaping, config gets XML-processed twice -->
28-
<property name="allowlist" value="http://www\.querydsl\.com.*&amp;#10;http://www\.prowaveconsulting\.com.*&amp;#10;http://www\.scispike\.com.*&amp;#10;http://.*.icu-project\.org.*" />
29-
</module>
30-
31-
<module name="com.puppycrawl.tools.checkstyle.TreeWalker">
32-
<module name="SuppressWarningsHolder" />
33-
34-
<!-- Coding -->
35-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.CovariantEqualsCheck" />
36-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EmptyStatementCheck" />
37-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.EqualsHashCodeCheck" />
38-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.InnerAssignmentCheck" />
39-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanExpressionCheck" />
40-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.SimplifyBooleanReturnCheck" />
41-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.StringLiteralEqualityCheck" />
42-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedForDepthCheck">
43-
<property name="max" value="3" />
44-
</module>
45-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedIfDepthCheck">
46-
<property name="max" value="4" />
47-
</module>
48-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.NestedTryDepthCheck">
49-
<property name="max" value="3" />
50-
</module>
51-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.MultipleVariableDeclarationsCheck" />
52-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.RequireThisCheck">
53-
<property name="checkMethods" value="false" />
54-
<property name="validateOnlyOverlapping" value="true" />
55-
</module>
56-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.HiddenFieldCheck">
57-
<property name="ignoreConstructorParameter" value="true" />
58-
<property name="ignoreSetter" value="true" />
59-
<property name="setterCanReturnItsClass" value="true" />
60-
</module>
61-
<module name="com.puppycrawl.tools.checkstyle.checks.coding.OneStatementPerLineCheck" />
62-
63-
<!-- Imports -->
64-
<module name="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStarImportCheck" />
65-
<module name="com.puppycrawl.tools.checkstyle.checks.imports.AvoidStaticImportCheck">
66-
<property name="excludes"
67-
value="org.neo4j.cypherdsl.core.Cypher.*, org.neo4j.cypherdsl.core.Functions.*, org.neo4j.cypherdsl.core.Conditions.*, org.neo4j.cypherdsl.core.Predicates.*, org.apiguardian.api.API.Status.*, org.assertj.core.api.Assertions.*, org.assertj.core.api.Assumptions.*, org.hamcrest.CoreMatchers.*, org.hamcrest.Matchers.*, org.mockito.Mockito.*, org.mockito.ArgumentMatchers.*" />
68-
</module>
69-
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
70-
<property name="regexp" value="true" />
71-
<property name="illegalPkgs"
72-
value="^sun.*, ^org\.apache\.commons\.(?!compress|dbcp2|lang|lang3|logging|pool2).*, ^com\.google\.common.*, ^org\.flywaydb\.core\.internal.*, ^org\.testcontainers\.shaded.*, ^org\.neo4j\.driver\.internal\.shaded.*, ^org\.slf4j.*, ^org\.jetbrains.*" />
73-
<property name="illegalClasses"
74-
value="^reactor\.core\.support\.Assert, ^org\.junit\.rules\.ExpectedException, ^org\.junit\.Test" />
75-
</module>
76-
<module name="com.puppycrawl.tools.checkstyle.checks.imports.RedundantImportCheck" />
77-
<module name="com.puppycrawl.tools.checkstyle.checks.imports.UnusedImportsCheck">
78-
<property name="processJavadoc" value="true" />
79-
</module>
2+
<!--
803
81-
<!-- Block Checks -->
82-
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck">
83-
<property name="option" value="text" />
84-
</module>
85-
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck" />
86-
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck" />
87-
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.NeedBracesCheck" />
88-
<module name="com.puppycrawl.tools.checkstyle.checks.blocks.AvoidNestedBlocksCheck" />
4+
Copyright 2011-2025 the original author or authors.
895
90-
<!-- Miscellaneous -->
91-
<module name="com.puppycrawl.tools.checkstyle.checks.indentation.CommentsIndentationCheck">
92-
<property name="tokens" value="BLOCK_COMMENT_BEGIN"/>
93-
</module>
94-
<module name="com.puppycrawl.tools.checkstyle.checks.UpperEllCheck" />
95-
<module name="com.puppycrawl.tools.checkstyle.checks.ArrayTypeStyleCheck" />
96-
<module name="com.puppycrawl.tools.checkstyle.checks.OuterTypeFilenameCheck" />
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
979
98-
<!-- Modifiers -->
99-
<module name="com.puppycrawl.tools.checkstyle.checks.modifier.RedundantModifierCheck" />
10+
https://www.apache.org/licenses/LICENSE-2.0
10011
101-
<!-- Regexp -->
102-
<module name="com.puppycrawl.tools.checkstyle.checks.regexp.RegexpCheck">
103-
<property name="format" value="[ \t]+$" />
104-
<property name="illegalPattern" value="true" />
105-
<property name="message" value="Trailing whitespace" />
106-
</module>
107-
108-
<!-- Whitespace -->
109-
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck" />
110-
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck" />
111-
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceAfterCheck" >
112-
<property name="tokens" value="BNOT, DEC, DOT, INC, LNOT, UNARY_MINUS, UNARY_PLUS, ARRAY_DECLARATOR"/>
113-
</module>
114-
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCheck" />
115-
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.ParenPadCheck" />
116-
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.TypecastParenPadCheck" />
117-
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck" />
118-
<module name="com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck">
119-
<property name="allowEmptyTypes" value="true" />
120-
<property name="allowEmptyConstructors" value="true" />
121-
<property name="allowEmptyMethods" value="true" />
122-
<property name="allowEmptyCatches" value="true" />
123-
</module>
124-
125-
<!-- We have some empty blocks and statements. -->
126-
<module name="SuppressionCommentFilter"/>
127-
128-
<!-- Java Doc-->
129-
<module name="AtclauseOrder" />
130-
<module name="JavadocType">
131-
<property name="scope" value="public"/>
132-
<property name="allowUnknownTags" value="true" />
133-
</module>
134-
135-
<module name="MissingJavadocType" />
136-
<module name="NonEmptyAtclauseDescription" />
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
13717
18+
-->
19+
<!DOCTYPE module PUBLIC
20+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
21+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
22+
<module name="com.puppycrawl.tools.checkstyle.Checker">
23+
<module name="io.spring.javaformat.checkstyle.SpringChecks">
24+
<property name="excludes" value="io.spring.javaformat.checkstyle.check.SpringAvoidStaticImportCheck"/>
25+
<property name="excludes" value="io.spring.javaformat.checkstyle.check.SpringHeaderCheck"/>
26+
<property name="excludes" value="io.spring.javaformat.checkstyle.check.SpringLambdaCheck"/>
27+
</module>
28+
<module name="NewlineAtEndOfFile"/>
29+
<module name="SuppressWarningsFilter"/>
30+
<module name="com.puppycrawl.tools.checkstyle.TreeWalker">
31+
<module name="SuppressWarningsHolder"/>
13832
<!-- System.outs -->
13933
<module name="Regexp">
14034
<property name="format" value="System\.out\.println"/>
14135
<property name="illegalPattern" value="true"/>
14236
</module>
143-
</module>
37+
38+
<module name="com.puppycrawl.tools.checkstyle.checks.imports.IllegalImportCheck">
39+
<property name="regexp" value="true"/>
40+
<property name="illegalClasses"
41+
value="
42+
org.jetbrains.annotations.NotNull,
43+
org.jetbrains.annotations.Nullable,
44+
org.springframework.lang.NonNull,
45+
org.springframework.lang.Nullable,
46+
org.springframework.lang.NonNullApi,
47+
org.springframework.lang.NonNullFields
48+
"/>
49+
</module>
50+
51+
<module name="io.spring.javaformat.checkstyle.check.SpringAvoidStaticImportCheck">
52+
<property
53+
name="excludes"
54+
value="
55+
com.github.stefanbirkner.systemlambda.SystemLambda.*,
56+
com.tngtech.archunit.base.DescribedPredicate.*,
57+
com.tngtech.archunit.core.domain.JavaClass.Predicates.*,
58+
com.tngtech.archunit.lang.conditions.ArchPredicates.*,
59+
com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*,
60+
org.neo4j.cypherdsl.core.Cypher.*,
61+
org.apiguardian.api.API.Status.*
62+
"
63+
/>
64+
</module>
65+
</module>
14466
</module>

0 commit comments

Comments
 (0)