bel/terms/terms.py

Summary

Maintainability
D
2 days
Test Coverage

File terms.py has 458 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Standard Library
import re
import time
from typing import Any, List, Mapping, Optional, Union

Severity: Minor
Found in bel/terms/terms.py - About 7 hrs to fix

    Function get_term_completions has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_term_completions(
        completion_text: str,
        size: int = 10,
        entity_types: List[str] = None,
        annotation_types: List[str] = None,
    Severity: Minor
    Found in bel/terms/terms.py - About 4 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 get_normalized_terms has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_normalized_terms(
        term_key: Key,
        canonical_targets: Mapping[str, List[str]] = settings.BEL_CANONICALIZE,
        decanonical_targets: Mapping[str, List[str]] = settings.BEL_DECANONICALIZE,
        term: Optional[Term] = None,
    Severity: Minor
    Found in bel/terms/terms.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 get_term_completions has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def get_term_completions(
    Severity: Minor
    Found in bel/terms/terms.py - About 45 mins to fix

      Function get_term_search has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def get_term_search(search_term, size, entity_types, annotation_types, species, namespaces):
      Severity: Minor
      Found in bel/terms/terms.py - About 45 mins to fix

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

        def get_terms(term_key: Key) -> List[Term]:
            """Get term(s) using term_key - given term_key may match multiple term records
        
            Term Key can match the main key, alt_keys or obsolete_keys
            """
        Severity: Minor
        Found in bel/terms/terms.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_term has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_term(term_key: Key) -> Optional[Term]:
            """Expect one term to match term_key
        
            Term Key can match the main key, alt_keys or obsolete_keys
            """
        Severity: Minor
        Found in bel/terms/terms.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

        Function get_term_search has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def get_term_search(search_term, size, entity_types, annotation_types, species, namespaces):
            """Search for terms given search term"""
        
            if not size:
                size = 10
        Severity: Minor
        Found in bel/terms/terms.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