Skip to content

Commit 05b2298

Browse files
janniklindemboehm7
authored andcommitted
[SYSTEMDS-3938] Java codestyle enforcing github action
Closes #2392.
1 parent 470bb0b commit 05b2298

File tree

16 files changed

+570
-17
lines changed

16 files changed

+570
-17
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#-------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
#
20+
#-------------------------------------------------------------
21+
22+
name: Java Codestyle
23+
24+
on:
25+
push:
26+
paths-ignore:
27+
- 'docs/**'
28+
- '*.md'
29+
- '*.html'
30+
- 'src/main/python/**'
31+
- 'dev/**'
32+
branches:
33+
- main
34+
pull_request:
35+
paths-ignore:
36+
- 'docs/**'
37+
- '*.md'
38+
- '*.html'
39+
- 'src/main/python/**'
40+
- 'dev/**'
41+
branches:
42+
- main
43+
44+
jobs:
45+
java_codestyle:
46+
name: Java Checkstyle
47+
runs-on: ubuntu-latest
48+
steps:
49+
- name: Checkout Repository
50+
uses: actions/checkout@v6
51+
52+
- name: Setup Java 17 adopt
53+
uses: actions/setup-java@v5
54+
with:
55+
distribution: adopt
56+
java-version: '17'
57+
cache: 'maven'
58+
59+
- name: Run Checkstyle
60+
run: mvn -ntp -B -Dcheckstyle.skip=false checkstyle:check

.github/workflows/javaTests.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,4 +181,3 @@ jobs:
181181
name: Java Code Coverage (Jacoco)
182182
path: target/site/jacoco
183183
retention-days: 3
184-

dev/checkstyle/checkstyle.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
-->
20+
21+
<!DOCTYPE module PUBLIC
22+
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
23+
"https://checkstyle.org/dtds/configuration_1_3.dtd">
24+
25+
<module name="Checker">
26+
<module name="SuppressionFilter">
27+
<property name="file" value="dev/checkstyle/suppressions.xml"/>
28+
</module>
29+
30+
<module name="TreeWalker">
31+
<!-- XPath-based suppressions (target specific AST patterns) -->
32+
<module name="SuppressionXpathFilter">
33+
<property name="file" value="dev/checkstyle/suppressions-xpath.xml"/>
34+
</module>
35+
36+
<module name="UnusedImports"/>
37+
<module name="RedundantImport"/>
38+
<module name="AvoidStarImport"/>
39+
<module name="IllegalImport"/>
40+
<module name="PackageName"/>
41+
<module name="TypeName"/>
42+
<!-- 1) Private fields must be _lowerCamelCase -->
43+
<!--<module name="MemberName">
44+
<property name="applyToPublic" value="false"/>
45+
<property name="applyToProtected" value="false"/>
46+
<property name="applyToPackage" value="false"/>
47+
<property name="applyToPrivate" value="true"/>
48+
49+
<property name="format" value="^_[a-z][a-zA-Z0-9]*$"/>
50+
</module>-->
51+
<!-- 2) Non-private fields must be lowerCamelCase (no leading underscore) -->
52+
<!--<module name="MemberName">
53+
<property name="applyToPublic" value="true"/>
54+
<property name="applyToProtected" value="false"/>
55+
<property name="applyToPackage" value="true"/>
56+
<property name="applyToPrivate" value="false"/>
57+
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
58+
</module>-->
59+
<module name="MethodName"/>
60+
<!--<module name="ParameterName"/>-->
61+
<module name="LocalVariableName">
62+
<property name="format"
63+
value="^[a-zA-Z][a-zA-Z0-9_]*$"/>
64+
</module>
65+
</module>
66+
67+
<!-- to detect leading spaces (should be tabs) -->
68+
<module name="RegexpMultiline">
69+
<property name="format"
70+
value="(?m)^( +)(?!\*)(?!//)(?!/\*)\S"/>
71+
<property name="message"
72+
value="Indentation must use tabs (no leading spaces)."/>
73+
</module>
74+
</module>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
-->
20+
21+
<!DOCTYPE suppressions PUBLIC
22+
"-//Checkstyle//DTD SuppressionXpathFilter Experimental Configuration 1.2//EN"
23+
"https://checkstyle.org/dtds/suppressions_1_2_xpath_experimental.dtd">
24+
25+
<suppressions>
26+
<!-- Suppress MemberName for private final fields -->
27+
<suppress-xpath
28+
checks="MemberNameCheck"
29+
query="//VARIABLE_DEF[
30+
./MODIFIERS/LITERAL_PRIVATE
31+
and ./MODIFIERS/FINAL
32+
]/IDENT"/>
33+
34+
<!-- Suppress MemberName for private static fields -->
35+
<suppress-xpath
36+
checks="MemberNameCheck"
37+
query="//VARIABLE_DEF[
38+
./MODIFIERS/LITERAL_PRIVATE
39+
and ./MODIFIERS/LITERAL_STATIC
40+
]/IDENT"/>
41+
</suppressions>

0 commit comments

Comments
 (0)