Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/javaCodestyle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#-------------------------------------------------------------
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
#-------------------------------------------------------------

name: Java Codestyle

on:
push:
paths-ignore:
- 'docs/**'
- '*.md'
- '*.html'
- 'src/main/python/**'
- 'dev/**'
branches:
- main
pull_request:
paths-ignore:
- 'docs/**'
- '*.md'
- '*.html'
- 'src/main/python/**'
- 'dev/**'
branches:
- main

jobs:
java_codestyle:
name: Java Checkstyle
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v6

- name: Setup Java 17 adopt
uses: actions/setup-java@v5
with:
distribution: adopt
java-version: '17'
cache: 'maven'

- name: Run Checkstyle
run: mvn -ntp -B -Dcheckstyle.skip=false checkstyle:check
1 change: 0 additions & 1 deletion .github/workflows/javaTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,4 +181,3 @@ jobs:
name: Java Code Coverage (Jacoco)
path: target/site/jacoco
retention-days: 3

74 changes: 74 additions & 0 deletions dev/checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->

<!DOCTYPE module PUBLIC
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
"https://checkstyle.org/dtds/configuration_1_3.dtd">

<module name="Checker">
<module name="SuppressionFilter">
<property name="file" value="dev/checkstyle/suppressions.xml"/>
</module>

<module name="TreeWalker">
<!-- XPath-based suppressions (target specific AST patterns) -->
<module name="SuppressionXpathFilter">
<property name="file" value="dev/checkstyle/suppressions-xpath.xml"/>
</module>

<module name="UnusedImports"/>
<module name="RedundantImport"/>
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="PackageName"/>
<module name="TypeName"/>
<!-- 1) Private fields must be _lowerCamelCase -->
<!--<module name="MemberName">
<property name="applyToPublic" value="false"/>
<property name="applyToProtected" value="false"/>
<property name="applyToPackage" value="false"/>
<property name="applyToPrivate" value="true"/>

<property name="format" value="^_[a-z][a-zA-Z0-9]*$"/>
</module>-->
<!-- 2) Non-private fields must be lowerCamelCase (no leading underscore) -->
<!--<module name="MemberName">
<property name="applyToPublic" value="true"/>
<property name="applyToProtected" value="false"/>
<property name="applyToPackage" value="true"/>
<property name="applyToPrivate" value="false"/>
<property name="format" value="^[a-z][a-zA-Z0-9]*$"/>
</module>-->
<module name="MethodName"/>
<!--<module name="ParameterName"/>-->
<module name="LocalVariableName">
<property name="format"
value="^[a-zA-Z][a-zA-Z0-9_]*$"/>
</module>
</module>

<!-- to detect leading spaces (should be tabs) -->
<module name="RegexpMultiline">
<property name="format"
value="(?m)^( +)(?!\*)(?!//)(?!/\*)\S"/>
<property name="message"
value="Indentation must use tabs (no leading spaces)."/>
</module>
</module>
41 changes: 41 additions & 0 deletions dev/checkstyle/suppressions-xpath.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0"?>
<!--
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
-->

<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionXpathFilter Experimental Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2_xpath_experimental.dtd">

<suppressions>
<!-- Suppress MemberName for private final fields -->
<suppress-xpath
checks="MemberNameCheck"
query="//VARIABLE_DEF[
./MODIFIERS/LITERAL_PRIVATE
and ./MODIFIERS/FINAL
]/IDENT"/>

<!-- Suppress MemberName for private static fields -->
<suppress-xpath
checks="MemberNameCheck"
query="//VARIABLE_DEF[
./MODIFIERS/LITERAL_PRIVATE
and ./MODIFIERS/LITERAL_STATIC
]/IDENT"/>
</suppressions>
Loading
Loading