adafruit / Adafruit_CircuitPython_EPD

e paper driver for circuit python
MIT License
40 stars 19 forks source link

Code fails duplicate-code check, consider refactor #58

Open evaherrada opened 2 years ago

evaherrada commented 2 years ago

https://github.com/adafruit/Adafruit_CircuitPython_EPD/runs/6993434800?check_suite_focus=true#step:11:33

kattni commented 2 years ago

Assigning Tekktrik as well to look into this. We'll work together to decide what the best solution is.

tekktrik commented 2 years ago

This looks like code that can be refactored, given how extensive the duplications are.

tekktrik commented 2 years ago

This library is a candidate for refactoring based on pylint warning of duplicate code. The solution for this library would be to refactor the code to not have duplicated portions of code. In most cases, this might mean making base classes/functions so code can be recycled, but in some cases it may mean removing duplicate functionality (e.g., for compatibility).

To determine the duplicate code section, allow pylint to warn against duplicated code by removing ,duplicate-code from .pre-commit-config.yaml and then running pre-commit:

https://github.com/adafruit/Adafruit_CircuitPython_EPD/blob/67508b4409b4a4bae5bf60ee99b0b140fed2dfde/.pre-commit-config.yaml#L27

Then, refactor the duplicated code sections until it passes pre-commit. The modified .pre-commit-config.yaml file and refactored code can then be submitted as a PR.