afonasev / flake8-return

Flake8 plugin for return expressions checking.
MIT License
62 stars 69 forks source link

Port no-else-break, no-else-continue, no-else-raise, no-else-return from pylint #122

Closed calumy closed 1 year ago

calumy commented 1 year ago

This PR ports the listed checks from pylint for reasons described in #14.

Test cases for each check taken from pylint tests:

codecov[bot] commented 1 year ago

Codecov Report

Base: 94.04% // Head: 90.52% // Decreases project coverage by -3.52% :warning:

Coverage data is based on head (bea3b13) compared to base (3bba9cd). Patch coverage: 88.31% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #122 +/- ## ========================================== - Coverage 94.04% 90.52% -3.53% ========================================== Files 3 9 +6 Lines 168 285 +117 Branches 35 75 +40 ========================================== + Hits 158 258 +100 - Misses 5 22 +17 Partials 5 5 ``` | [Impacted Files](https://codecov.io/gh/afonasev/flake8-return/pull/122?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy) | Coverage Δ | | |---|---|---| | [flake8\_return/mixins/unnecessary\_assign.py](https://codecov.io/gh/afonasev/flake8-return/pull/122/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy#diff-Zmxha2U4X3JldHVybi9taXhpbnMvdW5uZWNlc3NhcnlfYXNzaWduLnB5) | `75.67% <75.67%> (ø)` | | | [flake8\_return/errors.py](https://codecov.io/gh/afonasev/flake8-return/pull/122/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy#diff-Zmxha2U4X3JldHVybi9lcnJvcnMucHk=) | `100.00% <100.00%> (ø)` | | | [flake8\_return/mixins/implicit\_return.py](https://codecov.io/gh/afonasev/flake8-return/pull/122/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy#diff-Zmxha2U4X3JldHVybi9taXhpbnMvaW1wbGljaXRfcmV0dXJuLnB5) | `100.00% <100.00%> (ø)` | | | [flake8\_return/mixins/implicit\_return\_value.py](https://codecov.io/gh/afonasev/flake8-return/pull/122/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy#diff-Zmxha2U4X3JldHVybi9taXhpbnMvaW1wbGljaXRfcmV0dXJuX3ZhbHVlLnB5) | `100.00% <100.00%> (ø)` | | | [flake8\_return/mixins/superfluous\_return.py](https://codecov.io/gh/afonasev/flake8-return/pull/122/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy#diff-Zmxha2U4X3JldHVybi9taXhpbnMvc3VwZXJmbHVvdXNfcmV0dXJuLnB5) | `100.00% <100.00%> (ø)` | | | [flake8\_return/mixins/unnecessary\_return\_none.py](https://codecov.io/gh/afonasev/flake8-return/pull/122/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy#diff-Zmxha2U4X3JldHVybi9taXhpbnMvdW5uZWNlc3NhcnlfcmV0dXJuX25vbmUucHk=) | `100.00% <100.00%> (ø)` | | | [flake8\_return/stack\_keys.py](https://codecov.io/gh/afonasev/flake8-return/pull/122/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy#diff-Zmxha2U4X3JldHVybi9zdGFja19rZXlzLnB5) | `100.00% <100.00%> (ø)` | | | [flake8\_return/visitors.py](https://codecov.io/gh/afonasev/flake8-return/pull/122/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy#diff-Zmxha2U4X3JldHVybi92aXNpdG9ycy5weQ==) | `100.00% <100.00%> (+6.71%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Afonasev+Evgeniy)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

calumy commented 1 year ago

I have separated the mixins into a subdirectory due to the failing ci due to too many lines in visitors.py file. Please let me know if this should be reverted.

afonasev commented 1 year ago

Thx for your contribution! 👍