Skip to content

Commit 2a2fdcc

Browse files
committed
Parse more checkstyle rules into OpenRewrite styles.
Also correct a few defaults which were wrong according to checkstyle's documentation.
1 parent 69d2da8 commit 2a2fdcc

6 files changed

Lines changed: 1401 additions & 233 deletions

File tree

rewrite-core/src/main/java/org/openrewrite/style/Style.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ default String getJacksonPolymorphicTypeTag() {
3939
}
4040

4141
default Style merge(Style lowerPrecedence) {
42-
return this;
42+
return StyleHelper.merge(lowerPrecedence, this);
4343
}
4444

4545
default Style applyDefaults() { return this; }

rewrite-java/src/main/java/org/openrewrite/java/style/Checkstyle.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,11 @@ public static DefaultComesLastStyle defaultComesLast() {
7272
return new DefaultComesLastStyle(false);
7373
}
7474

75-
public static final EmptyBlockStyle.BlockPolicy defaultBlockPolicy = EmptyBlockStyle.BlockPolicy.TEXT;
75+
// https://checkstyle.sourceforge.io/checks/blocks/emptyblock.html
76+
public static final EmptyBlockStyle.BlockPolicy defaultBlockPolicy = EmptyBlockStyle.BlockPolicy.STATEMENT;
7677

7778
public static EmptyBlockStyle emptyBlock() {
78-
return new EmptyBlockStyle(EmptyBlockStyle.BlockPolicy.TEXT, true, true, true, true,
79+
return new EmptyBlockStyle(EmptyBlockStyle.BlockPolicy.STATEMENT, true, true, true, true,
7980
true, true, true, true, true, true, true, true);
8081
}
8182

@@ -107,9 +108,10 @@ public static NeedBracesStyle needBracesStyle() {
107108
return new NeedBracesStyle(false, false);
108109
}
109110

111+
// https://checkstyle.sourceforge.io/checks/whitespace/nowhitespaceafter.html
110112
public static NoWhitespaceAfterStyle noWhitespaceAfterStyle() {
111113
return new NoWhitespaceAfterStyle(true, false, false, true, true, true,
112-
true, false, true, true, true, true, true, true);
114+
true, true, true, true, true, true, true, true);
113115
}
114116

115117
public static NoWhitespaceBeforeStyle noWhitespaceBeforeStyle() {

0 commit comments

Comments
 (0)