wemake-python-styleguide icon indicating copy to clipboard operation
wemake-python-styleguide copied to clipboard

Redundant Tenary Check Added

Open FieldMarshallObvious opened this issue 1 year ago • 6 comments

Added usless ternary rule

Checklist

  • [x] I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • [x] I have created at least one test case for the changes I have made
  • [ ] I have updated the documentation for the changes I have made
  • [ ] I have added my changes to the 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.

FieldMarshallObvious avatar Mar 28 '24 00:03 FieldMarshallObvious

My apologies if I was supposed to update Changelog.md, and the documentation before PR 😅

FieldMarshallObvious avatar Mar 28 '24 04:03 FieldMarshallObvious

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.

FieldMarshallObvious avatar Mar 28 '24 18:03 FieldMarshallObvious

There are some paths that are not covered. Run related tests locally and open htmlcov folder with human readable output, it will show which lines are not covered.

sobolevn avatar Mar 29 '24 10:03 sobolevn

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (a1107de) to head (95b7a62). Report is 75 commits behind head on master.

:exclamation: Current head 95b7a62 differs from pull request most recent head 17c31aa. Consider uploading reports for the commit 17c31aa to get more accurate results

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     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Mar 30 '24 08:03 codecov[bot]

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

FieldMarshallObvious avatar Apr 11 '24 16:04 FieldMarshallObvious

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.

FieldMarshallObvious avatar Apr 17 '24 15:04 FieldMarshallObvious