lbl-anp / becquerel

Becquerel is a Python package for analyzing nuclear spectroscopic measurements.
Other
43 stars 16 forks source link

high cyclomatic complexity scores #387

Open jvavrek opened 7 months ago

jvavrek commented 7 months ago

We should aim to reduce the cyclomatic complexity of some of our code to around 20 or below:

❯ 🅒 myenv jvavrek in becquerel on  main flake8 . --max-complexity=20
./becquerel/core/calibration.py:180:1: C901 '_validate_expression' is too complex (21)
./becquerel/core/fitting.py:750:5: C901 'Fitter.fit' is too complex (25)
./becquerel/parsers/cnf.py:78:1: C901 'read' is too complex (54)
./becquerel/parsers/iec1455.py:32:1: C901 'read' is too complex (37)
./becquerel/parsers/spc.py:182:1: C901 'read' is too complex (40)
./becquerel/parsers/spe.py:11:1: C901 'read' is too complex (27)
./becquerel/tools/nndc.py:205:1: C901 '_parse_float_uncertainty' is too complex (23)

It's mostly the read methods with high complexity scores, which is probably fine, since there are a lot of branches necessary to read different fields. But we could potentially extract out some methods to knock those scores down. And we could probably improve Fitter.fit and the other non-read methods.