Skip to content

Issue #15769: fix false-positive indentation violations for block codes #16515

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

Merged
merged 1 commit into from
Apr 19, 2025

Conversation

@mohitsatr
Copy link
Member Author

mohitsatr commented Mar 10, 2025

Github, generate report for Indentation/all-examples-in-one

Copy link
Contributor

Failed to download or process the specified configuration(s).
Error details:

Please ensure you've used one of the following commands correctly:

@mohitsatr mohitsatr force-pushed the codeblock-indentation branch from ffcf264 to fbfa4b1 Compare March 10, 2025 03:41
@mohitsatr
Copy link
Member Author

Github, generate report for Indentation/all-examples-in-one

Copy link
Contributor

@mohitsatr mohitsatr marked this pull request as ready for review March 12, 2025 03:24
@romani
Copy link
Member

romani commented Mar 12, 2025

@Zopsss , please do first review

Copy link
Member

@Zopsss Zopsss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

item:

@mohitsatr
Copy link
Member Author

Github, generate report

Copy link
Contributor

@mohitsatr
Copy link
Member Author

mohitsatr commented Mar 13, 2025

first, we need to check regression on the project suggested here #14294 (comment)

report is ready #16515 (comment)

@mohitsatr
Copy link
Member Author

@Zopsss in the regression config, we need to specify the google_style config as this issue is related to google-style right?

@Zopsss
Copy link
Member

Zopsss commented Mar 14, 2025

Yes, find diff between current master branch's google_checks.xml config and your modified google_checks.xml config. Check the generated report, if false positives/negatives are introduced then report them here and try to fix them

@mohitsatr
Copy link
Member Author

Github, generate report

@mohitsatr
Copy link
Member Author

@Zopsss report generation exceeded 6 hours limit and got cancelled twice https://github.com/checkstyle/checkstyle/actions/runs/13871818479 ??

@Zopsss
Copy link
Member

Zopsss commented Mar 16, 2025

Sorry, even I'm seeing this error for the first time.

@romani can you check what's the issue here?

@mohitsatr
Copy link
Member Author

Github, generate report

@romani
Copy link
Member

romani commented Mar 21, 2025

Please do not run on whole Google style config, just use intendtation module from it, nothing else.

@mohitsatr
Copy link
Member Author

Github, generate report

Copy link
Contributor

Report generation failed on phase "make_report",
step "Generate report".
Link: https://github.com/checkstyle/checkstyle/actions/runs/13985147713

@mohitsatr
Copy link
Member Author

Github, generate report

Copy link
Contributor

Report generation failed on phase "make_report",
step "Generate report".
Link: https://github.com/checkstyle/checkstyle/actions/runs/13986614683

@mohitsatr
Copy link
Member Author

Error : Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.12.1:site (default-site) on project sample: Error generating maven-checkstyle-plugin:3.1.1:checkstyle report: Failed during checkstyle configuration: Exception was thrown while processing /home/runner/work/checkstyle/checkstyle/.ci-temp/contribution/checkstyle-tester/src/main/java/openjdk21/src/jdk.jlink/share/classes/module-info.java: IllegalStateException occurred while parsing file /home/runner/work/checkstyle/checkstyle/.ci-temp/contribution/checkstyle-tester/src/main/java/openjdk21/src/jdk.jlink/share/classes/module-info.java. 54:0: no viable alternative at input 'module': NoViableAltException -> [Help 1]

@romani
Copy link
Member

romani commented Mar 21, 2025

module-info.java

please use https://github.com/checkstyle/contribution/blob/master/checkstyle-tester/my_check.xml but module should one one , attention to <!-- PLEASE CHANGE IT TO CHECK YOU ARE TESTING !!!! -->

@mohitsatr
Copy link
Member Author

<?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"/>

    <!-- do not change severity to 'error', as that will hide errors caused by exceptions -->
    <property name="severity" value="warning"/>

    <!-- haltOnException is required for exception fixes and reporting of all exceptions -->
    <property name="haltOnException" value="false"/>

    <!-- BeforeExecutionFileFilters is required for sources of java9 -->
    <module name="BeforeExecutionExclusionFileFilter">
        <property name="fileNamePattern" value="module\-info\.java$" />
    </module>

    <module name="TreeWalker">
         <!-- as we run on regression even on non-compiled files we need to skip exceptions on them -->
         <property name="skipFileOnJavaParseException" value="true"/>
         <property name="javaParseExceptionSeverity" value="ignore"/>

    
         
         <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>
         <!-- Suppression for block code until we find a way to detect them properly
         until https://github.com/checkstyle/checkstyle/issues/15769 -->
        <module name="SuppressionXpathSingleFilter">
           <property name="checks" value="Indentation"/>
           <property name="query" value="//SLIST[not(parent::CASE_GROUP)]/SLIST
                                   | //SLIST[not(parent::CASE_GROUP)]/SLIST/RCURLY"/>
        </module>

         <!-- suppress javadoc parsing errors, as we test Check not a parser -->
         <module name="SuppressionXpathSingleFilter">
            <property name="message" value="Javadoc comment at column \d+ has parse error"/>
         </module>
    </module>

