Skip to content

Conversation

@Praveen7294
Copy link
Contributor

@Praveen7294 Praveen7294 commented Jul 8, 2025

Fixes #23079

Motivation

To improve code quality and maintainability, I resolved all existing Checkstyle violations in the codebase. This ensures consistent coding standards across modules, reduces CI noise, and creates a cleaner environment for contributors. It also helps streamline future development and reviews by eliminating style-related distractions.

Modifications

Fixed all Checkstyle violations in the test directories of the Apache Pulsar repository. The changes address issues related to ImportOrder, extra blank lines between import statements, LineLength, StaticVariableName, ClassName, MethodName, FileTabCharacter, RegexpSingleline, and other style checks. This ensures cleaner, consistent, and CI-compliant test code throughout the project.

Verifying this change

Added the following specific suppressions because fixing the Checkstyle violations would require changes to the existing code.

   <suppress files="ExtensibleLoadManagerImplTest.java" checks="LineLength"/>
   <suppress files="BundleSplitterTaskTest.java" checks="TodoComment"/>
   <suppress files="BlobStoreTestBase.java" checks="TodoComment"/>
   <suppress files="BlobStoreManagedLedgerOffloaderBase.java" checks="TodoComment"/>
   <suppress files="DebeziumMsSqlSourceTester.java" checks="RegexpSinglelineJava"/>
   <suppress files="DebeziumOracleDbSourceTester.java" checks="RegexpSinglelineJava"/>
   <suppress files="PulsarIODebeziumSourceRunner.java" checks="RegexpSinglelineJava"/>
  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jul 8, 2025
@BewareMyPower BewareMyPower changed the title Fixes #23079: Checkstyle checks applied to all test [improve][common] Fixes #23079: Checkstyle checks applied to all test Jul 10, 2025
@BewareMyPower BewareMyPower changed the title [improve][common] Fixes #23079: Checkstyle checks applied to all test [improve][ci] Fixes #23079: Checkstyle checks applied to all test Jul 10, 2025
BewareMyPower
BewareMyPower previously approved these changes Jul 10, 2025
@BewareMyPower
Copy link
Contributor

Error:  src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java:[356,41] (whitespace) OperatorWrap: '+' should be on a new line.
Error:  src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java:[357,32] (whitespace) OperatorWrap: '+' should be on a new line.
Error:  src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java:[390,58] (whitespace) OperatorWrap: '+' should be on a new line.
Error:  src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java:[391,32] (whitespace) OperatorWrap: '+' should be on a new line.
Error:  src/test/java/org/apache/pulsar/tests/TestRetrySupportSuccessTest.java:[26] (javadoc) JavadocStyle: First sentence should end with a period.

The checkstyle check does not pass

@BewareMyPower BewareMyPower dismissed their stale review July 10, 2025 03:42

ci failed

@Praveen7294
Copy link
Contributor Author

Error:  src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java:[356,41] (whitespace) OperatorWrap: '+' should be on a new line.
Error:  src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java:[357,32] (whitespace) OperatorWrap: '+' should be on a new line.
Error:  src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java:[390,58] (whitespace) OperatorWrap: '+' should be on a new line.
Error:  src/test/java/org/apache/pulsar/tests/BetweenTestClassesListenerAdapterTest.java:[391,32] (whitespace) OperatorWrap: '+' should be on a new line.
Error:  src/test/java/org/apache/pulsar/tests/TestRetrySupportSuccessTest.java:[26] (javadoc) JavadocStyle: First sentence should end with a period.

The checkstyle check does not pass

@BewareMyPower i solved above checks, please again review.

@BewareMyPower
Copy link
Contributor

@Praveen7294
Copy link
Contributor Author

Praveen7294 commented Jul 10, 2025

I don't know why Checkstyle doesn't check some modules locally when I build the project.

@BewareMyPower Can you please help me with this?

@Praveen7294
Copy link
Contributor Author

Praveen7294 commented Jul 10, 2025

