You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To enforce checksyle conventions add the checkstyle plugin and include a dependency on `spring-javaformat-checkstyle`:
164
+
To enforce checkstyle conventions, add the checkstyle plugin and include a dependency on `spring-javaformat-checkstyle`:
165
165
166
166
[source,groovy,indent=0,subs="normal"]
167
167
----
@@ -208,9 +208,9 @@ java-baseline=8
208
208
The Eclipse plugin provides a custom formatter implementation and automatically applies project specific settings.
209
209
The plugin is automatically activated whenever the Maven or Gradle plugins are discovered in a project build script.
210
210
211
-
If you need to customize the project specific settings that the plugin applies you should add a `.eclipse` folder in the root of your project.
211
+
If you need to customize the project specific settings that the plugin applies, you should add a `.eclipse` folder in the root of your project.
212
212
All `.prefs` files from this folder will be copied to the project `.settings` folders.
213
-
Usually you'll provide your own `org.eclipse.jdt.core.prefs` and `org.eclipse.jdt.ui.prefs` files.
213
+
Usually, you'll provide your own `org.eclipse.jdt.core.prefs` and `org.eclipse.jdt.ui.prefs` files.
214
214
215
215
You can also add a `.eclipse/eclipse.properties` file to customize the following items:
216
216
@@ -232,7 +232,7 @@ The plugin is automatically activated whenever the Maven or Gradle plugins are d
232
232
A Spring Java Format icon (image:spring-javaformat-intellij-idea/spring-javaformat-intellij-idea-plugin/src/main/resources/spring-javaformat/formatOn.png[title="Icon"]) will also be displayed in the status bar to indicate the formatter is active.
233
233
You can use the standard `code` -> `reformat code` action to format the code.
234
234
235
-
To install the plugin use the `spring-javaformat-intellij-idea-plugin` jar file.
235
+
To install the plugin, use the `spring-javaformat-intellij-idea-plugin` jar file.
236
236
You can download the latest version from https://repo1.maven.org/maven2/io/spring/javaformat/spring-javaformat-intellij-idea-plugin/{release-version}[Maven Central].
237
237
238
238
@@ -275,24 +275,24 @@ Once the configuration file is created, configure your IDE to use it:
275
275
276
276
=== Visual Studio Code
277
277
The Visual Studio Code extension provides custom formatter support for Microsoft Visual Studio Code.
278
-
The extension using the https://code.visualstudio.com/api/references/vscode-api#DocumentFormattingEditProvider[`DocumentFormattingEditProvider`] API.
278
+
The extension uses the https://code.visualstudio.com/api/references/vscode-api#DocumentFormattingEditProvider[`DocumentFormattingEditProvider`] API.
279
279
Once installed it may be activated by using the "`Format Document`" action available in the editor context menu or from the Command Palette.
280
280
281
-
To install the extension select "`Install from VSIX`" in the extensions panel and choose the `spring-javaformat-vscode-extension` vsix file.
281
+
To install the extension, select "`Install from VSIX`" in the extensions panel and choose the `spring-javaformat-vscode-extension` vsix file.
282
282
You can download the latest version from https://repo1.maven.org/maven2/io/spring/javaformat/spring-javaformat-vscode-extension/{release-version}[Maven Central].
283
283
284
284
285
285
286
286
=== About the Conventions
287
-
Most of the coding conventions and style comes from the Spring Framework and Spring Boot projects.
288
-
Spring Framework manually formats code, where as Spring Boot uses automatic formatting.
287
+
Most of the coding conventions and style come from the Spring Framework and Spring Boot projects.
288
+
Spring Framework manually formats code, whereas Spring Boot uses automatic formatting.
289
289
290
290
291
291
292
292
=== Indenting With Spaces
293
-
By default tabs are used for indenting formatted code.
293
+
By default, tabs are used for indenting formatted code.
294
294
We strongly recommend that this default is not changed, especially for official Spring projects.
295
-
If, however, you feel that you can't live with tabs then switching to spaces is the one configuration option that we do support.
295
+
If, however, you feel that you can't live with tabs, switching to spaces is the one configuration option that we do support.
296
296
297
297
To use spaces rather than tabs, add a file called `.springjavaformatconfig` to the root of your project with the following content:
298
298
@@ -331,7 +331,7 @@ If you want most `SpringChecks` but need to exclude one or two, you can do somet
331
331
Some code isn't particularly amenable to automatic formatting.
332
332
For example, Spring Security configurations often work better when manually formatted.
333
333
334
-
If you need to disable formatting for a specific block of code you can enclose it in a `@formatter:off` / `@formatter:on` set:
334
+
If you need to disable formatting for a specific block of code, you can enclose it in a `@formatter:off` / `@formatter:on` set:
335
335
336
336
[source,java]
337
337
----
@@ -350,17 +350,17 @@ making use of available horizontal space in your IDE and avoiding unwanted addit
350
350
wrapping when viewing code on GitHub and the like.
351
351
352
352
If you're used to longer lines, 120 chars can take some getting used to. Specifically, if
353
-
you have many nesting levels things can start to look quite bad. Generally, if you see
354
-
code bunched up to the right of your screen you should take that as a signal to use the
353
+
you have many nesting levels, things can start to look quite bad. Generally, if you see
354
+
code bunched up to the right of your screen, you should take that as a signal to use the
355
355
"`extract method`" refactor. Extracting small private methods will improve formatting and
356
356
it helps when reading the code and debugging.
357
357
358
358
359
359
360
360
==== Whitespace
361
361
Keeping whitespace lines out of method bodies can help make the code easier to scan.
362
-
If blank lines are only included between methods it becomes easier to see the overall structure of the class.
363
-
If you find you need whitespace inside your method, consider if extracting a private method might give a better result.
362
+
If blank lines are only included between methods, it becomes easier to see the overall structure of the class.
363
+
If you find you need whitespace inside your method, consider whether extracting a private method might give a better result.
364
364
365
365
366
366
@@ -375,18 +375,18 @@ They will also ensure that `@author` tags are well formed.
375
375
376
376
==== Final
377
377
Private members should be `final` whenever possible.
378
-
Local variable and parameters should generally not be explicitly declared as final since it adds so much noise.
378
+
Local variables and parameters should generally not be explicitly declared as final since it adds so much noise.
379
379
380
380
381
381
382
382
==== Read-down Methods, Fields and Parameters
383
383
Methods don't need to be organized by scope.
384
384
There's no need to group all `private`, `protected` and `public` methods together.
385
-
Instead try to make your code easy to read when scanning the file from top to bottom.
386
-
In other words, try to have methods only reference method further down in the file.
385
+
Instead, try to make your code easy to read when scanning the file from top to bottom.
386
+
In other words, try to have methods only reference methods further down in the file.
387
387
Keep private methods as close to the thing that calls them as possible.
388
388
389
-
It's also recommend that you try to keep consistent ordering with fields and constructor parameters.
389
+
It's also recommended that you try to keep consistent ordering with fields and constructor parameters.
0 commit comments