-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
Redundant Tenary Check Added #2902
base: master
Are you sure you want to change the base?
Redundant Tenary Check Added #2902
Conversation
Added RedundantTernaryViolation to best_practices.py with code 475. The error template for this code is set to 'Found redundant ternary operator'. Added RedundantTernaryVisistor to redundancy.py. This visistor checks for all the cases mentioned in the original issue request. Added The RedundantTernaryVisistor to the list of visitors in tree.py. Added a test case for the RedundantTernaryVisistor to new file test_redundant_ternary.py. Added 3 test cases to noqa.py to test the new check under code 475. Reflected this in test_noqa.py.
My apologies if I was supposed to update Changelog.md, and the documentation before PR 😅 |
tests/test_visitors/test_ast/test_redundancy/test_redundant_ternary.py
Outdated
Show resolved
Hide resolved
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
I believe I have resolved all the requested changes! I am currently getting an error on my build for 99.98% test coverage but 0 failed? Not sure how to resolve this. |
There are some paths that are not covered. Run related tests locally and open |
Removed if statement for allowed ops, and length of operators, the if statement was never false Removed generator which checked for allowed ops
tests/test_visitors/test_ast/test_redundancy/test_redundant_ternary.py
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2902 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 122 122
Lines 6564 6653 +89
Branches 1556 1571 +15
=========================================
+ Hits 6564 6653 +89 ☔ View full report in Codecov by Sentry. |
Haven't removed other tests because those are needed for complete coverage
Hey @sobolevn, sorry for the inconvenience but I am not sure if I resolved your suggestion. I removed all but 3 tests, I left correct ternary in because without it I don't reach coverage on the false cases for the if statements in redundancy.py |
I resolved the previous conversation based on the reductions I made to the test_redundant_ternary.py file. I didn't completely remove the test_correct_ternary, as that appears to be needed for 100% coverage of my code. |
Added usless ternary rule
Checklist
CHANGELOG.md
Last Commit on my branch
Added RedundantTernaryViolation to best_practices.py with code 475. The error template for this code is set to 'Found redundant ternary operator'. Added RedundantTernaryVisistor to redundancy.py. This visistor checks for all the cases mentioned in the original issue request. Added The RedundantTernaryVisistor to the list of visitors in tree.py. Added a test case for the RedundantTernaryVisistor to new file test_redundant_ternary.py. Added 3 test cases to noqa.py to test the new check under code 475. Reflected this in test_noqa.py.
Related issues
🙏 Please, if you or your company is finding wemake-python-styleguide valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/wemake-python-styleguide. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.