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

Method/function-wide IF statement #81

Open
aik099 opened this issue Jun 4, 2015 · 0 comments
Open

Method/function-wide IF statement #81

aik099 opened this issue Jun 4, 2015 · 0 comments

Comments

@aik099
Copy link
Owner

aik099 commented Jun 4, 2015

When large IF statement is extracted, during refactoring, to separate method it's important to transform it the way that it will exit method immediately using inverted condition to decrease nesting level in that method.

If transformation wasn't made by developer and method has method-wide IF statement, then this must be reported as an error.

Before:

...
if ( $condition ) {
    // some stuff
}
...

After:

...
function someStuff()
{
    if ( !$condition ) {
        return;
    }

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

No branches or pull requests

1 participant