HumanCellAtlas/ingest-client

View on GitHub

Showing 66 of 924 total issues

Function build has a Cognitive Complexity of 66 (exceeds 5 allowed). Consider refactoring.
Open

    def build(self, spreadsheet_tabs_template):
        # TODO(maniarathi): Fill out docstring here once finished parsing and consolidating code.
        tab_config = spreadsheet_tabs_template.tab_config

        if (self.link_config is not False) and (self.autofill_scale != 0):  # some precalculation for whole sheet
Severity: Minor
Found in ingest/template/linked_spreadsheet_builder.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

IngestApi has 54 functions (exceeds 20 allowed). Consider refactoring.
Open

class IngestApi:
    def __init__(self, url=None, token_manager=None):
        self.logger = logging.getLogger(__name__)
        self.session = create_session_with_retry()
        self.token_manager = token_manager
Severity: Major
Found in ingest/api/ingestapi.py - About 7 hrs to fix

    File ingestexportservice.py has 476 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    #!/usr/bin/env python
    import json
    import logging
    import os
    import re
    Severity: Minor
    Found in ingest/exporter/ingestexportservice.py - About 7 hrs to fix

      Function build has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

          def build(self, spreadsheet_tabs_template):
              tabs = spreadsheet_tabs_template.tabs
      
              for tab in tabs:
                  for tab_name, detail in tab.items():
      Severity: Minor
      Found in ingest/template/vanilla_spreadsheet_builder.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

      Function _value_linking has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
      Open

          def _value_linking(self):
      
              # # work out from backbone list and autofill_scale how many id values to fill
              # backbone = self.link_config[0]
              # multiplier = []
      Severity: Minor
      Found in ingest/template/linked_spreadsheet_builder.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 submission.py has 410 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import logging
      
      import requests
      
      from ingest.api.ingestapi import IngestApi
      Severity: Minor
      Found in ingest/importer/submission.py - About 5 hrs to fix

        File ingestapi.py has 362 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        #!/usr/bin/env python
        """
        desc goes here
        """
        import json
        Severity: Minor
        Found in ingest/api/ingestapi.py - About 4 hrs to fix

          Function get_user_friendly_column_name has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_user_friendly_column_name(self, template, column_name, primary_schema=None):
                  # TODO(maniarathi): Make this description better.
                  """ Given a column name derived originally from a metadata schema file that will be inputted as a column name
                  into the generated spreadsheet, turn it into a user friendly name. """
                  if '.text' in column_name:
          Severity: Minor
          Found in ingest/template/spreadsheet_builder.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

          Function export_bundle has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
          Open

              def export_bundle(self, bundle_uuid, bundle_version, submission_uuid, process_uuid):
                  start_time = time.time()
                  self.related_entities_cache = {}
                  saved_bundle_uuid = None
          
          
          Severity: Minor
          Found in ingest/exporter/ingestexportservice.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

          Function load has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
          Open

              def load(entity_json):
                  dictionary = EntityMap()
          
                  for entity_type, entities_dict in entity_json.items():
                      for entity_id, entity_body in entities_dict.items():
          Severity: Minor
          Found in ingest/importer/submission.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

          Function _validate_entity_links has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def _validate_entity_links(self, entity_map, entity):
                  links_by_entity = entity.links_by_entity
          
                  for link_entity_type, link_entity_ids in links_by_entity.items():
                      for link_entity_id in link_entity_ids:
          Severity: Minor
          Found in ingest/importer/submission.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

          Function _fill_examples_from_schema has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def _fill_examples_from_schema(self, example_text, worksheet, cols, col_number, tab_name):
                  double_prefix = 'Should be one of: '
                  metadata_fs = ';'
                  if example_text.startswith(double_prefix):
                      example_text_ = example_text[len(double_prefix):].split(',')[0]  # TODO hard coded assumption?
          Severity: Minor
          Found in ingest/template/linked_spreadsheet_builder.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 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, json_data):
                  super().__init__(json_data)
          
                  # Populate metadata/information about the schema itself, derived from the URL
                  if "$id" in json_data.keys():
          Severity: Minor
          Found in ingest/template/descriptor.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

          IngestExporter has 24 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class IngestExporter:
              def __init__(self, ingest_api: IngestApi, dss_api: DssApi, staging_service: StagingService, dry_run=False,
                           output_directory=None):
                  format = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
                  logging.basicConfig(format=format)
          Severity: Minor
          Found in ingest/exporter/ingestexportservice.py - About 2 hrs to fix

            Function _protocol_linking has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
            Open

                def _protocol_linking(self, backbone_entities):
                    protocol_pairings = self.link_config[1]
                    # protocols_to_add = []
                    protocols_to_add = {}
            
            
            Severity: Minor
            Found in ingest/template/linked_spreadsheet_builder.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 importer.py has 259 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import logging
            
            from requests import HTTPError
            
            from ingest.importer.conversion import template_manager
            Severity: Minor
            Found in ingest/importer/importer.py - About 2 hrs to fix

              MetadataEntity has 21 functions (exceeds 20 allowed). Consider refactoring.
              Open

              class MetadataEntity:
              
                  # TODO enforce definition of concrete and domain types for all MetadataEntity
                  # It's only currently done this way to minimise friction with other parts of the system
                  def __init__(self, concrete_type=TYPE_UNDEFINED, domain_type=TYPE_UNDEFINED, object_id=None,
              Severity: Minor
              Found in ingest/importer/conversion/metadata_entity.py - About 2 hrs to fix

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

                    def _add_link_cols(self, tab_name, col_number, worksheet, hf, backbone_entities):
                
                        # given the tab name work out what entity links need to be added
                
                        _link_to_tab = []
                Severity: Minor
                Found in ingest/template/linked_spreadsheet_builder.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 sheet_in_schemas has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                Open

                    def sheet_in_schemas(self, worksheet):
                        schemas = self.template_mgr.template.json_schemas
                        try:
                            concrete_type = self.template_mgr.get_concrete_type(worksheet.title)
                        except UnknownKeySchemaException as e:
                Severity: Minor
                Found in ingest/importer/importer.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 put_bundle has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                Open

                    def put_bundle(self, bundle_uuid, version, bundle_files):
                        bundle = None
                
                        # retrying file creation 20 times
                        max_retries = 20
                Severity: Minor
                Found in ingest/api/dssapi.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