Skip to content

Split blocksHolding and RealPass::refuseIgnoredThatMoves - #2429

Merged
annejan merged 1 commit into
mainfrom
refactor/complexity-2157-b8
Dec 1, 2026
Merged

annejan merged 1 commit into
mainfrom
refactor/complexity-2157-b8

Conversation

@annejan

@annejan annejan commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Part of #2157, batch 8. Only the structure changes: the extracted code is moved as it was, comments included.

Function CCN before after New
blocksHolding 19 14 bareKey() (3), addHolder() (4)
RealPass::refuseIgnoredThatMoves 19 13 ignoredByRulesWithin() (4), exposedWhereLanded() (4)
  • blocksHolding(): the key normalisation (trim, upper case, drop ! and 0x) moves to bareKey(). The endBlock lambda's test moves to addHolder(). Both are in an anonymous namespace. wanted is now const.
  • refuseIgnoredThatMoves(): the git check-ignore -v walk for rules inside the folder moves to ignoredByRulesWithin(). The caller still asks only when the landing does not exist, as the old && did. The final old > new list moves to exposedWhereLanded().

Test plan

  • qmake6 -r CONFIG+=rnp && make -j12 && make check in a scratch HOME/GNUPGHOME: 37 suites, 2,079 passed, 0 failed
  • doxygen Doxyfile: no warnings
  • lizard -C 14: both functions are at or below 14

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Moving a folder now correctly identifies files ignored by rules within that folder that would no longer be ignored at the destination, and refuses the move when those files would become exposed.
    • Duplicate key holders are no longer reported when multiple matching blocks contain the same primary fingerprint.

Part of #2157. Behaviour-preserving extractions, comments moved verbatim:

- blocksHolding (CCN 19 to 14): the key normalisation moves to bareKey()
  (3) and the end-of-block test to addHolder() (4), in an anonymous
  namespace.
- RealPass::refuseIgnoredThatMoves (CCN 19 to 13): the check-ignore -v
  rule walk moves to ignoredByRulesWithin() (4), still only asked when
  the landing does not exist, and the exposed-file list to
  exposedWhereLanded() (4).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Anne Jan Brouwer <[email protected]>
@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The PR extracts key normalization and holder collection from blocksHolding into helpers. It also extracts ignore-rule lookup and landed-path exposure checks from refuseIgnoredThatMoves, while retaining the existing destination-ignore lookup and refusal behavior.

Changes: Key holder collection

Layer / File(s) Summary
Key normalization and holder collection
src/gpgkeystate.cpp
blocksHolding uses bareKey to normalize the requested key and addHolder to collect matching, nonempty primary fingerprints without duplicates.

Ignored files during moves

Layer / File(s) Summary
Ignore-rule lookup and exposure check
src/realpass.h, src/realpass.cpp
ignoredByRulesWithin collects moving paths matched by ignore rules within the source folder. exposedWhereLanded identifies paths that are no longer ignored at their destination and are not covered by a travelling rule. refuseIgnoredThatMoves uses these helpers.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related issues

  • IJHack/QtPass#2157 tracks blocksHolding and RealPass::refuseIgnoredThatMoves as functions to split. This PR extracts helpers from both functions, though the issue also tracks other items.

Possibly related PRs

  • IJHack/QtPass#2383: This PR extracts helpers from the blocksHolding() function introduced in that PR.

Suggested reviewers: nogeenhenk

Merge Risk: Minimal · up to aae2f

This refactor splits two complex functions into helpers without changing behavior. No concrete risk was found, so it looks safe to merge.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two functions this PR refactors, blocksHolding and RealPass::refuseIgnoredThatMoves. The PR splits each into helpers (bareKey, addHolder, ignoredByRulesWithin, exposedWhereLanded) …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two functions this PR refactors, blocksHolding and RealPass::refuseIgnoredThatMoves. The PR splits each into helpers (bareKey, addHolder, ignoredByRulesWithin, exposedWhereLanded) to lower cyclomatic complexity, with behavior preserved. The title describes the main change accurately, though it does not say the change is a behavior-preserving refactor.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit checks each key with care,
Then gathers fingerprints to share.
Ignored paths are traced along,
To see if rules still keep them strong.
The helpers hop into the flow,
And mark which paths are free to go.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI (base), Organization UI (inherited)
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 38e9f681-6ace-4be1-b5cb-e9f2da18edee
Commits

Reviewing files that changed from the base of the PR and between ffa74be and aae2f49.

Files selected for processing: 3

  • src/gpgkeystate.cpp
  • src/realpass.cpp
  • src/realpass.h

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

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

Reviewed at aae2f49. The eighth refactor for #2157; only the structure changes.

  • blocksHolding: bareKey() is the old normalisation (trim, upper case, trailing !, 0x) and addHolder() the old test in endBlock; the empty-key return and the block walk are unchanged.
  • refuseIgnoredThatMoves: ignoredByRulesWithin() runs only when the landing does not exist, as the old && did, and returns the same list; a failed lookup still gives an empty one. exposedWhereLanded() is the old loop. The ignore lookup at the landing and the refusal after it stay in place.

Nothing to add.


Generated by Claude Code

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 94.496% (-0.09%) from 94.582% — refactor/complexity-2157-b8 into main

@annejan
annejan merged commit 9ec41c8 into main Dec 1, 2026
33 checks passed
@annejan
annejan deleted the refactor/complexity-2157-b8 branch December 1, 2026 04:42
@annejan annejan mentioned this pull request Dec 1, 2026
25 of 40 tasks
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.

3 participants