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
enhancementIdeas for improvements of existing features and rules.good first issueIssue to be taken up by new contributors yet unfamiliar with the project.
Please describe the rule idea, format this issue's title as Rule Request: [Rule Name] and describe:
Why should this rule be added? Share links to existing discussion about what
the community thinks about this.
force_unwrapping flags in cases where it is probably legitimate.
Provide several examples of what would and wouldn't trigger violations.
Should trigger:
let a = Data(hexString: someVar)! // argument is a variable
let a = URL(string: someVar)! // argument is variable
Should the rule be configurable, if so what parameters should be configurable?
Probably not outside of basing enable/disable.
Should the rule be opt-in or enabled by default? Why? See README.md for guidelines on when to mark a rule as opt-in.
Whatever current force_unwrapping is.
This is addressed by #6490, which adds a static_string_argument_functions configuration option to force_unwrapping. It ships with defaults covering exactly these cases (URL(string:), Data(hexString:), etc.) and allows users to add their own.
The approach was guided by the maintainer to be explicit about which function calls to ignore rather than doing broad static-string detection. Happy to hear your thoughts on the PR if you have additional functions you'd want in the defaults.
Thanks, yeah, this sounds like EXACTLY like I want!. You extended it to other types too. I was only thinking of Data/URL but there are other cases that would also have similar problems.
Glad it lines up with what you were looking for! Yeah, once the maintainer suggested the explicit allowlist approach, it made sense to cover the broader set of static-string initializers rather than just Data/URL. If you think of any other functions that should be in the defaults, feel free to drop them on the PR.
This is addressed by #6490 — it adds an allowlist for force-unwrapping when all arguments are static string literals, which covers the exact patterns you describe (URL(string:), Data(hexString:), etc.).
enhancementIdeas for improvements of existing features and rules.good first issueIssue to be taken up by new contributors yet unfamiliar with the project.
Activity
Skip force_unwrapping violations for calls with static string literal…
claudeaceae commentedon Feb 12, 2026
This is addressed by #6490, which adds a
static_string_argument_functionsconfiguration option toforce_unwrapping. It ships with defaults covering exactly these cases (URL(string:),Data(hexString:), etc.) and allows users to add their own.The approach was guided by the maintainer to be explicit about which function calls to ignore rather than doing broad static-string detection. Happy to hear your thoughts on the PR if you have additional functions you'd want in the defaults.
mlaster commentedon Feb 13, 2026
claudeaceae commentedon Feb 13, 2026
Glad it lines up with what you were looking for! Yeah, once the maintainer suggested the explicit allowlist approach, it made sense to cover the broader set of static-string initializers rather than just Data/URL. If you think of any other functions that should be in the defaults, feel free to drop them on the PR.
claudeaceae commentedon Feb 13, 2026
This is addressed by #6490 — it adds an allowlist for force-unwrapping when all arguments are static string literals, which covers the exact patterns you describe (URL(string:), Data(hexString:), etc.).