bel/nanopub/validate.py

Summary

Maintainability
D
1 day
Test Coverage

File validate.py has 316 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Standard Library
import copy
import re
from typing import List, Tuple

Severity: Minor
Found in bel/nanopub/validate.py - About 3 hrs to fix

    Function validate_annotation has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_annotation(annotation):
        """Check elasticsearch index for annotation term"""
    
        if not annotation.get("hash", False):
            annotation_str = get_annotation_str(annotation)
    Severity: Minor
    Found in bel/nanopub/validate.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

    Function validate_sections has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_sections(nanopub: NanopubR, validation_level: str = "complete") -> NanopubR:
        """Validate Nanopub sections"""
    
        if not isinstance(nanopub, dict):
            nanopub = nanopub.dict(exclude_unset=True, exclude_none=True)
    Severity: Minor
    Found in bel/nanopub/validate.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 validate_annotations has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_annotations(annotations: List[dict], validation_level: str):
        """Validate annotations
    
        Args:
            annotations (List[dict]): List of annotation objects
    Severity: Minor
    Found in bel/nanopub/validate.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 validate_assertion has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_assertion(assertion_obj: AssertionStr, *, version: str = "latest"):
        """ Validate single assertion """
    
        bo = bel.lang.belobj.BEL(assertion_obj, version=version)
    
    
    Severity: Minor
    Found in bel/nanopub/validate.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 validate_assertions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def validate_assertions(
        assertions: List[dict], *, version: str = "latest", validation_level: str = "complete"
    ):
        """Validate assertions
    
    
    Severity: Minor
    Found in bel/nanopub/validate.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

    Function get_cached_assertion_validations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_cached_assertion_validations(assertions, validation_level):
        """ Collect cached validations for assertions"""
    
        # Get hash keys for missing validations
        hashes = []
    Severity: Minor
    Found in bel/nanopub/validate.py - About 35 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

    Function get_cached_annotation_validations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_cached_annotation_validations(annotations):
        """ Collect cached validations for annotations"""
    
        # Get hash keys for missing validations
        hashes = []
    Severity: Minor
    Found in bel/nanopub/validate.py - About 35 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