[INFO] --------------------< org.apache.pulsar:buildtools >--------------------
[INFO] Building Pulsar Build Tools 4.1.0-SNAPSHOT                       [1/132]
[INFO]   from buildtools\pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- enforcer:3.1.0:enforce (enforce-maven-version) @ buildtools ---
[INFO]
[INFO] --- enforcer:3.1.0:enforce (enforce-java-version) @ buildtools ---
[INFO]
[INFO] --- remote-resources:1.7.0:process (process-resource-bundles) @ buildtools ---
[INFO] Preparing remote bundle org.apache:apache-jar-resource-bundle:1.4
[INFO] Copying 3 resources from 1 bundle.
[INFO]
[INFO] --- resources:3.3.0:resources (default-resources) @ buildtools ---
[INFO] Copying 3 resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- compiler:3.10.1:compile (default-compile) @ buildtools ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- resources:3.3.0:testResources (default-testResources) @ buildtools ---
[INFO] skip non existing resourceDirectory F:\GitHub\pulsar\buildtools\src\test\resources
[INFO] Copying 3 resources
[INFO]
[INFO] --- compiler:3.10.1:testCompile (default-testCompile) @ buildtools ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- surefire:3.1.0:test (default-test) @ buildtools ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- jar:3.3.0:jar (default-jar) @ buildtools ---
[INFO]
[INFO] --- site:3.12.1:attach-descriptor (attach-descriptor) @ buildtools ---
[INFO] Skipping because packaging 'jar' is not pom.
[INFO]
[INFO] --- shade:3.4.1:shade (default) @ buildtools ---
[INFO] Including org.apache.commons:commons-lang3:jar:3.17.0 in the shaded jar.
[INFO] Excluding org.yaml:snakeyaml:jar:2.0 from the shaded jar.
[INFO] Excluding org.apache.ant:ant:jar:1.10.12 from the shaded jar.
[INFO] Excluding org.apache.ant:ant-launcher:jar:1.10.12 from the shaded jar.
[INFO] Excluding com.google.guava:guava:jar:32.1.2-jre from the shaded jar.
[INFO] Excluding com.google.guava:failureaccess:jar:1.0.1 from the shaded jar.
[INFO] Excluding com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava from the shaded jar.
[INFO] Excluding com.google.code.findbugs:jsr305:jar:3.0.2 from the shaded jar.
[INFO] Excluding org.checkerframework:checker-qual:jar:3.33.0 from the shaded jar.
[INFO] Excluding com.google.errorprone:error_prone_annotations:jar:2.18.0 from the shaded jar.
[INFO] Excluding com.google.j2objc:j2objc-annotations:jar:2.8 from the shaded jar.
[INFO] Excluding com.google.inject:guice:jar:4.2.3 from the shaded jar.
[INFO] Excluding javax.inject:javax.inject:jar:1 from the shaded jar.
[INFO] Excluding aopalliance:aopalliance:jar:1.0 from the shaded jar.
[INFO] Excluding org.testng:testng:jar:7.7.1 from the shaded jar.
[INFO] Excluding com.beust:jcommander:jar:1.82 from the shaded jar.
[INFO] Excluding org.webjars:jquery:jar:3.6.1 from the shaded jar.
[INFO] Excluding org.apache.logging.log4j:log4j-api:jar:2.23.1 from the shaded jar.
[INFO] Excluding org.apache.logging.log4j:log4j-core:jar:2.23.1 from the shaded jar.
[INFO] Excluding org.apache.logging.log4j:log4j-slf4j2-impl:jar:2.23.1 from the shaded jar.
[INFO] Excluding org.slf4j:slf4j-api:jar:2.0.13 from the shaded jar.
[INFO] Excluding org.slf4j:jcl-over-slf4j:jar:2.0.13 from the shaded jar.
[INFO] Excluding org.mockito:mockito-core:jar:5.17.0 from the shaded jar.
[INFO] Excluding net.bytebuddy:byte-buddy:jar:1.15.11 from the shaded jar.
[INFO] Excluding net.bytebuddy:byte-buddy-agent:jar:1.15.11 from the shaded jar.
[INFO] Excluding org.objenesis:objenesis:jar:3.3 from the shaded jar.
[INFO] Dependency-reduced POM written at: F:\GitHub\pulsar\buildtools\dependency-reduced-pom.xml
[WARNING] buildtools-4.1.0-SNAPSHOT.jar, commons-lang3-3.17.0.jar define 5 overlapping classes and resources:
[WARNING]   - META-INF.versions.9.module-info
[WARNING]   - META-INF/LICENSE.txt
[WARNING]   - META-INF/NOTICE.txt
[WARNING]   - META-INF/maven/org.apache.commons/commons-lang3/pom.properties
[WARNING]   - META-INF/maven/org.apache.commons/commons-lang3/pom.xml
[WARNING] maven-shade-plugin has detected that some class files are
[WARNING] present in two or more JARs. When this happens, only one
[WARNING] single version of the class is copied to the uber jar.
[WARNING] Usually this is not harmful and you can skip these warnings,
[WARNING] otherwise try to manually exclude artifacts based on
[WARNING] mvn dependency:tree -Ddetail=true and the above output.
[WARNING] See https://maven.apache.org/plugins/maven-shade-plugin/
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing F:\GitHub\pulsar\buildtools\target\buildtools-4.1.0-SNAPSHOT.jar with F:\GitHub\pulsar\buildtools\target\buildtools-4.1.0-SNAPSHOT-shaded.jar
[INFO]
[INFO] --- install:3.1.0:install (default-install) @ buildtools ---
[INFO] Installing F:\GitHub\pulsar\buildtools\dependency-reduced-pom.xml to C:\Users\praveen kumar\.m2\repository\org\apache\pulsar\buildtools\4.1.0-SNAPSHOT\buildtools-4.1.0-SNAPSHOT.pom
[INFO] Installing F:\GitHub\pulsar\buildtools\target\buildtools-4.1.0-SNAPSHOT.jar to C:\Users\praveen kumar\.m2\repository\org\apache\pulsar\buildtools\4.1.0-SNAPSHOT\buildtools-4.1.0-SNAPSHOT.jar
[INFO]
[INFO] ----------------------< org.apache.pulsar:pulsar >----------------------
[INFO] Building Pulsar 4.1.0-SNAPSHOT                                   [2/132]
[INFO]   from pom.xml
[INFO] --------------------------------[ pom ]---------------------------------

