You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "terrymanu (via GitHub)" <gi...@apache.org> on 2026/09/05 03:50:14 UTC

[PR] Enforce non-final for-loop variables with Checkstyle [shardingsphere]

terrymanu opened a new pull request, #39731:
URL: https://github.com/apache/shardingsphere/pull/39731

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Enforce non-final for-loop variables with Checkstyle [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu merged PR #39731:
URL: https://github.com/apache/shardingsphere/pull/39731


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Enforce non-final for-loop variables with Checkstyle [shardingsphere]

Posted by "terrymanu (via GitHub)" <gi...@apache.org>.
terrymanu commented on PR #39731:
URL: https://github.com/apache/shardingsphere/pull/39731#issuecomment-5549155876

   ### Result
   
   **Review Result: Mergeable**
   
   A precise `MatchXpath` check now prohibits declaring variables as `final` in traditional and enhanced `for` loops.
   
   ### Evidence
   
   - `src/resources/checkstyle.xml:130` adds a structural query that matches only `VARIABLE_DEF` nodes whose parent is `FOR_INIT` or `FOR_EACH_CLAUSE`.
   - The query does not match fields, method parameters, or local variables declared inside loop bodies.
   - Checkstyle 14.0.0 documentation confirms that `MatchXpath` supports custom AST-based rules: [MatchXpath](https://checkstyle.org/checks/coding/matchxpath.html) and [XPath support](https://checkstyle.org/xpath.html).
   - Positive fixture: valid loops, `final` fields, `final` parameters, and `final` variables inside loop bodies produced zero violations.
   - Negative fixture: a traditional `for` loop and an annotated, multiline enhanced `for` loop produced exactly two violations.
   - Full-repository Checkstyle verification completed successfully with exit code 0.
   - XML validation and `git diff --check` completed successfully with exit code 0.
   - Three-round performance comparison:
     - Baseline: 2.42/2.06/2.09 seconds
     - Candidate: 2.08/2.11/2.04 seconds
     - No reproducible performance regression was detected.
   - Spotless was not run because the current configuration does not govern ordinary XML files.
   
   ### Coverage
   
   - Candidate type: standalone local candidate under Code Correctness Review.
   - Baseline: `a6d0948a5f4df30a2dae8cfb2e0af0281fe48577`.
   - Task-owned change: four added lines in `src/resources/checkstyle.xml`.
   - Reviewed rule accuracy, false-positive boundaries, Checkstyle 14.0.0 compatibility, repository-wide impact, and execution performance.
   - No unresolved issues remain. Remote CI was not reviewed.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org