Skip to content

Issue #16781: NoWhitespaceBefore blind spot resulting in high failure rate #16781

@Pankraz76

Description

@Pankraz76

Understanding the NoWhitespaceBefore Check

I may be misunderstanding the NoWhitespaceBefore check, but my current understanding is that it should detect and flag any unwanted whitespace that appears before specific tokens, including:

  • Dots (.)
  • Semicolons (;)
  • String literals ("")
  • Method call parentheses (())
  • Other similar syntax elements

The check's purpose is to identify and report any unnecessary whitespace preceding these tokens.

Testing Observations:
When testing with 10 straightforward examples, only 1 violation was detected. This low detection rate raises concerns about either:

  1. The check's current implementation
  2. My interpretation of its intended behavior

Test Case Demonstration

public void testSpaceViolation2() {
     "".equals(""); // Expected violation
    "" .equals(""); // Expected violation - found by current impl. of NoWhitespaceBeforeCheck
    "". equals(""); // Expected violation
    "".equals (""); // Expected violation
    "".equals( ""); // Expected violation
    "".equals("" ); // Expected violation
    "".equals("") ; // Expected violation
    " ".equals("");
    "".equals(" ");
}
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions