File querying_pubchem_api.py
has 326 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""
PubChem querying API.
"""
from __future__ import annotations
Function _strip_by_key_in_place
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _strip_by_key_in_place(self, data: Union[dict, list], bad_key: str) -> None:
if isinstance(data, list):
for x in data:
self._strip_by_key_in_place(x, bad_key)
elif isinstance(data, dict):
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _get_metadata
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_metadata(
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(
Function fetch_properties
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def fetch_properties(self, cid: int) -> Mapping[str, Any]:
url = f"{self._pug}/compound/cid/{cid}/JSON"
#
try:
matches: NestedDotDict = self._query_json(url)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _scrape_cid
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _scrape_cid(self, inchikey: str) -> int:
# This is awful
# Every attempt to get the actual, correct, unique CID corresponding to the inchikey
# failed with every proper PubChem API
# We can't use <pug_view>/data/compound/<inchikey> -- we can only use a CID there
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"