bel/belspec/enhance.py

Summary

Maintainability
D
2 days
Test Coverage

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
    """
Severity: Minor
Found in bel/belspec/enhance.py - About 7 hrs to fix

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.
Severity: Minor
Found in bel/belspec/enhance.py - About 6 hrs to fix

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
Severity: Minor
Found in bel/belspec/enhance.py - About 2 hrs to fix

    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":
    Severity: Major
    Found in bel/belspec/enhance.py - About 45 mins to fix

      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"])
      
      
      Severity: Major
      Found in bel/belspec/enhance.py - About 45 mins to fix

        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 += "*"
        Severity: Major
        Found in bel/belspec/enhance.py - About 45 mins to fix

          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", []))
          Severity: Major
          Found in bel/belspec/enhance.py - About 45 mins to fix

            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"])
            
            
            Severity: Major
            Found in bel/belspec/enhance.py - About 45 mins to fix

              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"])
              
              
              Severity: Major
              Found in bel/belspec/enhance.py - About 45 mins to fix

                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"] = []
                Severity: Minor
                Found in bel/belspec/enhance.py - About 25 mins to fix

                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

                There are no issues that match your filters.

                Category
                Status