bel/resources/manage.py

Summary

Maintainability
B
5 hrs
Test Coverage

Function create_email_body_for_update_resources has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

def create_email_body_for_update_resources(results):
    """Create email message body for update_resources"""

    failures = [url for url in results if results[url]["state"] == "Failed"]
    warnings = [url for url in results if results[url]["state"] == "Warning"]
Severity: Minor
Found in bel/resources/manage.py - About 2 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 update_resources has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

def update_resources(urls: List[str] = None, force: bool = False, email: str = None):
    """Update bel resources

    Reads the arangodb resources_metadata objects to figure out what bel resource urls to process
    unless a url is provided to download (at which point it will be added to resources_metadata on
Severity: Minor
Found in bel/resources/manage.py - About 2 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 load_resource has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

def load_resource(resource_url: str = None, force: bool = False):
    """Load BEL Resource file

    Forceupdate will create a new index in Elasticsearch regardless of whether
    an index with the resource version already exists.
Severity: Minor
Found in bel/resources/manage.py - About 45 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