You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
force_unwrapping: provide opt-out for default ignored_literal_argument_functions exemptions #6675
Not strictly a bug, closer to a missing capability for teams with strict force-unwrap policies.
The ignored_literal_argument_functions option on force_unwrapping (added in #6490, 0.63.3) is intentionally additive: the postprocessor on the config element unions five built-in defaults (URL(string:), NSURL(string:), UIImage(named:), NSImage(named:), Data(hexString:)) into the user-supplied set after parsing.
The limitation is that there's no way for a user to opt out of those five defaults. Some codebases treat any force-unwrap as a code smell, even of compile-time literals, because the literal might still be invalid:
leturl=URL(string:"")! // crashes
letimg=UIImage(named:"renamedAsset")! // crashes when asset is moved/renamed
For those teams, the new exemption silently loosens force_unwrapping with no config path to restore strict policing. Pinning to 0.63.2 is currently the only workaround, which leaves users stuck on an older release.
$ swiftlint lint --no-cache test.swift
Done linting! Found 0 violations, 0 serious in 1 file.
Expected: both lines trigger force_unwrapping. Actual: zero violations regardless of what the user puts in ignored_literal_argument_functions ([], ["DummyOnly"], etc.), the defaults are always merged in.
Environment
SwiftLint version: 0.63.3
Xcode version: 26.3
Installation method: Homebrew
Configuration file:
opt_in_rules:
- force_unwrappingforce_unwrapping:
ignored_literal_argument_functions: [] # has no effect; defaults still apply
changed the title [-]force_unwrapping: `ignored_literal_argument_functions` cannot remove default exemptions[/-][+]force_unwrapping: provide opt-out for default `ignored_literal_argument_functions` default exemptions[/+]on May 28, 2026
changed the title [-]force_unwrapping: provide opt-out for default `ignored_literal_argument_functions` default exemptions[/-][+]force_unwrapping: provide opt-out for default `ignored_literal_argument_functions` exemptions[/+]on May 28, 2026
Activity
[-]force_unwrapping: `ignored_literal_argument_functions` cannot remove default exemptions[/-][+]force_unwrapping: provide opt-out for default `ignored_literal_argument_functions` default exemptions[/+][-]force_unwrapping: provide opt-out for default `ignored_literal_argument_functions` default exemptions[/-][+]force_unwrapping: provide opt-out for default `ignored_literal_argument_functions` exemptions[/+]SimplyDanny commentedon May 28, 2026
You are right. That's problematic. I've prepared #6677 to make the defaults replaceable.