internetarchive / openlibrary

One webpage for every book ever published!
https://openlibrary.org
GNU Affero General Public License v3.0
4.99k stars 1.25k forks source link

Code complexity: `update_keys()` in `solr/update_work.py` is too complex #7885

Open cclauss opened 1 year ago

cclauss commented 1 year ago

A continuation of #7883

The update_keys() async function in openlibrary/solr/update_work.py is 145+ lines long and is too complex... https://github.com/internetarchive/openlibrary/blob/112b89b2b5a37262664cd0f7647939a670e04833/openlibrary/solr/update_work.py#L1382-L1528

openlibrary/solr/update_work.py:1382:11: C901 `update_keys` is too complex (31 > 28)
openlibrary/solr/update_work.py:1382:11: PLR0912 Too many branches (24 > 22)
openlibrary/solr/update_work.py:1382:11: PLR0915 Too many statements (83 > 70)

Tasks:

scottbarnes commented 1 year ago

In case it's any help, here's the current state of test coverage for update_keys(), where the red lines are not executed. Rather than despairing, I am interpreting this to mean there's lots of opportunity to write great new tests. image image