feat: configure Eclipse formatter for Spotless#571
Conversation
1547ca1 to
2783a95
Compare
2783a95 to
2561a3a
Compare
:java_duke: JaCoCo coverage report
|
|
||||||||||||||
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
There was a problem hiding this comment.
Thanks for this @swetasamasti2310 !
See specific comments below.
Note that just running spotlessCheck or spotlessApply won't do anything unless there is a file which has changed. Spotless only looks at files that have changed status, so if you want to see what the rules are doing then you have to modify some files (add a blank line somewhere in a file will work).
One general comment I found when I tried this out. When I changed a file and re-ran spotlessApply I noticed that some enums got messed up:
Before
public enum ContentLayer {
@JsonProperty("body") BODY,
@JsonProperty("furniture") FURNITURE,
@JsonProperty("background") BACKGROUND,
@JsonProperty("invisible") INVISIBLE,
@JsonProperty("notes") NOTES
}
public enum GroupLabel {
@JsonProperty("unspecified") UNSPECIFIED,
@JsonProperty("list") LIST,
@JsonProperty("ordered_list") ORDERED_LIST,
@JsonProperty("chapter") CHAPTER,
@JsonProperty("section") SECTION,
@JsonProperty("sheet") SHEET,
@JsonProperty("slide") SLIDE,
@JsonProperty("form_area") FORM_AREA,
@JsonProperty("key_value_area") KEY_VALUE_AREA,
@JsonProperty("comment_section") COMMENT_SECTION,
@JsonProperty("inline") INLINE,
@JsonProperty("picture_area") PICTURE_AREA
}After
public enum ContentLayer {
@JsonProperty("body") BODY, @JsonProperty("furniture") FURNITURE, @JsonProperty("background") BACKGROUND, @JsonProperty("invisible") INVISIBLE, @JsonProperty("notes") NOTES
}
public enum GroupLabel {
@JsonProperty("unspecified") UNSPECIFIED, @JsonProperty("list") LIST, @JsonProperty("ordered_list") ORDERED_LIST, @JsonProperty("chapter") CHAPTER, @JsonProperty("section") SECTION, @JsonProperty("sheet") SHEET, @JsonProperty("slide") SLIDE, @JsonProperty("form_area") FORM_AREA, @JsonProperty("key_value_area") KEY_VALUE_AREA, @JsonProperty("comment_section") COMMENT_SECTION, @JsonProperty("inline") INLINE, @JsonProperty("picture_area") PICTURE_AREA
}Is there a way to ensure that enums constants stay on individual lines?
I also noticed that when I have chained items, like this:
request.headers()
.map()
.entrySet()
.stream()
.map(this::maskSensitiveHeaderValues)
.forEach(entry -> stringBuilder.append(" %s: %s\n".formatted(entry.getKey(), String.join(", ", entry.getValue())))
);after re-running spotlessApply they get shrunk to a single line
request.headers().map().entrySet().stream().map(this::maskSensitiveHeaderValues).forEach(entry -> stringBuilder.append(" %s: %s\n".formatted(entry.getKey(), String.join(", ", entry.getValue())))
);Is there a way to turn that off?
2561a3a to
734c451
Compare
@edeandrea Earlier I tested with code change only but I didn't change for all the settings. Now I have done changes for these also i.e. Enum and chained items also. In addition to this settings. I have also changed other settings trying to make as similar as possible to the settings given in .editorConfig. Tested for each scenario with code changes. |
- Updated Eclipse formatter XML to match .editorconfig - Changed indentation from 4 to 2 spaces - Changed line length from 120 to 180 characters - Enabled new lines before else/catch/finally Resolves docling-project#378 Signed-off-by: swetasamasti2310 <swetagupta2310@gmail.com>
- Added eclipse().configFile() to use Eclipse formatter XML - Added removeUnusedImports() to clean up imports - Added trimTrailingWhitespace() for whitespace cleanup - Added endWithNewline() to ensure files end with newline Signed-off-by: swetasamasti2310 <swetagupta2310@gmail.com>
734c451 to
17fc4e7
Compare
|
HTML test reports are available as workflow artifacts (zipped HTML). • Download: Artifacts for this run |
|
Thanks @swetasamasti2310 This may not be the behavior of the current @JsonProperty("children")
@JsonSetter(
nulls = Nulls.AS_EMPTY)
@lombok.Singular("child")
private List<RefItem> children;Should be this? @JsonProperty("children")
@JsonSetter(nulls = Nulls.AS_EMPTY)
@lombok.Singular("child")
private List<RefItem> children;The carriage return in the annotation parameter - there shouldn't be a preceding carriage return. Similar with try & catch blocks: try (
InputStream is = (InputStream) body) {
body = new String(is.readAllBytes(), StandardCharsets.UTF_8);
}
catch (
IOException
| InterruptedException e) {
throw new DoclingServeClientException(e);
}should be try (InputStream is = (InputStream) body) {
body = new String(is.readAllBytes(), StandardCharsets.UTF_8);
}
catch (IOException | InterruptedException e) {
throw new DoclingServeClientException(e);
}During a cast, there should also be an extra space return (T) StreamResponse
.body((InputStream)body)should be |
Title: feat: configure Eclipse formatter for Spotless
Description:
Changes
Testing
./gradlew spotlessApply- formatting works correctly./gradlew spotlessCheck- all checks passResolves #378