bel/schemas/bel.py

Summary

Maintainability
C
1 day
Test Coverage

File bel.py has 386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# Standard Library
import copy
import enum
import json
import re
Severity: Minor
Found in bel/schemas/bel.py - About 5 hrs to fix

    Function collect_orthologs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def collect_orthologs(self, species_keys: List[Key] = settings.BEL_ORTHOLOGIZE_TARGETS):
            """Get orthologs for BelEntity is orthologizable"""
    
            self.add_entity_types()
            self.normalize()
    Severity: Minor
    Found in bel/schemas/bel.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

    Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Minor
    Found in bel/schemas/bel.py - About 35 mins to fix

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

          def normalize(
              self,
              canonical_targets: Mapping[str, List[str]] = settings.BEL_CANONICALIZE,
              decanonical_targets: Mapping[str, List[str]] = settings.BEL_DECANONICALIZE,
          ):
      Severity: Minor
      Found in bel/schemas/bel.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 add_term has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_term(self):
              """Add term info"""
      
              if self.namespace_metadata and self.namespace_metadata.namespace_type == "complete":
                  self.term = bel.terms.terms.get_term(self.nsval.key)
      Severity: Minor
      Found in bel/schemas/bel.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 __init__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, term_key: Key = "", nsval: Optional[NsVal] = None):
              """Create BelEntity via a term_key or a NsVal object
      
              You cannot provide a term_key_label string (e.g. NS:ID:LABEL) as a term_key
              """
      Severity: Minor
      Found in bel/schemas/bel.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 add_entity_types has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def add_entity_types(self):
              """get entity_types to BEL Entity"""
      
              if self.entity_types:
                  return self
      Severity: Minor
      Found in bel/schemas/bel.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