justaddcoffee/kg-emerging-viruses

View on GitHub
kg_covid_19/transform_utils/chembl/chembl_transform.py

Summary

Maintainability
D
2 days
Test Coverage
F
13%

Function parse_doc_fields has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_doc_fields(
        self, record: dict, allowed_properties: set, remap: Optional[dict] = None
    ):
        """Parse a record from the API.

Severity: Minor
Found in kg_covid_19/transform_utils/chembl/chembl_transform.py - About 1 day 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 chembl_transform.py has 350 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""Transform class for CHEMBL data."""

import json
from typing import Dict, List, Optional, Set

Severity: Minor
Found in kg_covid_19/transform_utils/chembl/chembl_transform.py - About 4 hrs to fix

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

        def run(
            self, data_file: Optional[str] = None, chembl_data_files: Optional[dict] = None
        ) -> None:
            """Call method and perform needed transformations.
    
    
    Severity: Minor
    Found in kg_covid_19/transform_utils/chembl/chembl_transform.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_chembl_activity has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_chembl_activity(self, data: List):
            """Parse ChEMBL Activity records.
    
            An activity document links 4 entities,
                - assay
    Severity: Minor
    Found in kg_covid_19/transform_utils/chembl/chembl_transform.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 remap and k2 in remap.keys():
                                update_properties(remap[k2], v2)
                            else:
                                update_properties(k2, v2)
                    else:
    Severity: Major
    Found in kg_covid_19/transform_utils/chembl/chembl_transform.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              for x in v:
                                  r = self.parse_doc_fields(x, allowed_properties, remap)
                                  for k2, v2 in r.items():
                                      update_properties(k2, v2)
                  else:
      Severity: Major
      Found in kg_covid_19/transform_utils/chembl/chembl_transform.py - About 45 mins to fix

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

            def parse_chembl_document(self, data: List):
                """Parse ChEMBL Document records.
        
                Args:
                    data: A list of ChEMBL Document records
        Severity: Minor
        Found in kg_covid_19/transform_utils/chembl/chembl_transform.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