justaddcoffee/kg-emerging-viruses

View on GitHub
kg_covid_19/transform_utils/string_ppi/string_ppi.py

Summary

Maintainability
B
5 hrs
Test Coverage
A
91%

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

    def run(self, data_file: Optional[str] = None) -> None:
        """Perform transformations to process protein-protein interactions.

        Args:
            data_file: data file to parse
Severity: Minor
Found in kg_covid_19/transform_utils/string_ppi/string_ppi.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 load_mapping has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    def load_mapping(
        self, input_dir: str, output_dir: str, species_id: Optional[List] = None
    ) -> None:
        """Load Ensembl Gene to Protein mapping from NCBI gene2ensembl (gene2ensembl.gz).

Severity: Minor
Found in kg_covid_19/transform_utils/string_ppi/string_ppi.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

Avoid deeply nested control flow statements.
Open

                        if protein in string_to_uniprot_id_map:
                            uniprot_curie = (
                                f"UniProtKB:{string_to_uniprot_id_map[protein]}"
                            )
                            uniprot_curie = collapse_uniprot_curie(uniprot_curie)
Severity: Major
Found in kg_covid_19/transform_utils/string_ppi/string_ppi.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if gene not in seen_genes:
                                seen_genes.add(gene)
                                ensemble_gene = f"ENSEMBL:{gene}"
                                gene_informations = self.gene_info_map[
                                    self.ensembl2ncbi_map[gene]
    Severity: Major
    Found in kg_covid_19/transform_utils/string_ppi/string_ppi.py - About 45 mins to fix

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

          def load_gene_info(
              self, input_dir: str, output_dir: str, species_id: Optional[List] = None
          ) -> None:
              """Load mappings from NCBI gene_info (gene_info.gz).
      
      
      Severity: Minor
      Found in kg_covid_19/transform_utils/string_ppi/string_ppi.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