Skip to content

Commit 3c0e723

Browse files
author
Vincent Potucek
committed
ReplaceObsoletes
1 parent cd74920 commit 3c0e723

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/src/main/java/com/diffplug/spotless/generic/ReplaceObsoletesStep.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ public String format(String rawUnix, File file) throws Exception {
4949
"(public\\s+(?:String|\\w+)\\s+\\w+)\\s*=\\s*null",
5050
"$1");
5151

52+
// Remove = 0 from numeric fields (int, long, short, byte)
53+
result = result.replaceAll(
54+
"(public\\s+(?:int|long|short|byte)\\s+\\w+)\\s*=\\s*0(?:L)?\\s*;",
55+
"$1;");
56+
57+
// Remove = 0.0 from floating-point fields (float, double)
58+
result = result.replaceAll(
59+
"(public\\s+(?:float|double)\\s+\\w+)\\s*=\\s*0(?:\\.0)?(?:f|d)?\\s*;",
60+
"$1;");
61+
5262
return result;
5363
}
5464

0 commit comments

Comments
 (0)