Function add_function_signature_help
has a Cognitive Complexity of 50 (exceeds 5 allowed). Consider refactoring. Open
def add_function_signature_help(specification: dict) -> dict:
"""Add function signature help
Simplify the function signatures for presentation to BEL Editor users
"""
- 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 enhance_function_signatures
has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring. Open
def enhance_function_signatures(specification: Mapping[str, Any]) -> Mapping[str, Any]:
"""Enhance function signatures
Add required and optional objects to signatures objects for semantic validation
support.
- 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
File enhance.py
has 258 lines of code (exceeds 250 allowed). Consider refactoring. Open
"""Enhance the BEL Specification YAML file for easier use by BEL package"""
# Standard Library
import copy
import re
from typing import Any, List, Mapping
Avoid deeply nested control flow statements. Open
if arg.get("optional", False) and arg.get("multiple", False) is False:
args_summary += "?"
if arg["type"] in ["NSArg"]:
text = f'Zero or one namespace argument of following type(s): {", ".join([val for val in arg["values"]])}'
elif arg["type"] == "StrArgNSArg":
Avoid deeply nested control flow statements. Open
if arg["type"] in ["Function", "Modifier"]:
opt_args.extend(arg.get("values", []))
elif arg["type"] in ["StrArgNSArg", "NSArg", "StrArg"]:
opt_args.append(arg["type"])
Avoid deeply nested control flow statements. Open
if arg.get("optional", False) and arg.get("multiple", False) is False:
args_summary += "?"
text = f'Zero or one of each function(s): {", ".join([val for val in arg["values"]])}'
elif arg.get("optional", False):
args_summary += "*"
Avoid deeply nested control flow statements. Open
if arg["type"] in ["Function", "Modifier"]:
mult_args.extend(arg.get("values", []))
elif arg["type"] in ["NSArg"]:
# Complex and Composite signature has this
mult_args.extend(arg.get("values", []))
Avoid deeply nested control flow statements. Open
if arg["type"] in ["Function", "Modifier"]:
pos_args.append(arg.get("values", []))
elif arg["type"] in ["StrArgNSArg", "NSArg", "StrArg"]:
pos_args.append(arg["type"])
Avoid deeply nested control flow statements. Open
if arg["type"] in ["Function", "Modifier"]:
req_args.append(arg.get("values", []))
elif arg["type"] in ["StrArgNSArg", "NSArg", "StrArg"]:
req_args.append(arg["type"])
Function add_namespaces
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_namespaces(specification):
"""Add namespace convenience keys, list, list_{short|long}, to_{short|long}"""
for ns in specification["namespaces"]:
specification["namespaces"][ns]["list"] = []
- 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"