</module>

@romani like this ?

@romani
Copy link
Member

romani commented Mar 22, 2025

Yes

@mohitsatr
Copy link
Member Author

Github, generate report

Copy link
Contributor

@romani
Copy link
Member

romani commented Mar 22, 2025

diff is huge, please start copy all code from diff report to Input to have all distinct cases that we missed in Inputs.
Ideally we should have all in Inputs, and depend less on diff report.

@mohitsatr
Copy link
Member Author

mohitsatr commented Mar 23, 2025

report is weird. there are diffs in switch and case blocks. this report is based on google config and not every project uses it. so obviously there will be diffs.
only Hbase and camunda use google-style

@mohitsatr
Copy link
Member Author

we have already checked the regression using default indentation config #16515 (comment)

@Zopsss
Copy link
Member

Zopsss commented Mar 23, 2025

only Hbase and camunda use google-style

Please go through their diff and add missing examples to our inputs. We can ignore other projects.

Also if you're going to generate more regression reports then only include projects which uses google-style, other projects will not help us to find edge cases.

@mohitsatr
Copy link
Member Author

Github, generate report

Copy link
Contributor

@mohitsatr
Copy link
Member Author

Github, generate report

Copy link
Contributor

@mohitsatr
Copy link
Member Author

mohitsatr commented Mar 24, 2025

@Zopsss in camunda project, violations on switch expression are fixed in #16418. these diffs got removed that PR's regression report #16418 (comment)
As for the Hbase project, there are not any new violations. diff is due to change in violation message.

@mohitsatr mohitsatr force-pushed the codeblock-indentation branch from fbfa4b1 to 78e1fb8 Compare March 24, 2025 06:22
@mohitsatr
Copy link
Member Author

Github, generate report

Copy link
Contributor

@mohitsatr
Copy link
Member Author

like I said , there is no violation change in Hbase project, do I still need to add examples from it to our input ??

@Zopsss
Copy link
Member

Zopsss commented Mar 25, 2025

in camunda project, violations on switch expression are fixed in #16418. these diffs got removed that PR's regression report #16418 (comment)

Sorry I'm not able to understand why diff got removed. Were the violations in diff was false positives? And your PR fixed them?

As for the Hbase project, there are not any new violations. diff is due to change in violation message.

Can you point out the PR where the violation message was changed?

@Zopsss
Copy link
Member

Zopsss commented Mar 25, 2025

like I said , there is no violation change in Hbase project, do I still need to add examples from it to our input ??

Did we fixed some bug that's why the violation message was changed? Or is it something else?

If the diff doesn't have any false-postivie/negative and if you don't find an example which is not in our input files then you don't need to add any new example. We'll be good to go

@romani
Copy link
Member

romani commented Mar 27, 2025

@mohitsatr mohitsatr force-pushed the codeblock-indentation branch from 78e1fb8 to d66657d Compare April 9, 2025 03:25
@mohitsatr
Copy link
Member Author

mohitsatr commented Apr 9, 2025

diffes in the Hbase project is mainly due to the way they are formatting for loops
indentation value of loop braces is same as indentation value of for keyword

for (...)
{
  ..
}  

this is how we expect it to be:

for (...)
  {
     ..
  }

@mohitsatr
Copy link
Member Author

now check is also giving correct violation

Screenshot from 2025-04-09 09-00-57

@romani
Copy link
Member

romani commented Apr 10, 2025

@Zopsss , please finish review

Copy link
Member

@Zopsss Zopsss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review, LGTM! Thanks a lot for all the hard work!!!

@Zopsss
Copy link
Member

Zopsss commented Apr 18, 2025

@romani please merge the PR

Copy link
Member

@romani romani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good step forward!!!

@romani romani merged commit 7d511ed into checkstyle:master Apr 19, 2025
115 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

google_checks.xml: remove xpath suppression and false-positive indentation violations for block codes
3 participants