Skip to content

Issue #18064: added ArrayBracketNoWhitespace check#18240

Open
M-SaaD-H wants to merge 1 commit into
checkstyle:masterfrom
M-SaaD-H:18064
Open

Issue #18064: added ArrayBracketNoWhitespace check#18240
M-SaaD-H wants to merge 1 commit into
checkstyle:masterfrom
M-SaaD-H:18064

Conversation

@M-SaaD-H

@M-SaaD-H M-SaaD-H commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

@romani

romani commented Dec 5, 2025

Copy link
Copy Markdown
Member

Please read and watch videos at Starting_Development.
Please make CI green.

@M-SaaD-H

M-SaaD-H commented Dec 5, 2025

Copy link
Copy Markdown
Contributor Author

Hi @romani ,
I have tested the check locally before raising the PR, but overlooked the XpathRegression tests. I am sorry for this, but I am facing some issues in passing these tests. I have asked this in the discord channel but didn't got the solution from there too. It will be really helpful if you could help me in understanding and solving this issue.
Tagged you in the related thread on discord.

@romani

romani commented Dec 5, 2025

Copy link
Copy Markdown
Member

Just debug test and trace all lines to understand why there is no violation. All is debug-able.

@SURYANSHUAGRAWAL2006

SURYANSHUAGRAWAL2006 commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

@saad please make sure commit should be only one so, please squash all commits into single one.

@mohitsatr

Copy link
Copy Markdown
Member

@M-SaaD-H please push the changes so we can see what's wrong with XpathRegression tests. It's little hard to understand from images.

@M-SaaD-H

M-SaaD-H commented Dec 7, 2025

Copy link
Copy Markdown
Contributor Author

@mohitsatr I have pushed the code.
Please look into it.

@M-SaaD-H

Copy link
Copy Markdown
Contributor Author

Hi @mohitsatr can you please look into the CIs, I can't really get why they are failing.

@SURYANSHUAGRAWAL2006

Copy link
Copy Markdown
Contributor

Hello Saad my advice is that you have to be run the command mvn clean verify again and run this command again and again until BUILD SUCCESS will not encountered because same error also came in my checks so I simply did to ran command mvn clean verify and when BUILD SUCCESS showing then I push my code and all checks passed.
so, please go through this.

@M-SaaD-H

Copy link
Copy Markdown
Contributor Author

Hi @SURYANSHUAGRAWAL2006 ,
Thanks for your advice. I have already verified that build is success locally. I am getting BUILD SUCCESS message when I run mvn clean verify. This error is only showing when I push my changes. Moreover, I can't find the actual reason for the failure of these CI pipelines.

@vivek-0509

vivek-0509 commented Dec 11, 2025

Copy link
Copy Markdown
Member

For the run-inspections failure open the ci failes they have given this link
https://app.circleci.com/pipelines/github/checkstyle/checkstyle/38573/workflows/43e71112-f6c4-4ca9-8d52-4a0ed937de87/jobs/1167874/artifacts

you will se the inspections result open those links and fix those issues

Similarly for other CI failures check the logs

@SURYANSHUAGRAWAL2006

SURYANSHUAGRAWAL2006 commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

Hello Saad I saw your build failure this is occurring not because of your code or check style it is because of maven problem so, Kindly rerun all CI best way close the pr then reopen the pr then all CI will run again and then you check all CI is passing or not but I am sure this is not your code problem rather than it is problem of maven internal.

@M-SaaD-H

Copy link
Copy Markdown
Contributor Author

Hi @romani
Can you please look into it?

@M-SaaD-H M-SaaD-H force-pushed the 18064 branch 2 times, most recently from ce465be to b2c32cd Compare December 16, 2025 06:27
@M-SaaD-H M-SaaD-H force-pushed the 18064 branch 2 times, most recently from bf67dc9 to 8bb25c4 Compare December 16, 2025 13:57
@mohitsatr

Copy link
Copy Markdown
Member

@M-SaaD-H Green CI is a good sign. Take to run regression.

Please go through the section Executing generation using github action and try to generate the report.

Example PR: #17329

