Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single-branch if shouldn't be replaced by when. #2

Open
technomancy opened this issue Mar 4, 2012 · 7 comments
Labels

Comments

@technomancy
Copy link
Contributor

@technomancy technomancy commented Mar 4, 2012

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.

@AlexBaranosky

This comment has been minimized.

Copy link

@AlexBaranosky AlexBaranosky commented Mar 4, 2012

Maybe what we really need is an easy way to configure which substitutions different users prefer?

@cemerick

This comment has been minimized.

Copy link
Contributor

@cemerick cemerick commented Sep 28, 2012

The battle continues. ;-) +1 for @AlexBaranosky's suggestion.

@jonase

This comment has been minimized.

Copy link
Owner

@jonase jonase commented Sep 28, 2012

Is this rule causing problems? Are you getting pull requests from users who have run kibit on your project and you don't agree with the changes (I've seen this happen)? If that's the case I'd rather just remove the rule for now until I find time to revisit this project.

@cemerick

This comment has been minimized.

Copy link
Contributor

@cemerick cemerick commented Sep 28, 2012

My apologies; I saw this issue on my way to creating #52, so perhaps the +1 wasn't especially valuable.

@technomancy

This comment has been minimized.

Copy link
Contributor Author

@technomancy technomancy commented Nov 20, 2012

@jonase yeah, I would like to use Kibit on Leiningen, but the amount of noise generated from this bug makes it annoying to try it out.

@Raynes

This comment has been minimized.

Copy link
Contributor

@Raynes Raynes commented Nov 26, 2012

I strongly disagree that this is a 'bug' of any sort. I personally prefer when for single branch ifs and would be disappointed if this got removed entirely.

@danielcompton

This comment has been minimized.

Copy link
Collaborator

@danielcompton danielcompton commented Nov 10, 2014

I'm inclined to agree with @technomancy on this. I propose removing single-branch if -> when rules, but making them available through add-on custom rules #66. Thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.