-
Notifications
You must be signed in to change notification settings - Fork 51
Early return sniff #22
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
Conversation
@kukulich Can I ask your help here? Am I missing something to get this to work? |
@carusogabriel Hmm, in yesterday perspective I thought that the code should not be reported because there's already "early exit" code in |
@carusogabriel Just for your info, there are three types of errors in this sniff: "Use early exit instead of else.", "Remove useless else to reduce code nesting." and "Use early exit to reduce code nesting.". It may be good to document and test all of them here. |
@kukulich Thanks, I'll add more test so |
@kukulich Thanks. Time to update some tests and untag WIP 👷♂️ |
Solving conflicts |
README.md
Outdated
- :white_check_mark: Omit phpDoc for parameters/returns with native types, unless adding description | ||
- :white_check_mark: Don't use `@author`, `@since` and similar annotations that duplicate Git information | ||
- :white_check_mark: Assignment in condition is not allowed | ||
- :white_check_mark: Use early return instead of `else` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is not true. The sniff does a little more :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a suggestion? 😄
lib/Doctrine/ruleset.xml
Outdated
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowYodaComparison"/> | ||
<!-- Forbid weak comparisons --> | ||
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowEqualOperators"/> | ||
<!-- Require usage of early exit instead of using else --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@carusogabriel The comment is not true. The sniff does a little more :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a suggestion? 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@carusogabriel There's bad indentation here: https://github.com/doctrine/coding-standard/pull/22/files#diff-50034f4d68d4e08b523b28d23715cd5fR34 And nothing should change in method |
@carusogabriel yeah, still some weirdness going on there :P |
Rebase also needed, sorry @carusogabriel! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
@carusogabriel thanks! Proceeding to release :) |
@Ocramius Perfect. Should we update across Doctrine's repos as well? |
@carusogabriel yeah, let's do that afterwards 👍 |
Based on doctrine/orm#6929, doctrine/mongodb-odm#1691, doctrine/orm#6889 and doctrine/dbal#2937