Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GenericWhitespace Check ignores exception to the ">" rule for succeeding whitespaces #14344

Closed
sktpy opened this issue Jan 24, 2024 · 3 comments · Fixed by #14497
Closed

GenericWhitespace Check ignores exception to the ">" rule for succeeding whitespaces #14344

sktpy opened this issue Jan 24, 2024 · 3 comments · Fixed by #14497

Comments

@sktpy
Copy link
Contributor

sktpy commented Jan 24, 2024

Detected at #14341.
Affects PR #14364

(Documentation)

Test.java

import java.util.ArrayList;
import java.util.List;

public class Test {
  List a = new ArrayList<> (); // violation expected
}

config.xml

<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
        "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
        "https://checkstyle.org/dtds/configuration_1_3.dtd">
<module name="Checker">
  <module name="TreeWalker">
    <module name="GenericWhitespace"/>
  </module>
</module>

Actual:

java -jar checkstyle-10.12.7-all.jar -c config.xml Test.java
Starting audit...
Audit done.

Expected: violation on line 5.
Test.java:5:26: '>' is followed by whitespace. [GenericWhitespace]

Explanation:

  • As per the documentation, right angle bracket (>) should not be followed by whitespace for diamond operators and when preceding method name or constructor.
  • In List a = new ArrayList<> (); the right angle bracket (>) precedes the constructor, and is also part of the diamond operator (<>), hence shouldn't be followed by the whitespace.
  • The exact example is provided provided in the documentation, showcasing that it is incorrect style and should throw a violation, but this is ignored by the Check. (Also evident in the referenced PR)
@sktpy sktpy changed the title GenericWhiteSpace Check fails exception to ">" not being followed by whitespace GenericWhitespace Check fails exception to ">" not being followed by whitespace Jan 24, 2024
@sktpy sktpy changed the title GenericWhitespace Check fails exception to ">" not being followed by whitespace GenericWhitespace Check fails exception to the ">" rule for succeeding whitespaces Jan 24, 2024
@sktpy sktpy changed the title GenericWhitespace Check fails exception to the ">" rule for succeeding whitespaces GenericWhitespace Check ignores exception to the ">" rule for succeeding whitespaces Jan 24, 2024
@MANISH-K-07

This comment was marked as off-topic.

@sktpy

This comment was marked as off-topic.

@sktpy
Copy link
Contributor Author

sktpy commented Feb 14, 2024

I am on it

sktpy added a commit to sktpy/checkstyle that referenced this issue Feb 17, 2024
…n to the '>' rule for succeeding whitespaces
sktpy added a commit to sktpy/checkstyle that referenced this issue Feb 18, 2024
…n to the '>' rule for succeeding whitespaces
sktpy added a commit to sktpy/checkstyle that referenced this issue Feb 19, 2024
…n to the '>' rule for succeeding whitespaces
sktpy added a commit to sktpy/checkstyle that referenced this issue Feb 19, 2024
…n to the '>' rule for succeeding whitespaces
sktpy added a commit to sktpy/checkstyle that referenced this issue Feb 19, 2024
…n to the '>' rule for succeeding whitespaces
sktpy added a commit to sktpy/checkstyle that referenced this issue Feb 21, 2024
…n to the '>' rule for succeeding whitespaces
rnveach pushed a commit that referenced this issue Feb 22, 2024
@romani romani added the bug label Feb 22, 2024
aye-nyeinSan added a commit to aye-nyeinSan/checkstyle that referenced this issue Feb 23, 2024
Issue checkstyle#14396: Made changes to pom.xml and checker-framework.groovy to fail execution if report generation fails

Issue checkstyle#14344: Fix GenericWhitespace Check ignoring exception to the '>' rule for succeeding whitespaces

Pull checkstyle#14503: improve text block grammar

Issue checkstyle#13213: Remove '//ok' comments from input files

Issue checkstyle#13213: Remove '//ok' comments from input files

Issue checkstyle#13213: Remove '//ok' comments from input files
kalpadiptyaroy pushed a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 27, 2024
…n to the '>' rule for succeeding whitespaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants