Showing 111 of 113 total issues

Function get_resources_handles has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

def get_resources_handles(client, username=None, password=None):
    """Get BEL Resources arangodb handle"""

    (username, password) = get_user_credentials(username, password)

Severity: Minor
Found in bel/db/arangodb.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 convert has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

def convert(ast):
    """Convert BEL1 AST Function to BEL2 AST Function"""

    if ast and ast.type == "Function":
        # Activity function conversion
Severity: Minor
Found in bel/lang/migrate_1_2.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

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 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 parse_belscript has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_belscript(lines):
        """Lines from the BELScript - can be an iterator or list
    
        yields Nanopubs in nanopubs_bel-1.0.0 format
        """
    Severity: Minor
    Found in bel/nanopub/belscripts.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 read_nanopubs has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

    def read_nanopubs(fn: str) -> Iterable[Mapping[str, Any]]:
        """Read file and generate nanopubs
    
        If filename has *.gz, will read as a gzip file
        If filename has *.jsonl*, will parsed as a JSONLines file
    Severity: Minor
    Found in bel/nanopub/files.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 __init__ has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(
            self,
            assertion: AssertionStr = None,
            subject: Optional[Function] = None,
            relation: Optional[Relation] = None,
    Severity: Minor
    Found in bel/lang/ast.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 batch_load_docs has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    def batch_load_docs(db, doc_iterator, on_duplicate: str = "replace"):
        """Batch load documents
    
        Args:
            db: ArangoDB client database handle
    Severity: Minor
    Found in bel/db/arangodb.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 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

    Consider simplifying this complex logical expression.
    Open

            if len(self.args) == 1 and self.args[0].type == "Function":
                self.subject = self.args[0]
            # Normal SRO BEL assertion
            elif (
                len(self.args) == 3
    Severity: Critical
    Found in bel/lang/ast.py - About 2 hrs to fix

      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

      File enhance.py has 258 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Enhance the BEL Specification YAML file for easier use by BEL package"""
      # Standard Library
      import copy
      import re
      from typing import Any, List, Mapping
      Severity: Minor
      Found in bel/belspec/enhance.py - About 2 hrs to fix

        File belscripts.py has 255 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/env python3.6
        # -*- coding: utf-8 -*-
        
        """
        Process belscripts content into nanopubs_bel-1.0.0 format for use in BEL.bio
        Severity: Minor
        Found in bel/nanopub/belscripts.py - About 2 hrs to fix

          Function orthologs_iterator has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

          def orthologs_iterator(fo, version, statistics: Mapping):
              """Ortholog node and edge iterator
          
              NOTE: the statistics dict works as a side effect since it is passed as a reference!!!
              """
          Severity: Minor
          Found in bel/resources/ortholog.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 find_strings has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          def find_strings(assertion_str, components):
              """Find str_args and unknown strings"""
          
              str_spans: List[Span] = []
          
          
          Severity: Minor
          Found in bel/lang/parse.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 terms_iterator_for_elasticsearch has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          def terms_iterator_for_elasticsearch(f: IO, index_name: str, metadata: dict):
              """Add index_name to term documents for bulk load"""
          
              species_list = settings.BEL_FILTER_SPECIES
          
          
          Severity: Minor
          Found in bel/resources/namespace.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 has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

              def validate(self, errors: List[ValidationError] = None):
                  """Validate BEL Function"""
          
                  if errors is None:
                      errors = []
          Severity: Minor
          Found in bel/lang/ast.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 process_definition has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          def process_definition(line, nanopubs_metadata):
              """Process DEFINE line in BEL script"""
          
              matches = re.match('DEFINE\s+(\w+)\s+(\w+)\s+AS\s+URL\s+"(.*?)"\s*$', line)
              if matches:
          Severity: Minor
          Found in bel/nanopub/belscripts.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 add_annotations has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def add_annotations(pubmed):
              """Add nanopub annotations to pubmed doc
          
              Enhance MESH terms etc as full-fledged nanopub annotations for use by the BEL Nanopub editor
              """
          Severity: Minor
          Found in bel/nanopub/pubmed.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

          Severity
          Category
          Status
          Source
          Language