Skip to content

Commit 2b8828d

Browse files
committed
Add checkstyle to imgui-binding and make everything compliant to Java codestyle
1 parent 3f7698f commit 2b8828d

File tree

20 files changed

+1734
-1672
lines changed

20 files changed

+1734
-1672
lines changed

config/checkstyle/checkstyle.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
<!-- Suppress warnings by using -->
9292
<module name="SuppressWarningsFilter"/>
9393

94+
<module name="SuppressionFilter">
95+
<property name="file" value="${config_loc}/suppressions.xml" />
96+
</module>
97+
9498
<module name="TreeWalker">
9599

96100
<!-- Checks for Javadoc comments. -->
@@ -160,7 +164,10 @@
160164
<!-- See https://checkstyle.org/config_coding.html -->
161165
<module name="EmptyStatement"/>
162166
<module name="EqualsHashCode"/>
163-
<module name="HiddenField"/>
167+
<module name="HiddenField" >
168+
<property name="ignoreSetter" value="true" />
169+
<property name="ignoreConstructorParameter" value="true" />
170+
</module>
164171
<module name="IllegalInstantiation"/>
165172
<module name="InnerAssignment"/>
166173
<module name="MagicNumber"/>
@@ -178,11 +185,11 @@
178185
<module name="VisibilityModifier"/>
179186

180187
<!-- Miscellaneous other checks. -->
181-
<!-- See https://checkstyle.org/config_misc.html -->
188+
<!-- See https://checkstyle.org/config_misc.html -->
182189
<module name="ArrayTypeStyle"/>
183190
<module name="FinalParameters"/>
184191
<module name="FinalLocalVariable"/>
185-
<module name="TodoComment"/>
192+
<!-- <module name="TodoComment"/> -->
186193
<module name="UpperEll"/>
187194

188195
<!-- See https://checkstyle.sourceforge.io/config_annotation.html#SuppressWarningsHolder -->

config/checkstyle/suppressions.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0"?>
2+
3+
<!DOCTYPE suppressions PUBLIC
4+
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
5+
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
6+
7+
<suppressions>
8+
<suppress checks="MagicNumber" files="[\\/]imgui[\\/]"/>
9+
<suppress checks="LineLength" files="[\\/]imgui[\\/]"/>
10+
<suppress checks="ConstantName" files="[\\/]imgui[\\/]"/>
11+
<suppress checks="VisibilityModifier" files="[\\/]imgui[\\/]"/>
12+
<suppress checks="ParameterNumber" files="[\\/]imgui[\\/]"/>
13+
<suppress checks="FileLength" files="[\\/]imgui[\\/]"/>
14+
<suppress checks="FinalParameters" files="ImGui.java"/>
15+
</suppressions>

imgui-binding/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import imgui.generate.GenerateLibs
22

33
plugins {
44
id 'java'
5+
id 'checkstyle'
56
id 'com.jfrog.bintray' version '1.8.4'
67
id 'maven-publish'
78
}

imgui-binding/src/main/java/imgui/ImBool.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
import java.util.Objects;
44

55
public final class ImBool {
6-
boolean[] data = new boolean[]{false};
6+
final boolean[] data = new boolean[]{false};
77

88
public ImBool() {
99
}
1010

11-
public ImBool(boolean value) {
11+
public ImBool(final boolean value) {
1212
data[0] = value;
1313
}
1414

1515
public boolean get() {
1616
return data[0];
1717
}
1818

19-
public void set(boolean value) {
19+
public void set(final boolean value) {
2020
data[0] = value;
2121
}
2222

@@ -26,10 +26,14 @@ public String toString() {
2626
}
2727

2828
@Override
29-
public boolean equals(Object o) {
30-
if (this == o) return true;
31-
if (o == null || getClass() != o.getClass()) return false;
32-
ImBool imBool = (ImBool) o;
29+
public boolean equals(final Object o) {
30+
if (this == o) {
31+
return true;
32+
}
33+
if (o == null || getClass() != o.getClass()) {
34+
return false;
35+
}
36+
final ImBool imBool = (ImBool) o;
3337
return data[0] == imBool.data[0];
3438
}
3539

imgui-binding/src/main/java/imgui/ImDouble.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
import java.util.Objects;
44

55
public final class ImDouble {
6-
double[] data = new double[]{0.0d};
6+
final double[] data = new double[]{0.0d};
77

88
public ImDouble() {
99
}
1010

11-
public ImDouble(double value) {
11+
public ImDouble(final double value) {
1212
set(value);
1313
}
1414

1515
public double get() {
1616
return this.data[0];
1717
}
1818

19-
public void set(double value) {
19+
public void set(final double value) {
2020
this.data[0] = value;
2121
}
2222

@@ -26,10 +26,14 @@ public String toString() {
2626
}
2727

2828
@Override
29-
public boolean equals(Object o) {
30-
if (this == o) return true;
31-
if (o == null || getClass() != o.getClass()) return false;
32-
ImDouble imDouble = (ImDouble) o;
29+
public boolean equals(final Object o) {
30+
if (this == o) {
31+
return true;
32+
}
33+
if (o == null || getClass() != o.getClass()) {
34+
return false;
35+
}
36+
final ImDouble imDouble = (ImDouble) o;
3337
return data[0] == imDouble.data[0];
3438
}
3539

imgui-binding/src/main/java/imgui/ImDrawData.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
* BINDING NOTICE: DO NOT TRY TO MODIFY FIELDS OF THIS CLASS MANUALLY! You should only access their values after {@link ImGui#Render()} call.
1010
*/
1111
public final class ImDrawData {
12-
public static int V_BUFFER_SIZE = (4 + 1) * 4;
13-
public static int I_BUFFER_SIZE = 2;
14-
public static int CMD_BUFFER_SIZE = (1 + 4 + 1) * 4;
12+
public static final int V_BUFFER_SIZE = (4 + 1) * 4;
13+
public static final int I_BUFFER_SIZE = 2;
14+
public static final int CMD_BUFFER_SIZE = (1 + 4 + 1) * 4;
1515

1616
public ByteBuffer vByteBuffer;
1717
public ByteBuffer iByteBuffer;
@@ -37,7 +37,7 @@ public final class ImDrawData {
3737
public float framebufferScaleX;
3838
public float framebufferScaleY;
3939

40-
ImDrawData(int maxVertices, int maxIndices, int maxCmd) {
40+
ImDrawData(final int maxVertices, final int maxIndices, final int maxCmd) {
4141
vByteBuffer = ByteBuffer.allocateDirect(maxVertices * V_BUFFER_SIZE).order(ByteOrder.nativeOrder());
4242
iByteBuffer = ByteBuffer.allocateDirect(maxIndices * I_BUFFER_SIZE).order(ByteOrder.nativeOrder());
4343
cmdByteBuffer = ByteBuffer.allocateDirect(maxCmd * CMD_BUFFER_SIZE).order(ByteOrder.nativeOrder());

0 commit comments

Comments
 (0)