In above module checks, Checkstyle doesn't enforce the rules when I build the project locally, but it does check them in the CI workflows. There are some other modules that behave the same way.

@BewareMyPower
Copy link
Contributor

You can check the command in CI:

image
mvn -B -T 8 -ntp initialize checkstyle:check

My local run is the same with CI:

[INFO] ------------------------------------------------------------------------
[INFO] Total time:  7.961 s (Wall Clock)
[INFO] Finished at: 2025-07-10T20:43:13+08:00
[INFO] ------------------------------------------------------------------------
[INFO] 0 goals, 0 executed
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-checkstyle-plugin:3.1.2:check (default-cli) on project bc_2_0_0: You have 2 Checkstyle violations. -> [Help 1]

@Praveen7294
Copy link
Contributor Author

@BewareMyPower Thanks

@Praveen7294
Copy link
Contributor Author

@BewareMyPower Now, I have resolved all Checkstyle violations. Please review.

@Praveen7294
Copy link
Contributor Author

@BewareMyPower Please approve workflows

@codecov-commenter
Copy link

codecov-commenter commented Jul 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.33%. Comparing base (bbc6224) to head (f71c64f).
⚠️ Report is 1311 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #24492      +/-   ##
============================================
+ Coverage     73.57%   74.33%   +0.76%     
- Complexity    32624    32868     +244     
============================================
  Files          1877     1868       -9     
  Lines        139502   145902    +6400     
  Branches      15299    16728    +1429     
============================================
+ Hits         102638   108462    +5824     
+ Misses        28908    28840      -68     
- Partials       7956     8600     +644     
Flag Coverage Δ
inttests 26.78% <ø> (+2.19%) ⬆️
systests 23.27% <ø> (-1.06%) ⬇️
unittests 73.83% <ø> (+0.99%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 1097 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@BewareMyPower BewareMyPower merged commit 13e0a7b into apache:master Jul 11, 2025
52 checks passed
@Praveen7294 Praveen7294 deleted the checkstyle branch July 11, 2025 12:23
3pacccccc added a commit to 3pacccccc/pulsar that referenced this pull request Jul 11, 2025
codelipenghui pushed a commit to codelipenghui/incubator-pulsar that referenced this pull request Jul 15, 2025
@lhotari
Copy link
Member

lhotari commented Jul 17, 2025

@BewareMyPower You added the release labels for maintenance branches. It will be a significant effort to backport this change to maintenance branches (comments in the issue). Who is going to handle the backporting?

@BewareMyPower
Copy link
Contributor

Let me do that

@BewareMyPower
Copy link
Contributor

I will only cherry-pick it to 4.0.x releases, since there is no plan for 4.1.0 for now.

BewareMyPower pushed a commit that referenced this pull request Jul 17, 2025
priyanshu-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 22, 2025
…st (apache#24492)

(cherry picked from commit 13e0a7b)
(cherry picked from commit 2e07576)
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Jul 24, 2025
…st (apache#24492)

(cherry picked from commit 13e0a7b)
(cherry picked from commit 2e07576)
nborisov pushed a commit to nborisov/pulsar that referenced this pull request Sep 12, 2025
KannarFr pushed a commit to CleverCloud/pulsar that referenced this pull request Sep 22, 2025
walkinggo pushed a commit to walkinggo/pulsar that referenced this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Checkstyle check is not applied to all tests

4 participants