Skip to content

IGNITE-28822 Protected Classes CI check: reduce cognitive complexity of the detection script#13280

Merged
anton-vinogradov merged 1 commit into
apache:masterfrom
anton-vinogradov:ignite-28822
Jun 30, 2026
Merged

IGNITE-28822 Protected Classes CI check: reduce cognitive complexity of the detection script#13280
anton-vinogradov merged 1 commit into
apache:masterfrom
anton-vinogradov:ignite-28822

Conversation

@anton-vinogradov

@anton-vinogradov anton-vinogradov commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

What

Simplify the detection logic in the Rolling Upgrade check step so it reads as a sequence of named steps:

  • Split it into small functions — changed_java_files, is_protected_class, filter_protected — with a top-level changed_java_files | filter_protected > "$HITS_FILE".
  • Collapse the two near-identical loops (added/deleted vs modified files) into that single pass; the revision inspected per file status is A → head, D/M → base.
  • Drop the string accumulation with literal \n + printf '%b', the process substitution and the parallel HITS variable; 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/%b and 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 file org/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 @Order definition, not a protected class.

Notes

  • Independent of #13279 (different hunk of the same file); no conflict expected.

Jira: https://issues.apache.org/jira/browse/IGNITE-28822

🤖 Generated with Claude Code

…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>
@anton-vinogradov anton-vinogradov merged commit 9d88f27 into apache:master Jun 30, 2026
7 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.

2 participants