bel/cli/scripts.py

Summary

Maintainability
C
1 day
Test Coverage

Function nanopub_stats has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

def nanopub_stats(ctx, input_fn):
    """Collect statistics on nanopub file

    input_fn can be json, jsonl or yaml and additionally gzipped
    """
Severity: Minor
Found in bel/cli/scripts.py - About 3 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 scripts.py has 283 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Standard Library
import gzip
import json
import re
import sys
Severity: Minor
Found in bel/cli/scripts.py - About 2 hrs to fix

    Function convert_belscript has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def convert_belscript(ctx, input_fn, output_fn):
        """Convert belscript to nanopubs_bel format
    
        This will convert the OpenBEL BELScript file format to
        nanopub_bel-1.0.0 format.
    Severity: Minor
    Found in bel/cli/scripts.py - About 1 hr 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 reformat has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def reformat(ctx, input_fn, output_fn):
        """Reformat between JSON, YAML, JSONLines formats
    
        \b
        input_fn:
    Severity: Minor
    Found in bel/cli/scripts.py - About 55 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

    Avoid deeply nested control flow statements.
    Open

                        if re.match("\s*\(", assertion["object"]):
                            counts["assertions"]["nested"] += 1
    
    
    Severity: Major
    Found in bel/cli/scripts.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if not assertion.get("relation") in counts["assertions"]["relations"]:
                              counts["assertions"]["relations"][assertion.get("relation")] = 1
                          else:
                              counts["assertions"]["relations"][assertion.get("relation")] += 1
      
      
      Severity: Major
      Found in bel/cli/scripts.py - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status