Skip to content
Closed
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ Please note for this to work you should create/update user maven settings (typic
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
...
...
<servers>
...
<server>
Expand Down
24 changes: 24 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ subprojects {
apply plugin: 'checkstyle'
apply plugin: "com.github.spotbugs"
apply plugin: 'org.gradle.test-retry'
apply plugin: 'com.diffplug.spotless'

// We use the shadow plugin for the jmh-benchmarks module and the `-all` jar can get pretty large, so
// don't publish it
Expand Down Expand Up @@ -611,6 +612,26 @@ subprojects {
}
}

spotless {
java {
importOrder('kafka', 'org.apache.kafka', 'com', 'net', 'org', 'java', 'javax', '', '\\#')

// auto-format specified modules only; the list of auto-format modules will be updated incrementally.
if ([].contains(project.name)) {
target 'src/**/*.java'
} else {
target = project.files([])
}

eclipse('4.13.0').configFile("$rootDir/eclipse-formatter.xml")
indentWithSpaces()
trimTrailingWhitespace()
removeUnusedImports()

licenseHeaderFile file("$rootDir/checkstyle/java.header")
}
}

checkstyle {
configFile = new File(rootDir, "checkstyle/checkstyle.xml")
configProperties = checkstyleConfigProperties("import-control.xml")
Expand All @@ -622,6 +643,9 @@ subprojects {
description = 'Run checkstyle on all main Java sources'
}

checkstyleMain.dependsOn('spotlessApply')
checkstyleTest.dependsOn('spotlessApply')
Comment thread
dongjinleekr marked this conversation as resolved.
Outdated

configure(checkstyleTest) {
group = 'Verification'
description = 'Run checkstyle on all test Java sources'
Expand Down
7 changes: 7 additions & 0 deletions checkstyle/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@
<module name="UnusedImports">
<property name="processJavadoc" value="true" />
</module>
<module name="ImportOrder">
<property name="groups" value="kafka,org.apache.kafka,com,net,org,java,javax"/>
<property name="ordered" value="true"/>
<property name="separated" value="true"/>
<property name="option" value="bottom"/>
<property name="sortStaticImportsAlphabetically" value="true"/>
</module>
<module name="RedundantImport"/>
<module name="IllegalImport" />
<module name="EqualsHashCode"/>
Expand Down
73 changes: 59 additions & 14 deletions checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,15 @@
files="(FieldSpec|MessageDataGenerator).java"/>
<suppress id="dontUseSystemExit"
files="MessageGenerator.java"/>

<!-- core -->
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|FinalLocalVariable|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|AvoidStarImport)"
<suppress checks="(ImportOrder|AvoidStarImport)"
files="generator[\\/]src[\\/](main|test)[\\/].+.java$"/>
<suppress checks="(ImportOrder|AvoidStarImport)"
files="generator[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>

<!-- Core -->
<suppress checks="(ImportOrder|AvoidStarImport)"
files="core[\\/]src[\\/](main|test)[\\/].+.java$"/>
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|FinalLocalVariable|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|ImportOrder|AvoidStarImport)"
files="core[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>
<suppress checks="NPathComplexity" files="ClusterTestExtensions.java"/>

Expand Down Expand Up @@ -81,8 +87,10 @@
<suppress checks="(UnnecessaryParentheses|BooleanExpressionComplexity|CyclomaticComplexity|WhitespaceAfter|LocalVariableName)"
files="Murmur3.java"/>

<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|AvoidStarImport)"
files="clients[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>
<suppress checks="(ImportOrder|AvoidStarImport)"
files="clients[\\/]src[\\/](main|test)[\\/].+.java$"/>
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|ImportOrder|AvoidStarImport)"
files="clients[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>

<suppress checks="NPathComplexity"
files="MessageTest.java|OffsetFetchRequest.java"/>
Expand Down Expand Up @@ -135,7 +143,12 @@
<suppress checks="NPathComplexity"
files="(DistributedHerder|RestClient|RestServer|JsonConverter|KafkaConfigBackingStore|FileStreamSourceTask|TopicAdmin).java"/>

<!-- connect tests-->
<suppress checks="(ImportOrder|AvoidStarImport)"
files="connect.+[\\/]src[\\/](main|test)[\\/].+.java$"/>
<suppress checks="(ImportOrder|AvoidStarImport)"
files="connect.+[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>

<!-- Connect tests-->
<suppress checks="ClassDataAbstractionCoupling"
files="(DistributedHerder|KafkaBasedLog|WorkerSourceTaskWithTopicCreation|WorkerSourceTask)Test.java"/>

Expand All @@ -150,6 +163,10 @@
<suppress checks="JavaNCSS"
files="DistributedHerderTest.java"/>

<!-- Server-common -->
<suppress checks="(ImportOrder|AvoidStarImport)"
files="server-common[\\/]src[\\/](main|test)[\\/].+.java$"/>

<!-- Streams -->
<suppress checks="ClassFanOutComplexity"
files="(KafkaStreams|KStreamImpl|KTableImpl|StreamsPartitionAssignor).java"/>
Expand Down Expand Up @@ -182,13 +199,12 @@
<suppress checks="FinalLocalVariable"
files="^(?!.*[\\/]org[\\/]apache[\\/]kafka[\\/]streams[\\/].*$)"/>

<suppress checks="(ImportOrder|AvoidStarImport)"
files="streams[\\/]src[\\/](main|test)[\\/].+.java$"/>

