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.

@atodorov atodorov force-pushed the MrSenko:new_checker_useless_return branch from 1bcc0c0 to f80d14a Jan 5, 2018
Copy link
Member

@PCManticore PCManticore left a comment

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 '

This comment has been minimized.

@PCManticore

PCManticore Jan 23, 2018
Member

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

This comment has been minimized.

@PCManticore

PCManticore Jan 23, 2018
Member

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 atodorov force-pushed the MrSenko:new_checker_useless_return branch from f80d14a to 7fc4fc5 Jan 23, 2018
@atodorov
Copy link
Contributor Author

@atodorov atodorov commented Jan 23, 2018

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
@atodorov atodorov force-pushed the MrSenko:new_checker_useless_return branch from 7fc4fc5 to cf54954 Jan 23, 2018
@PCManticore
Copy link
Member

@PCManticore PCManticore commented Jan 25, 2018

Thank you @atodorov !

@PCManticore PCManticore merged commit 95269d7 into PyCQA:master Jan 25, 2018
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.