Adafruit_CircuitPython_RGB_Display icon indicating copy to clipboard operation
Adafruit_CircuitPython_RGB_Display copied to clipboard

Code fails duplicate-code check, consider refactor

Open evaherrada opened this issue 3 years ago • 3 comments

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

evaherrada avatar Jun 21 '22 21:06 evaherrada

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

kattni avatar Jun 21 '22 22:06 kattni

This looks like enough duplicate code to warrant a refactoring.

tekktrik avatar Jun 21 '22 22:06 tekktrik

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_RGB_Display/blob/2980a3f4efb4ea0894928826342942b6677ab006/.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.

tekktrik avatar Jun 22 '22 17:06 tekktrik