Skip to content

Issue #18931: Add MatchXpath example for large array initialization#19196

Merged
romani merged 1 commit into
checkstyle:masterfrom
achyuth8055:issue-matchxpath-array-init-example
Mar 13, 2026
Merged

Issue #18931: Add MatchXpath example for large array initialization#19196
romani merged 1 commit into
checkstyle:masterfrom
achyuth8055:issue-matchxpath-array-init-example

Conversation

@achyuth8055

@achyuth8055 achyuth8055 commented Mar 12, 2026

Copy link
Copy Markdown
Contributor

Resolves #18931

I have made the changes as per your suggestion and added the id="largeConstantCollection" in the example. The documentation example, test, and example file have been updated accordingly and the build is passing locally.

Could you please review it and let me know if any further changes are needed? Thank you!

Copilot AI review requested due to automatic review settings March 12, 2026 19:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new MatchXpath documentation example demonstrating how to flag large array initializations (more than 10 elements), including an explicit id for the example configuration.

Changes:

  • Added Example6.java with a MatchXpath query targeting large ARRAY_INIT nodes and a custom message.
  • Added a corresponding example test to validate the reported violation location/message.
  • Updated the MatchXpath xdoc template to include the new Example6 config and code snippet.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/xdocs-examples/resources/com/puppycrawl/tools/checkstyle/checks/coding/matchxpath/Example6.java New example showing how to match array initializations with >10 elements and includes id=largeConstantCollection.
src/xdocs-examples/java/com/puppycrawl/tools/checkstyle/checks/coding/MatchXpathCheckExamplesTest.java Adds a test case validating the Example6 output (line/column + message).
src/site/xdoc/checks/coding/matchxpath.xml.template Documents the new Example6 configuration and code in the MatchXpath check page.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

<param name="type" value="code"/>
</macro><hr class="example-separator"/>
<p id="Example6-config">
To violate if array initialization has more than <b>10</b> elements

Copilot AI Mar 12, 2026

Copy link

Choose a reason for hiding this comment

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

The sentence reads ungrammatically in the rendered docs. Consider rephrasing to something like: “Reports a violation if an array initialization has more than 10 elements.” (and add terminal punctuation) to match typical documentation style.

Suggested change
To violate if array initialization has more than <b>10</b> elements
Reports a violation if an array initialization has more than <b>10</b> elements.

Copilot uses AI. Check for mistakes.
@romani

romani commented Mar 13, 2026

Copy link
Copy Markdown
Member

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

@achyuth8055 achyuth8055 force-pushed the issue-matchxpath-array-init-example branch from 6e86e05 to 1e80ecc Compare March 13, 2026 05:30
@achyuth8055 achyuth8055 force-pushed the issue-matchxpath-array-init-example branch from 1e80ecc to 715226c Compare March 13, 2026 06:24

@romani romani 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.

awesome

@romani romani merged commit 593e043 into checkstyle:master Mar 13, 2026
120 of 123 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.

Example of validation for Large Constant Collection

3 participants