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

Add new checker useless-return #1823

Merged
merged 1 commit into from Jan 25, 2018

Conversation

atodorov
Copy link
Contributor

@atodorov atodorov commented Jan 5, 2018

Another take on #1821 only producing messages if there is ony 1 return statement at the end of the function.

Copy link
Contributor

@PCManticore PCManticore left a comment

Choose a reason for hiding this comment

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

This looks good. It will also need a ChangeLog entry as well as a What's new entry.

@@ -174,6 +174,11 @@ class RefactoringChecker(checkers.BaseTokenChecker):
'state this as return None, and an explicit return statement '
'should be present at the end of the function (if reachable)'
),
'R1711': ("Useless return at end of function or method",
'useless-return',
'Emitted when a single "return" or "return None" statement is found '
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add another sentence saying why this can be removed? e.g because the function has an implicit return of None etc.


"""Unittest for refactoring checker."""

import astroid
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually prefer functional tests for checks, please check the functional directory for examples. We only write specific unittests if we can't test the new check with a functional one.

@atodorov
Copy link
Contributor Author

All fixed, let me know if you have more comments.

warns about a single "return" or "return None" statement at the
end of functions or methods
@PCManticore
Copy link
Contributor

Thank you @atodorov !

@PCManticore PCManticore merged commit 95269d7 into pylint-dev:master Jan 25, 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.

None yet

2 participants