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
or use the https://dl.bintray.com/spring/javaformat-eclipse/[update site].
184
184
185
-
### IntelliJ IDEA
185
+
=== IntelliJ IDEA
186
186
The IntelliJ plugin provides custom formatter support for IDEA.
187
187
The plugin is automatically activated whenever the Maven or Gradle plugins are discovered in a project build script.
188
188
A Spring Java Format icon (image:spring-javaformat-intellij/spring-javaformat-intellij-plugin/src/main/resources/spring-javaformat/formatOn.png[title="Icon"]) will also be displayed in the status bar to indicate the formatter is active.
@@ -191,39 +191,39 @@ You can use the standard `code` -> `reformat code` action to format the code.
191
191
To install the plugin use the `spring-javaformat-intellij-plugin` jar file.
192
192
You can download the latest version from https://repo.spring.io/release/io/spring/javaformat/spring-javaformat-intellij-plugin/{release-version}[repo.spring.io].
193
193
194
-
### About the conventions
194
+
=== About the conventions
195
195
Most of the coding conventions and style comes from the Spring Framework and Spring Boot projects.
196
196
Spring Framework manually formats code, where as Spring Boot uses automatic formatting.
197
197
198
-
### Tips
198
+
=== Tips
199
199
Formatting and Checkstyle alone are not enough to produce truly consistent code.
200
200
Here are some tips that we've found useful when developing Spring Boot.
201
201
202
-
#### Wrapping
202
+
==== Wrapping
203
203
The source formatter intentionally uses a low character count of 90 chars for wrapping.
204
204
If you're used to longer lines, this can take some getting used to.
205
205
Specifically, if you have many nesting levels things can start to look quite bad.
206
206
207
207
Generally, if you see code bunched up to the right of your screen you should take that as a signal to use the "`extract method`" refactor.
208
208
Extracting small private methods will improve formatting and it helps when reading the code and debugging.
209
209
210
-
#### Whitespace
210
+
==== Whitespace
211
211
Keeping whitespace lines out method bodies can help make the code easier to scan.
212
212
If blank lines are only included between methods it becomes easier to see the overall structure of the class.
213
213
If you find you need whitespace inside your method, consider if extracting a private method might give a better result.
214
214
215
-
#### Comments
215
+
==== Comments
216
216
Try to add javadoc for each public method and constant.
217
217
Private methods shouldn't generally need javadoc, unless it provides a natural place to document unusual behavior.
218
218
219
219
The checkstyle rules will enforce that all public classes have javadoc.
220
220
They will also ensure that `@author` tags are well formed.
221
221
222
-
#### Final
222
+
==== Final
223
223
Private members should be `final` whenever possible.
224
224
Local variable and parameters should generally not be explicitly declared as final since it adds so much noise.
225
225
226
-
#### Read-down methods, fields and parameters
226
+
==== Read-down methods, fields and parameters
227
227
Methods don't need to be organized by scope.
228
228
There's no need to group all `private`, `protected` and `public` methods together.
229
229
Instead try to make your code easy to read when scanning the file from top to bottom.
0 commit comments