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

A false negative about the rule Indentation #13782

Open
clearlove2077 opened this issue Sep 26, 2023 · 5 comments
Open

A false negative about the rule Indentation #13782

clearlove2077 opened this issue Sep 26, 2023 · 5 comments

Comments

@clearlove2077
Copy link

I have read check documentation: https://checkstyle.sourceforge.io/checks/misc/indentation.html#Indentation
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

/var/tmp $ cat T.java
import util.MyAnnotation;
@MyAnnotation
public @Ann
@Ann2 class T
    implements TestInterface {
}

/var/tmp $ cat 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">
  <property name="charset" value="UTF-8"/>
  <property name="severity" value="warning"/>
  <property name="fileExtensions" value="java, properties, xml"/>
  <module name="TreeWalker">
    <module name="Indentation">
      <property name="basicOffset" value="2"/>
      <property name="braceAdjustment" value="2"/>
      <property name="caseIndent" value="2"/>
      <property name="throwsIndent" value="4"/>
      <property name="lineWrappingIndentation" value="4"/>
      <property name="arrayInitIndent" value="2"/>
    </module>
  </module>
</module>



/var/tmp $ java -Duser.language=en -Duser.country=US -jar checkstyle-10.12.3-all.jar -c config.xml T.java
Starting audit...
Audit done.

I would expect Checkstyle to show the warning message like:

Starting audit...
[WARN] T.java:4:1: '@' has incorrect indentation level 0, expected level should be 4. [Indentation]
Audit done.

but no warnings, hence, I think this is an FN.

@romani
Copy link
Member

romani commented Sep 26, 2023

This is "Line wrap" should be +4 indentation.

@clearlove2077
Copy link
Author

clearlove2077 commented Sep 26, 2023

This is "Line wrap" should be +4 indentation.

Hi @romani , I want to provide another case for helping analysis, CheckStyle can report an Indention warning at line 2, but I use the same config file. Difference: the new case does not have the annotation MyAnnotation.

public @Ann
@Ann2 class T  // violation
    implements TestInterface {
}

Warning message:

[WARN] T.java:2:1: '@' has incorrect indentation level 0, expected level should be 4. [Indentation]

@nrmancuso
Copy link
Member

Since as far as I know annotations can't occur between public keyword and class keyword!

@kalpadiptyaroy no need to speculate, please prove your claim by javac.

@kalpadiptyaroy
Copy link
Contributor

kalpadiptyaroy commented Oct 8, 2023

@nrmancuso - My myth is busted. It is legal to use public before annotations while annotating a class. Removing my previous comment. I tried compiling it using javac and yes it works!

@kalpadiptyaroy
Copy link
Contributor

I am on it. I have written a basic test case in the following PR. Please have a look

kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 15, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 16, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 21, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 21, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 22, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 23, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 23, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 23, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 23, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 23, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Dec 23, 2023
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Jan 15, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Jan 15, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 1, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 1, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 1, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 3, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 17, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 17, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 27, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 27, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 27, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 27, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 28, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 28, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 28, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 28, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 28, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 28, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Feb 29, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 1, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 1, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 2, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 2, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 2, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 2, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 2, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 2, 2024
kalpadiptyaroy added a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 2, 2024
nrmancuso pushed a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 3, 2024
nrmancuso pushed a commit to kalpadiptyaroy/checkstyle that referenced this issue Mar 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants