clj-commons / clj-commons/kibit
Single-branch if shouldn't be replaced by when.
- Dominant language
- Clojure
- Stars
- 1.8k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
The readme says that if it finds the code `(if (some test) (some action) nil)` it will suggest replacing it with `while`. I think it means `when`, but this isn't right; single-branched `if` forms are totally acceptable if the focus is on the return value. Since `when` has an implicit `do` form, it is a way of signaling to readers that side-effects are involved, while `if` forms are all about what value is returned. Instead consider adding a rule for replacing `(if cond (do some action))` with `when`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the README section describing the single-branch if suggestion, then locate the existing rule that matches `(if (some test) (some action) nil)` and its surrounding behavior. Confirm whether the documentation or rule is wrong, and verify that the resulting suggestions distinguish return-value-oriented `if` forms from side-effect-oriented `(if cond (do some action))` forms.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- clojure
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100