Skip to content

[BUG] Java code format standard is not being enforced #2131

Description

@imotov

Describe the bug

There are currently 18 Java files in the main branch that do not pass spotless check, which indicates that changes in #1049 might not have been sufficient to fully resolve #1042.

To reproduce:

  • Checkout the current main branch
  • Run ./build.sh libcuvs java
  • Run git status
  • You will see that 18 files were reformatted by this action:
(cuvs-env) *[main][~/Projects/rapidsai/cuvs]$ git status
On branch main
Your branch is up to date with 'upstream/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   java/cuvs-java/src/main/java/com/nvidia/cuvs/CagraIndex.java
        modified:   java/cuvs-java/src/main/java/com/nvidia/cuvs/CuVSAceParams.java
        modified:   java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswAceParams.java
        modified:   java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndex.java
        modified:   java/cuvs-java/src/main/java/com/nvidia/cuvs/HnswIndexParams.java
        modified:   java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/CuVSProvider.java
        modified:   java/cuvs-java/src/main/java/com/nvidia/cuvs/spi/UnsupportedProvider.java
        modified:   java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/CagraIndexImpl.java
        modified:   java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/CuVSParamsHelper.java
        modified:   java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/HnswIndexImpl.java
        modified:   java/cuvs-java/src/main/java22/com/nvidia/cuvs/internal/common/Util.java
        modified:   java/cuvs-java/src/main/java22/com/nvidia/cuvs/spi/JDKProvider.java
        modified:   java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraAceBuildAndSearchIT.java
        modified:   java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraBuildAndSearchIT.java
        modified:   java/cuvs-java/src/test/java/com/nvidia/cuvs/CagraMultiThreadStabilityIT.java
        modified:   java/cuvs-java/src/test/java/com/nvidia/cuvs/HnswAceBuildAndSearchIT.java
        modified:   java/cuvs-java/src/test/java/com/nvidia/cuvs/HnswBuildAndSearchIT.java
        modified:   java/cuvs-java/src/test/java/com/nvidia/cuvs/HnswRandomizedIT.java

no changes added to commit (use "git add" and/or "git commit -a")

Expected behavior

No incorrectly formatted files should be present.

Environment details (please complete the following information):

  • Environment location: Bare-metal
  • Method of cuVS install: from source

Additional context

There are several issues here:

  1. There are some Java files that were not formatted properly before they were merged in.
  2. There are no format checks in pre-commit for Java or CI process, that could have prevented this.
  3. The Spotless license header file https://github.com/rapidsai/cuvs/blob/main/java/license-header.txt wasn't updated to 2025–2026, while the headers in some Java files were (that contributes to at least some of the spotless errors)
  4. spotless:apply is bound to Maven's verify phase, which means every build silently mutates source files, making the creation of clean PRs with only relevant diffs somewhat cumbersome. It also means that in CI, incorrectly formatted files are getting corrected and ignored instead of triggering a build failure.

I would propose:

  1. Update license-header.txt to contain 2025–$YEAR.
  2. Replace spotless:apply with spotless:check in the verify phase (that should catch any future issues in CI as part of normal test run).
  3. Add a spotless:check (or spotless:apply) call to pre-commit.
  4. Runspotless:apply on all files to make sure all files are correctly formatted .

If that proposal works for the maintainers, I can open a PR for these fixes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    JavabugSomething isn't working

    Type

    No type

    Projects

    Status
    Todo
    Status
    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions