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

Redundant Tenary Check Added #2902

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

FieldMarshallObvious
Copy link

@FieldMarshallObvious FieldMarshallObvious commented Mar 28, 2024

Added usless ternary rule

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • 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.

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.
@FieldMarshallObvious
Copy link
Author

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

tests/fixtures/noqa/noqa.py Outdated Show resolved Hide resolved
wemake_python_styleguide/violations/best_practices.py Outdated Show resolved Hide resolved
wemake_python_styleguide/violations/best_practices.py Outdated Show resolved Hide resolved
wemake_python_styleguide/violations/best_practices.py Outdated Show resolved Hide resolved
wemake_python_styleguide/visitors/ast/redundancy.py Outdated Show resolved Hide resolved
wemake_python_styleguide/visitors/ast/redundancy.py Outdated Show resolved Hide resolved
wemake_python_styleguide/visitors/ast/redundancy.py Outdated Show resolved Hide resolved
wemake_python_styleguide/visitors/ast/redundancy.py Outdated Show resolved Hide resolved
wemake_python_styleguide/visitors/ast/redundancy.py Outdated Show resolved Hide resolved
@FieldMarshallObvious
Copy link
Author

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.

@sobolevn
Copy link
Member

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.

Removed if statement for allowed ops, and length of operators, the if statement was never false
Removed generator which checked for allowed ops
Copy link

codecov bot commented Mar 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

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

❗ 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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Haven't removed other tests because those are needed for complete coverage
@FieldMarshallObvious
Copy link
Author

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
Copy link
Author

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.

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.

2 participants