Skip to content

False-Negative: NoTrailingWhitespace misses spaces after * in multi-line comments (Google Style) #17878

@HamedTaghani

Description

@HamedTaghani

I have read check documentation: https://checkstyle.org/checks/whitespace/index.html
I have downloaded the latest checkstyle from: https://checkstyle.org/cmdline.html#Download_and_Run
I have executed the cli and showed it below, as cli describes the problem better than 1,000 words

From: https://google.github.io/styleguide/javaguide.html#s2.3.1-whitespace-characters

Aside from the line terminator sequence, the ASCII horizontal space character (0x20) is the only whitespace character that appears anywhere in a source file.

Code:

/*
 * Copyright 2025
 */

/**
 * Test.
 */
public class Test {

  /**
   * Line one.
   *    // <--- This line has a single space or tab after the asterisk (should violate)
   * Line three.
   */
  public void exampleMethod() {
  }
}

Cli:

$ java -jar checkstyle-11.1.0-all.jar -c google_checks.xml Test.java
Starting audit...
Audit done.

Formatter:

java -jar google-java-format-1.28.0-all-deps.jar Test.java
/*
 * Copyright 2025
 */

/** Test. */
public class Test {

  /**
   * Line one. // <--- This line has a single space or tab after the asterisk (should violate) Line
   * three.
   */
  public void exampleMethod() {}
}

I've found a false negative related to the enforcement of the Google Java Style Guide, Section 2.3.1 (Whitespace), which prohibits trailing whitespace. The current configuration appears to miss trailing spaces on lines that contain only the asterisk (*) within a Javadoc block.

The issue is that the NoTrailingWhitespaceCheck does not report a violation when one or more space characters exist between the final asterisk and the newline character.

I am ready to submit a Pull Request for this if the team agrees it is a valid missed check. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions