Skip to content

Commit 140c634

Browse files
authored
Implementing Checkstyle (#208)
Motivation: To ensure code consistency and quality through the adoption of Checkstyle Modification: Added Checkstyle plugin and configuration, updated code to comply with new coding standards. Set version as INTERNAL on internal modules Result: Enhanced code quality and consistency across the project, facilitating easier contributions and maintenance.
1 parent 2192c24 commit 140c634

37 files changed

+382
-38
lines changed

.github/workflows/ci-integration-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
run: docker-compose -f ${{ github.workspace }}/containers/mysql-compose.yml up -d
3030
- name: Integration test with MySQL ${{ matrix.mysql-version }}
3131
run: |
32+
set -o pipefail
3233
./mvnw -B verify -Dmaven.javadoc.skip=true \
3334
-Dmaven.surefire.skip=true \
3435
-Dtest.mysql.password=r2dbc-password!@ \
@@ -37,5 +38,6 @@ jobs:
3738
-Dio.netty.leakDetectionLevel=paranoid \
3839
-Dio.netty.leakDetection.targetRecords=32 \
3940
| tee test.log
41+
set +o pipefail
4042
- name: ensure no leaks
4143
run: ./.github/scripts/ensure_no_leak.sh test.log

.github/workflows/ci-mariadb-intergration-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
run: docker-compose -f ${{ github.workspace }}/containers/mariadb-compose.yml up -d
3030
- name: Integration test with MySQL ${{ matrix.mysql-version }}
3131
run: |
32+
set -o pipefail
3233
./mvnw -B verify -Dmaven.javadoc.skip=true \
3334
-Dmaven.surefire.skip=true \
3435
-Dtest.mysql.password=r2dbc-password!@ \
@@ -39,5 +40,6 @@ jobs:
3940
-Dio.netty.leakDetectionLevel=paranoid \
4041
-Dio.netty.leakDetection.targetRecords=32 \
4142
| tee test.log
43+
set +o pipefail
4244
- name: ensure no leaks
4345
run: ./.github/scripts/ensure_no_leak.sh test.log

.github/workflows/ci-unit-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@ jobs:
2121
cache: maven
2222
- name: Unit test with Maven
2323
run: |
24+
set -o pipefail
2425
./mvnw -B test -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN \
2526
-Dio.netty.leakDetectionLevel=paranoid \
2627
-Dio.netty.leakDetection.targetRecords=32 \
2728
| tee test.log
29+
set +o pipefail
2830
- name: ensure no leaks
2931
run: ./.github/scripts/ensure_no_leak.sh test.log

build-tools/pom.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright 2024 asyncer.io projects
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ https://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
<groupId>io.asyncer</groupId>
23+
<artifactId>build-tools</artifactId>
24+
<version>INTERNAL</version>
25+
</project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE suppressions PUBLIC
3+
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
4+
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
5+
<suppressions>
6+
<suppress files="[/\\]target[/\\]" checks=".*"/>
7+
<suppress files="[/\\].mvn[/\\]" checks=".*"/>
8+
<suppress files="[/\\].idea[/\\]" checks=".*"/>
9+
<suppress files="[/\\].git[/\\]" checks=".*"/>
10+
</suppressions>
Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE module PUBLIC
3+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
4+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
5+
6+
<!--
7+
8+
Checkstyle configuration that checks the sun coding conventions from:
9+
10+
- the Java Language Specification at
11+
https://docs.oracle.com/javase/specs/jls/se11/html/index.html
12+
13+
- the Sun Code Conventions at https://www.oracle.com/java/technologies/javase/codeconventions-contents.html
14+
15+
- the Javadoc guidelines at
16+
https://www.oracle.com/technical-resources/articles/java/javadoc-tool.html
17+
18+
- the JDK Api documentation https://docs.oracle.com/en/java/javase/11/
19+
20+
- some best practices
21+
22+
Checkstyle is very configurable. Be sure to read the documentation at
23+
https://checkstyle.org (or in your downloaded distribution).
24+
25+
Most Checks are configurable, be sure to consult the documentation.
26+
27+
To completely disable a check, just comment it out or delete it from the file.
28+
To suppress certain violations please review suppression filters.
29+
30+
Finally, it is worth reading the documentation.
31+
32+
-->
33+
34+
<module name="Checker">
35+
<!--
36+
If you set the basedir property below, then all reported file
37+
names will be relative to the specified directory. See
38+
https://checkstyle.org/config.html#Checker
39+
40+
<property name="basedir" value="${basedir}"/>
41+
-->
42+
<property name="severity" value="error"/>
43+
44+
<property name="fileExtensions" value="java, properties, xml"/>
45+
46+
<!-- Excludes all 'module-info.java' files -->
47+
<!-- See https://checkstyle.org/filefilters/index.html -->
48+
<module name="BeforeExecutionExclusionFileFilter">
49+
<property name="fileNamePattern" value="module\-info\.java$"/>
50+
</module>
51+
52+
<!-- https://checkstyle.org/filters/suppressionfilter.html -->
53+
<module name="SuppressionFilter">
54+
<property name="file" value="${org.checkstyle.sun.suppressionfilter.config}"
55+
default="checkstyle-suppressions.xml"/>
56+
<property name="optional" value="true"/>
57+
</module>
58+
59+
<!-- Checks that a package-info.java file exists for each package. -->
60+
<!-- See https://checkstyle.org/checks/javadoc/javadocpackage.html#JavadocPackage -->
61+
<module name="JavadocPackage"/>
62+
63+
<!-- enables @SuppressWarning("checkstyle:xxxx") -->
64+
<module name="SuppressWarningsFilter" />
65+
66+
<!-- Checks whether files end with a new line. -->
67+
<!-- See https://checkstyle.org/checks/misc/newlineatendoffile.html -->
68+
<module name="NewlineAtEndOfFile"/>
69+
70+
<!-- Checks that property files contain the same keys. -->
71+
<!-- See https://checkstyle.org/checks/misc/translation.html -->
72+
<module name="Translation"/>
73+
74+
<!-- Checks for Size Violations. -->
75+
<!-- See https://checkstyle.org/checks/sizes/index.html -->
76+
<module name="FileLength"/>
77+
<module name="LineLength">
78+
<property name="max" value="120"/>
79+
<property name="fileExtensions" value="java"/>
80+
</module>
81+
82+
<!-- Checks for whitespace -->
83+
<!-- See https://checkstyle.org/checks/whitespace/index.html -->
84+
<module name="FileTabCharacter"/>
85+
86+
<!-- Miscellaneous other checks. -->
87+
<!-- See https://checkstyle.org/checks/misc/index.html -->
88+
<module name="RegexpSingleline">
89+
<property name="format" value="\s+$"/>
90+
<property name="minimum" value="0"/>
91+
<property name="maximum" value="0"/>
92+
<property name="message" value="Line has trailing spaces."/>
93+
</module>
94+
95+
<!-- Checks for Headers -->
96+
<!-- See https://checkstyle.org/checks/header/index.html -->
97+
<!-- <module name="Header"> -->
98+
<!-- <property name="headerFile" value="${checkstyle.header.file}"/> -->
99+
<!-- <property name="fileExtensions" value="java"/> -->
100+
<!-- </module> -->
101+
102+
<module name="RegexpSingleline">
103+
<property name="format" value="^(\s|\*|#)*Copyright\s+[0-9]+\s+asyncer.io projects\s*$"/>
104+
<property name="message" value="license header missing"/>
105+
<property name="minimum" value="1"/>
106+
<property name="maximum" value="1"/>
107+
</module>
108+
109+
110+
<module name="TreeWalker">
111+
112+
<!-- Checks for Javadoc comments. -->
113+
<!-- See https://checkstyle.org/checks/javadoc/index.html -->
114+
<module name="InvalidJavadocPosition"/>
115+
<module name="JavadocStyle">
116+
<property name="checkFirstSentence" value="false"/>
117+
</module>
118+
119+
<!-- enables @SuppressWarning("checkstyle:xxxx") -->
120+
<module name="SuppressWarningsHolder" />
121+
<!-- <module name="MissingJavadocMethod"/>-->
122+
123+
<!-- Checks for Naming Conventions. -->
124+
<!-- See https://checkstyle.org/checks/naming/index.html -->
125+
<!-- <module name="ConstantName"/>-->
126+
<module name="LocalFinalVariableName"/>
127+
<module name="LocalVariableName"/>
128+
<module name="MemberName"/>
129+
<module name="MethodName"/>
130+
<module name="PackageName"/>
131+
<module name="ParameterName"/>
132+
<module name="StaticVariableName"/>
133+
<module name="TypeName"/>
134+
135+
<!-- Checks for imports -->
136+
<!-- See https://checkstyle.org/checks/imports/index.html -->
137+
<module name="AvoidStarImport"/>
138+
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
139+
<module name="RedundantImport"/>
140+
<module name="UnusedImports">
141+
<property name="processJavadoc" value="true"/>
142+
</module>
143+
144+
<!-- Checks for Size Violations. -->
145+
<!-- See https://checkstyle.org/checks/sizes/index.html -->
146+
<!-- <module name="MethodLength"/>-->
147+
<!-- <module name="ParameterNumber"/>-->
148+
149+
<!-- Checks for whitespace -->
150+
<!-- See https://checkstyle.org/checks/whitespace/index.html -->
151+
<module name="EmptyForIteratorPad"/>
152+
<module name="GenericWhitespace"/>
153+
<module name="MethodParamPad"/>
154+
<module name="ParenPad"/>
155+
<module name="TypecastParenPad"/>
156+
<module name="WhitespaceAfter"/>
157+
<module name="WhitespaceAround"/>
158+
159+
<!-- Modifier Checks -->
160+
<!-- See https://checkstyle.org/checks/modifier/index.html -->
161+
<module name="ModifierOrder"/>
162+
<module name="RedundantModifier"/>
163+
164+
<!-- Checks for blocks. You know, those {}'s -->
165+
<!-- See https://checkstyle.org/checks/blocks/index.html -->
166+
<module name="AvoidNestedBlocks">
167+
<property name="allowInSwitchCase" value="true"/>
168+
</module>
169+
<module name="EmptyBlock"/>
170+
<module name="LeftCurly"/>
171+
<module name="NeedBraces"/>
172+
<module name="RightCurly"/>
173+
174+
<!-- Checks for common coding problems -->
175+
<!-- See https://checkstyle.org/checks/coding/index.html -->
176+
<module name="EmptyStatement"/>
177+
<module name="EqualsHashCode"/>
178+
<module name="IllegalInstantiation"/>
179+
<module name="SimplifyBooleanExpression"/>
180+
<module name="SimplifyBooleanReturn"/>
181+
182+
<!-- Checks for class design -->
183+
<!-- See https://checkstyle.org/checks/design/index.html -->
184+
<module name="DesignForExtension"/>
185+
<module name="FinalClass"/>
186+
<module name="HideUtilityClassConstructor"/>
187+
<module name="InterfaceIsType"/>
188+
189+
<!-- Miscellaneous other checks. -->
190+
<!-- See https://checkstyle.org/checks/misc/index.html -->
191+
<module name="ArrayTypeStyle"/>
192+
<!-- <module name="FinalParameters"/>-->
193+
<!-- <module name="TodoComment"/>-->
194+
<module name="UpperEll"/>
195+
196+
<!-- https://checkstyle.org/filters/suppressionxpathfilter.html -->
197+
<module name="SuppressionXpathFilter">
198+
<property name="file" value="${org.checkstyle.sun.suppressionxpathfilter.config}"
199+
default="checkstyle-xpath-suppressions.xml"/>
200+
<property name="optional" value="true"/>
201+
</module>
202+
</module>
203+
</module>

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
<modelVersion>4.0.0</modelVersion>
2020
<groupId>io.asyncer</groupId>
2121
<artifactId>r2dbc-mysql-parent</artifactId>
22-
<version>1.1.2-SNAPSHOT</version>
22+
<version>INTERNAL</version>
2323
<packaging>pom</packaging>
2424

2525
<modules>
2626
<module>r2dbc-mysql</module>
2727
<module>test-native-image</module>
28+
<module>build-tools</module>
2829
</modules>
2930
</project>

r2dbc-mysql/pom.xml

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<!--
3+
~ Copyright 2024 asyncer.io projects
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ https://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
-->
17+
<project xmlns="http://maven.apache.org/POM/4.0.0"
18+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
19+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
320
<modelVersion>4.0.0</modelVersion>
421

522
<groupId>io.asyncer</groupId>
@@ -257,6 +274,34 @@
257274

258275
<build>
259276
<plugins>
277+
<plugin>
278+
<groupId>org.apache.maven.plugins</groupId>
279+
<artifactId>maven-checkstyle-plugin</artifactId>
280+
<version>3.3.1</version>
281+
<executions>
282+
<execution>
283+
<id>validate</id>
284+
<phase>validate</phase>
285+
<configuration>
286+
<configLocation>io/asyncer/checkstyle.xml</configLocation>
287+
<suppressionsLocation>io/asyncer/checkstyle-suppressions.xml</suppressionsLocation>
288+
<consoleOutput>true</consoleOutput>
289+
<failsOnError>true</failsOnError>
290+
<failOnViolation>true</failOnViolation>
291+
</configuration>
292+
<goals>
293+
<goal>check</goal>
294+
</goals>
295+
</execution>
296+
</executions>
297+
<dependencies>
298+
<dependency>
299+
<groupId>io.asyncer</groupId>
300+
<artifactId>build-tools</artifactId>
301+
<version>INTERNAL</version>
302+
</dependency>
303+
</dependencies>
304+
</plugin>
260305
<plugin>
261306
<groupId>org.apache.maven.plugins</groupId>
262307
<artifactId>maven-compiler-plugin</artifactId>

r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/ColumnDefinition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public int hashCode() {
140140

141141
@Override
142142
public String toString() {
143-
return "ColumnDefinition<0x" + Integer.toHexString(bitmap) + ", 0x" + Integer.toHexString(collationId)+ '>';
143+
return "ColumnDefinition<0x" + Integer.toHexString(bitmap) + ", 0x" + Integer.toHexString(collationId) + '>';
144144
}
145145

146146
/**

r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/MySqlBatch.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
public abstract class MySqlBatch implements Batch {
2626

2727
@Override
28-
abstract public MySqlBatch add(String sql);
28+
public abstract MySqlBatch add(String sql);
2929

3030
@Override
31-
abstract public Flux<MySqlResult> execute();
31+
public abstract Flux<MySqlResult> execute();
3232
}

0 commit comments

Comments
 (0)