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

Determine if use of guard clauses should be enforced #452

Closed
craiglittle opened this issue Jan 24, 2016 · 5 comments
Closed

Determine if use of guard clauses should be enforced #452

craiglittle opened this issue Jan 24, 2016 · 5 comments

Comments

@craiglittle
Copy link
Contributor

As per @colszowka's request, this issue is for discussion between the contributors to determine if the Style/GuardClause cop should be enabled. This came up while bringing the codebase into compliance with the latest rubocop version. For the time being, the cop has been disabled.

Here's the existing method in the codebase that raised this question.

For what it's worth, my two cents: I like that the use of guard clauses, where appropriate, reduces the level of indentation in a method, so I'm in favor of enabling the cop.

@colszowka
Copy link
Collaborator

/cc @bf4 @sferik @xaviershay @amatsuda Gentlemen, what do you think?

Personally I'd prefer a simple if/else statement over a guard clause any time because it is easier to parse the control flow of the method this way imho, so I'd drop this particular cop.

@xaviershay
Copy link
Collaborator

I tend to prefer guard clause but don't think this is a thing that should be enforced by rubocop either way - depends on code context too much.

@sferik
Copy link
Collaborator

sferik commented Jan 26, 2016

👍 to what @xaviershay said.

@craiglittle
Copy link
Contributor Author

Agreed! Context matters a lot with this technique. I think it makes sense to proceed with the cop turned off.

Closing this out...

@colszowka
Copy link
Collaborator

Thanks for giving your thoughts everyone, let's keep it this way then! 👏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants