CIMAC-CIDC/cidc-schemas

View on GitHub

Showing 59 of 59 total issues

File template.py has 1001 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-

"""The underlying data representation of an assay or shipping manifest template."""

import os
Severity: Major
Found in cidc_schemas/template.py - About 2 days to fix

    Function _convert_api_to_template has a Cognitive Complexity of 94 (exceeds 10 allowed). Consider refactoring.
    Open

    def _convert_api_to_template(name: str, schema: dict, assay_schema: dict):
        # import here to avoid circular dependence where prism imports Template
        from .prism.merger import InvalidMergeTargetException
    
        # so many different ways of writing it
    Severity: Minor
    Found in cidc_schemas/template.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 generate_docs.py has 702 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python3
    from collections import OrderedDict
    from copy import deepcopy
    import jinja2
    import json
    Severity: Major
    Found in docs/generate_docs.py - About 1 day to fix

      File pipelines.py has 685 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      """Analysis pipeline configuration generators."""
      from collections import defaultdict
      from datetime import datetime
      from io import BytesIO
      import logging
      Severity: Major
      Found in cidc_schemas/prism/pipelines.py - About 1 day to fix

        Function _validate_worksheet has a Cognitive Complexity of 54 (exceeds 10 allowed). Consider refactoring.
        Open

            def _validate_worksheet(self, worksheet_name: str, ws_schema: dict) -> List[str]:
                """Validate rows in a worksheet, returning a list of validation error messages."""
                self.visited_fields.clear()
        
                # If no worksheet is found, return only that error.
        Severity: Minor
        Found in cidc_schemas/template_reader.py - About 7 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 _first_in_context has a Cognitive Complexity of 53 (exceeds 10 allowed). Consider refactoring.
        Open

        def _first_in_context(path: list, context: dict):
            """
            For matching a file path to its nearest equivalent key in a schema context
            Recursive to try for more specific, more complex entries
        
        
        Severity: Minor
        Found in cidc_schemas/template.py - About 7 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_clinical has a Cognitive Complexity of 46 (exceeds 10 allowed). Consider refactoring.
        Open

        def parse_clinical(file: BinaryIO) -> dict:
            """
            Parses the given clinical file to extract a list of participant IDs.
            By convention the first column should be "cimac_part_id" for files containing
            clinical data keyed to a specific participant. All tabs in each XLSX need to be checked
        Severity: Minor
        Found in cidc_schemas/prism/extra_metadata.py - About 6 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 core.py has 403 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """Build metadata dictionaries from Excel files."""
        import logging
        import base64
        import hmac
        from typing import List, Tuple, Union
        Severity: Minor
        Found in cidc_schemas/prism/core.py - About 5 hrs to fix

          File template_writer.py has 383 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # -*- coding: utf-8 -*-
          
          """Defines the `XlTemplateWriter` class for writing `Template`s to Excel templates."""
          
          import logging
          Severity: Minor
          Found in cidc_schemas/template_writer.py - About 5 hrs to fix

            File json_validation.py has 380 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            # -*- encoding: utf-8 -*-
            
            """Tools for performing validations based on json schemas"""
            
            import os
            Severity: Minor
            Found in cidc_schemas/json_validation.py - About 5 hrs to fix

              Function prismify has a Cognitive Complexity of 37 (exceeds 10 allowed). Consider refactoring.
              Open

              def prismify(
                  xlsx: XlTemplateReader,
                  template: Template,
                  schema_root: str = SCHEMA_DIR,
                  debug: bool = False,
              Severity: Minor
              Found in cidc_schemas/prism/core.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 _map_refs has a Cognitive Complexity of 34 (exceeds 10 allowed). Consider refactoring.
              Open

              def _map_refs(node: dict, on_refs: Callable[[str], dict]) -> dict:
                  """
                  Apply `on_refs` to all nodes with `$ref`, returning node with refs replaced
                  with results of the function call.
              
              
              Severity: Minor
              Found in cidc_schemas/json_validation.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 _update_definition_from_merge_pointer has a Cognitive Complexity of 32 (exceeds 10 allowed). Consider refactoring.
              Open

                  def _update_definition_from_merge_pointer(
                      self,
                      context_pointer: str,
                      definition: dict,
                  ) -> dict:
              Severity: Minor
              Found in docs/generate_docs.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

              File utils.py has 317 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import os
              import jsonschema
              from typing import Any, Dict, Iterable, List, Set, Tuple
              
              from cidc_schemas.constants import SCHEMA_DIR
              Severity: Minor
              Found in docs/utils.py - About 3 hrs to fix

                Function parse_npx has a Cognitive Complexity of 29 (exceeds 10 allowed). Consider refactoring.
                Open

                def parse_npx(xlsx: BinaryIO) -> dict:
                    """
                    Parses the given NPX file from olink to extract a list of sample IDs.
                    If the file is not valid NPX but still xlsx the function will
                    return a dict containing an empty list. Sample IDs not conforming to the CIMAC ID
                Severity: Minor
                Found in cidc_schemas/prism/extra_metadata.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

                File migrations.py has 305 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                from copy import deepcopy
                from typing import NamedTuple, Dict
                
                from .prism.core import _ENCRYPTED_FIELD_LEN, _encrypt
                
                
                Severity: Minor
                Found in cidc_schemas/migrations.py - About 3 hrs to fix

                  Function upgrade has a Cognitive Complexity of 28 (exceeds 10 allowed). Consider refactoring.
                  Open

                      def upgrade(cls, metadata: dict, *args, **kwargs) -> MigrationResult:
                          # these are removal, so cannot downgrade later
                          metadata.pop("collection_event_list", None)
                  
                          for partic in metadata.get("participants", []):
                  Severity: Minor
                  Found in cidc_schemas/migrations.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

                  File unprism.py has 290 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """Tools from extracting information from trial metadata blobs."""
                  from io import StringIO, BytesIO
                  from typing import Callable, Dict, List, NamedTuple, Optional, Union
                  
                  import pandas as pd
                  Severity: Minor
                  Found in cidc_schemas/unprism.py - About 2 hrs to fix

                    Function from_excel has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
                    Open

                        def from_excel(xlsx_path: Union[str, BinaryIO]):
                            """
                            Initialize an Excel template reader from an excel file.
                    
                            Arguments:
                    Severity: Minor
                    Found in cidc_schemas/template_reader.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 _pair_all_samples has a Cognitive Complexity of 25 (exceeds 10 allowed). Consider refactoring.
                    Open

                        def _pair_all_samples(
                            self, partic_map: Dict[str, Dict[str, Dict[str, str]]]
                        ) -> List[_PairingEntry]:
                            """
                            (Semi)automated pairing of tumor and normal samples
                    Severity: Minor
                    Found in cidc_schemas/prism/pipelines.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

                    Severity
                    Category
                    Status
                    Source
                    Language