@M-SaaD-H M-SaaD-H force-pushed the 18064 branch 4 times, most recently from 47b8d0f to 4d1133d Compare December 16, 2025 17:23
@M-SaaD-H

Copy link
Copy Markdown
Contributor Author

GitHub, generate report

@github-actions

Copy link
Copy Markdown
Contributor

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

@github-actions

Copy link
Copy Markdown
Contributor

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

@mohitsatr

Copy link
Copy Markdown
Member

@M-SaaD-H Config in the Pr's description is not valid. It has to be like: https://gist.githubusercontent.com/mohitsatr/0e04070f847926ea44bf7eda88706807/raw/f9470db307d730a651e9c93cad776d6b592839e8/textblockgooglestyleformatting.xml. Replace Textb...Check with your check

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

@Atharv3221 Atharv3221 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Improve

@M-SaaD-H M-SaaD-H force-pushed the 18064 branch 2 times, most recently from b3e5050 to c05d721 Compare June 5, 2026 17:28
</details>
</checkerFrameworkError>


Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove extra blank line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@Atharv3221 Atharv3221 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor

@Atharv3221

Copy link
Copy Markdown
Contributor

GitHub, generate website

@Atharv3221

Copy link
Copy Markdown
Contributor

ping @romani

@Atharv3221

Copy link
Copy Markdown
Contributor

ping @mohitsatr

@Zopsss Zopsss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

items:


public class InputArrayBracketNoWhitespaceBranchCoverage {

// Edge cases to cover missing branches in findClosestTokenAfter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what is findClosestTokenAfter ? and please remove this line.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

also rename the file name, no need to mention BranchCoverage

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


// Nested array access with complex expressions
int[][] matrix = new int[5][5];
int result1 = matrix[arr[0]][arr[1]];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

        int result2 = matrix[ arr[0]][arr[1 ]];

add this case

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

int[] arr2 = new int [10]; // violation ''\[' is preceded with whitespace.'
int[] arr3 = new int[ 10]; // violation ''\[' is followed by whitespace.'
int[] arr4 = new int[10 ]; // violation ''\]' is preceded with whitespace.'
int[] arr5 = new int[ 10 ];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add one more case here:

int []arr5 = new int[10];

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add 2 examples, one should contain correct code only and other should contain violations.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@Zopsss

Zopsss commented Jun 10, 2026

Copy link
Copy Markdown
Member

GitHub, generate report

@M-SaaD-H

Copy link
Copy Markdown
Contributor Author

GitHub, generate report

@github-actions

Copy link
Copy Markdown
Contributor

@M-SaaD-H

Copy link
Copy Markdown
Contributor Author

Hey @Zopsss ,
I've addressed all the review comments and generated the report. Please take a look when you get the chance.

@M-SaaD-H M-SaaD-H requested a review from Zopsss June 11, 2026 08:17
@Zopsss

Zopsss commented Jun 12, 2026

Copy link
Copy Markdown
Member

False-positive:

https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/6963b5f_2026150836/reports/diff/apache-ant/index.html#A7

The rsc[i] should not be followed by a whitespace as there is closing bracket (});) after it so it is fine.

Similar other case: https://checkstyle-diff-reports.s3.us-east-2.amazonaws.com/6963b5f_2026150836/reports/diff/apache-ant/index.html#A8

@Zopsss

Zopsss commented Jun 12, 2026

Copy link
Copy Markdown
Member

@M-SaaD-H fyi, do not wait for maintainers to review the report. You should do it yourself and report any false-positive/negative you find and fix them. It accelerates the review process

@M-SaaD-H

Copy link
Copy Markdown
Contributor Author

I initially assumed these were valid violations since formatter output often uses spaces in cases like { bytes[0] }. Since the intended behavior is to allow {bytes[0]}, I've updated the logic and pushed the fix.

@M-SaaD-H

Copy link
Copy Markdown
Contributor Author

GitHub, generate report

@github-actions

Copy link
Copy Markdown
Contributor

@M-SaaD-H

Copy link
Copy Markdown
Contributor Author

Hey @Zopsss ,
I've fixed the previous false positive and generated the report. Please take a look when you get the chance.

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.

New check: ArrayBracketWhitespace

7 participants