IGNITE-28822 Protected Classes CI check: reduce cognitive complexity of the detection script#13280
Merged
Merged
Conversation
0ad20c6 to
9935920
Compare
…of the detection script Collapse the two near-identical detection loops (added/deleted vs modified files) into a single pass and split the logic into small named functions (`changed_java_files`, `is_protected_class`, `filter_protected`) so the step reads as `changed_java_files | filter_protected`. Per file status the inspected revision is A -> head, D/M -> base. Drop the string accumulation with literal \n + `printf '%b'`, the process substitution and the parallel `HITS` variable; matches are written straight to the output file and detected with `[ -s ]`. This roughly halves the cyclomatic/cognitive complexity and removes the duplicated loop body. Side effect: the content-based grep removes a false positive where the previous diff-based grep matched the file path `org/apache/ignite/internal/Order*.java` in diff headers (regex dots match slashes). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
9935920 to
847176d
Compare
sergey-chugunov-1985
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Simplify the detection logic in the
Rolling Upgrade checkstep so it reads as a sequence of named steps:changed_java_files,is_protected_class,filter_protected— with a top-levelchanged_java_files | filter_protected > "$HITS_FILE".A→ head,D/M→ base.\n+printf '%b', the process substitution and the parallelHITSvariable; matches go straight to the output file, detected with[ -s ].Why
The two loops differed only in the diff filter and the grepped revision (duplication); the
\n/%band process-substitution idioms add reader friction. The named functions make the top level read as intent, halve the cyclomatic/cognitive complexity and remove the duplication.Behaviour
Verified equivalent to the previous logic on add / modify / delete / rename scenarios, and that a PR with no hits still exits 0 under
set -eo pipefail. One intentional difference: the content-based grep no longer flags add/delete of the annotation's own definition fileorg/apache/ignite/internal/Order*.java— the previous diff-based grep matched the file path in diff headers (the regex dots match slashes), a false positive, since that file is the@Orderdefinition, not a protected class.Notes
Jira: https://issues.apache.org/jira/browse/IGNITE-28822
🤖 Generated with Claude Code