Skip to content

commands: replace force-unwrap with optional chaining in ImagePrune#1850

Open
ArasanDev wants to merge 1 commit into
apple:mainfrom
ArasanDev:fix/image-prune-force-unwrap
Open

commands: replace force-unwrap with optional chaining in ImagePrune#1850
ArasanDev wants to merge 1 commit into
apple:mainfrom
ArasanDev:fix/image-prune-force-unwrap

Conversation

@ArasanDev

Copy link
Copy Markdown

Type of Change

  • Bug fix

Motivation and Context

In ImagePrune.hasTag(_:), ref.tag is checked for nil and then immediately force-unwrapped on the same line:

return ref.tag != nil && !ref.tag!.isEmpty

This is unnecessary — Swift's optional chaining handles both cases without a crash risk:

return ref.tag?.isEmpty == false

This complies with the NeverForceUnwrap rule enforced by swift-format.

Testing

  • Tested locally
  • make test passes (561 tests)

@ArasanDev ArasanDev force-pushed the fix/image-prune-force-unwrap branch from 4136ff3 to 9e9417f Compare June 27, 2026 19:09
@ArasanDev ArasanDev force-pushed the fix/image-prune-force-unwrap branch from 9e9417f to 8eead96 Compare June 27, 2026 19:13
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.

1 participant