Skip to content

Conversation

@codyoss
Copy link
Contributor

@codyoss codyoss commented Nov 6, 2018

No description provided.

golint asks to remove else blocks when returning to improve readability.
@PeterIvanov PeterIvanov self-requested a review November 6, 2018 05:35

if areAllOfTheSameType(errs...) {
return WrapMany(transparentWrapper, message, errs...)
} else {
Copy link
Collaborator

@PeterIvanov PeterIvanov Nov 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a thing here that annoys me a little. Here's a guideline we are trying to comply with here:
https://github.com/golang/go/wiki/CodeReviewComments#indent-error-flow
And it goes well when there is a 'negative' branch (greater indentation) and a 'positive' branch (minimal indentation).
Here, on the other hand, there a 2 positive branches, so it seems that changing the code in this manner actually makes it send a wrong message to a reader.
Thoughts?

As for other similar fixes in this PR, I suggest we apply the same rule. If we apply this guideline, at least it should show what is considered a 'positive' codepath.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You bring up a good point. In the example you highlighted I would argue that !areAllOfTheSameType would be the negative, so the logic should be reversed. As for the others I think the ones in builder.go could also be flipped. Final choice is yours. If you prefer to leave these I can remove them from the PR and just leave the doc fix. Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main point is whether or not linter is being a little too zealous here. I originally felt like it is, and that's why those reports remained unsolved until now. But if you feel otherwise, I'm ready to reconsider.
Could you please modify this PR so that this rule of positive path is best respected, and then I'll make comments if I disagree with some of those choices?

Copy link
Collaborator

@PeterIvanov PeterIvanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
Please address one small remaining issue and I'm ready to merge this PR.

switch.go Outdated
package errorx

// CaseNoTrait is a synthetic type used in TypeSwitch, signifying a presence of non-nil error of some other type.
// NotRecognisedType is a synthetic type used in TypeSwitch, signifying casting error to *Error failed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, not only that. Any type not expected in a switch, too.
So I suggest leaving the second half unchanged.

@codyoss
Copy link
Contributor Author

codyoss commented Nov 8, 2018

If you would like me to squash those back down to two commits lmk. Btw, cool project.

Copy link
Collaborator

@PeterIvanov PeterIvanov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!
I don't see any need for a squash, so I'll merge this as it is if it's OK with you.

@PeterIvanov PeterIvanov merged commit 2955085 into joomcode:master Nov 8, 2018
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

Successfully merging this pull request may close these issues.

2 participants