`implicit_return` doesn't trigger for if/switch expressions
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Swift
- Stars
- 19.7k
- Forks
- 2.3k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 11
Description
Bug Description
The implicit_return rule does not trigger in cases where an if or switch is used as the only expression in a function, and each branch consists of only a single return statement:
// This does not trigger a violation:
func test() -> String {
if .random() {
return "A"
} else {
return "B"
}
}
Mention the command or other SwiftLint integration method that caused the issue. Include stack traces or command output.
$ swiftlint
Environment
- SwiftLint version: 0.59.1
- Xcode version: Xcode 16.4 (16F6)
- Installation method used: built from source
- Configuration file:
enabled_rules: - implicit_return
- no nested configurations
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running swiftlint with the shown enabled_rules configuration against the example, then locate the implicit_return rule implementation and its tests. Confirm that the if/switch single-return cases are reported while existing behavior remains unchanged.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100