<!-- Generated code -->
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|FinalLocalVariable|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|AvoidStarImport)"
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|FinalLocalVariable|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|ImportOrder|AvoidStarImport)"
files="streams[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|FinalLocalVariable|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|AvoidStarImport)"
files="raft[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|FinalLocalVariable|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|AvoidStarImport)"
files="storage[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>

<suppress checks="ImportControl" files="FetchResponseData.java"/>
<suppress checks="ImportControl" files="RecordsSerdeTest.java"/>
Expand Down Expand Up @@ -226,10 +242,18 @@
files="TopologyTestDriver.java"/>
<suppress checks="ClassDataAbstractionCoupling"
files="TopologyTestDriver.java"/>
<suppress checks="(ImportOrder|AvoidStarImport)"
files="streams[\\/]test-utils[\\/]src[\\/](main|test)[\\/].+.java$"/>

<!-- Streams examples -->
<suppress id="dontUseSystemExit"
files="PageViewTypedDemo.java|PipeDemo.java|TemperatureDemo.java|WordCountDemo.java|WordCountProcessorDemo.java|WordCountTransformerDemo.java"/>
<suppress checks="(ImportOrder|AvoidStarImport)"
files="examples[\\/]src[\\/](main|test)[\\/].+.java$"/>

<!-- Jmh-benchmarks -->
<suppress checks="(ImportOrder|AvoidStarImport)"
files="jmh-benchmarks[\\/]src[\\/](main|test)[\\/].+.java$"/>

<!-- Tools -->
<suppress checks="ClassDataAbstractionCoupling"
Expand All @@ -254,10 +278,18 @@
files="VerifiableConsumer.java"/>
<suppress id="dontUseSystemExit"
files="VerifiableProducer.java"/>
<suppress checks="(ImportOrder|AvoidStarImport)"
files="tools[\\/]src[\\/](main|test)[\\/].+.java$"/>

<!-- Trogdor -->
<suppress checks="(ImportOrder|AvoidStarImport)"
files="trogdor[\\/]src[\\/](main|test)[\\/].+.java$"/>

<!-- Shell -->
<suppress checks="CyclomaticComplexity"
files="(GlobComponent).java"/>
<suppress checks="(ImportOrder|AvoidStarImport)"
files="shell[\\/]src[\\/](main|test)[\\/].+.java$"/>

<!-- Log4J-Appender -->
<suppress checks="CyclomaticComplexity"
Expand All @@ -267,8 +299,10 @@
files="KafkaLog4jAppender.java"/>
<suppress checks="JavaNCSS"
files="RequestResponseTest.java"/>
<suppress checks="(ImportOrder|AvoidStarImport)"
files="log4j-appender[\\/]src[\\/](main|test)[\\/].+.java$"/>

<!-- metadata -->
<!-- Metadata -->
<suppress checks="ClassDataAbstractionCoupling"
files="(QuorumControllerTest|ReplicationControlManager|ReplicationControlManagerTest).java"/>
<suppress checks="ClassFanOutComplexity"
Expand All @@ -279,15 +313,26 @@
files="(ClientQuotasImage|ReplicationControlManager).java"/>
<suppress checks="NPathComplexity"
files="(ClientQuotasImage|KafkaEventQueue|ReplicationControlManager).java"/>
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|AvoidStarImport)"
<suppress checks="(ImportOrder|AvoidStarImport)"
files="metadata[\\/]src[\\/](main|test)[\\/].+.java$"/>
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|ImportOrder|AvoidStarImport)"
files="metadata[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>

<!-- Raft -->
<suppress checks="(ImportOrder|AvoidStarImport)"
files="raft[\\/]src[\\/](main|test)[\\/].+.java$"/>
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|FinalLocalVariable|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|ImportOrder|AvoidStarImport)"
files="raft[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>

<!-- Storage -->
<suppress checks="(ImportOrder|AvoidStarImport)"
files="storage[\\/]api[\\/]src[\\/](main|test)[\\/].+.java$"/>
<suppress checks="(NPathComplexity|ClassFanOutComplexity|CyclomaticComplexity|ClassDataAbstractionCoupling|FinalLocalVariable|LocalVariableName|MemberName|ParameterName|MethodLength|JavaNCSS|ImportOrder|AvoidStarImport)"
files="storage[\\/]api[\\/]src[\\/](generated|generated-test)[\\/].+.java$"/>
<suppress checks="(CyclomaticComplexity|ParameterNumber)"
files="(RemoteLogManagerConfig).java"/>

<!-- benchmarks -->
<suppress checks="ClassDataAbstractionCoupling"
files="(ReplicaFetcherThreadBenchmark).java"/>

</suppressions>
60 changes: 60 additions & 0 deletions eclipse-formatter.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
Comment thread
dongjinleekr marked this conversation as resolved.
Outdated
<!--
// 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.
-->
<profiles version="1">
<profile kind="CodeFormatterProfile" name="ApacheKafka" version="1">
<!-- Import ordering -->
Comment thread
dongjinleekr marked this conversation as resolved.
Outdated
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>

<!-- Line -->
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="200"/>
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="200"/>

<!-- Disable comment formatting -->
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="false"/>

<!-- Indentation -->
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="1"/>

<!-- Tabs -->
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>

<!-- Alignment -->
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="18"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="18"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>

<!-- Wrapping -->
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="false"/>
<setting id="org.eclipse.jdt.core.formatter.wrap_prefer_two_fragments" value="false"/>

<!-- No trailing spaces -->
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
Comment thread
dongjinleekr marked this conversation as resolved.
Outdated

<!-- No blank line at the end of the class -->
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
</profile>
</profiles>