HumanCellAtlas/ingest-broker

View on GitHub

Showing 144 of 144 total issues

File summary_service.py has 266 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import json
import os
from functools import reduce
from typing import Generator
from typing import Iterable
Severity: Minor
Found in broker/service/summary_service.py - About 2 hrs to fix

    Function generateApplyFunction has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

            def generateApplyFunction(self):
                """
                If an identifier is specified, we want the following algorithm:
                - return entities matching the identifier
    
    
    Severity: Minor
    Found in broker/service/summary_service.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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    def generate_submission_summary(uuid, ingest_url):
        ingest_api = IngestApi(ingest_url)
        submission = ingest_api.getSubmissionByUuid(uuid)
        summary = SummaryService(ingest_api).summary_for_submission(submission)
    
    
    Severity: Major
    Found in generate_summary.py and 1 other location - About 1 hr to fix
    generate_summary.py on lines 18..23

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

    def generate_project_summary(uuid, ingest_url):
        ingest_api = IngestApi(ingest_url)
        project = ingest_api.getProjectByUuid(uuid)
        summary = SummaryService(ingest_api).summary_for_project(project)
    
    
    Severity: Major
    Found in generate_summary.py and 1 other location - About 1 hr to fix
    generate_summary.py on lines 10..15

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 45.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Function get_spreadsheet_location has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_spreadsheet_location(self, submission_uuid):
            submission_dir_path = f'{self.storage_dir}/{submission_uuid}'
            storage_manifest_path = f'{submission_dir_path}/{self.storage_manifest_name}'
            if not os.path.isdir(submission_dir_path):
                raise SubmissionSpreadsheetDoesntExist()
    Severity: Minor
    Found in broker/service/spreadsheet_storage/spreadsheet_storage_service.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

    Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, biomaterials=None, projects=None, processes=None, protocols=None, files=None):
    Severity: Minor
    Found in broker/service/summary_service.py - About 35 mins to fix

      Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, placeholder, entity_type, identifier, path, post_process):
      Severity: Minor
      Found in broker/service/summary_service.py - About 35 mins to fix

        Function __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def __init__(self, placeholder=None, entity_type=None, identifier=None, paths=None, reducer=None):
        Severity: Minor
        Found in broker/service/summary_service.py - About 35 mins to fix

          Line too long (100 > 79 characters)
          Open

          from broker.service.spreadsheet_storage.spreadsheet_storage_service import SpreadsheetStorageService
          Severity: Minor
          Found in broker_app.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (113 > 79 characters)
          Open

              def __init__(self, ingest_api: IngestApi, storage_service: SpreadsheetStorageService, importer: XlsImporter):

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (84 > 79 characters)
          Open

                  further broken down by entity type (e.g donor, tissue, cell suspension), ...
          Severity: Minor
          Found in broker/service/summary_service.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (106 > 79 characters)
          Open

                      submission_summary = self.add_entity_count_breakdown(submission_summary, submissions_entities)
          Severity: Minor
          Found in broker/service/summary_service.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (85 > 79 characters)
          Open

                      self.submission_summary_cache.insert(submission_uuid, submission_summary)
          Severity: Minor
          Found in broker/service/summary_service.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (98 > 79 characters)
          Open

                  given a collection of entities (i.e biomaterials, protocols, processes, ...) a submission,
          Severity: Minor
          Found in broker/service/summary_service.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (114 > 79 characters)
          Open

                  grouped_directives.file_directives = filter(lambda directive: directive.entity_type == 'file', directives)
          Severity: Minor
          Found in broker/service/summary_service.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (81 > 79 characters)
          Open

                      return lambda collection: reduce((lambda x, y: x + y), collection, 0)
          Severity: Minor
          Found in broker/service/summary_service.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (80 > 79 characters)
          Open

                      submission_spreadsheet_path = f'{submission_dir}/{spreadsheet_name}'

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (116 > 79 characters)
          Open

                              json.dump({"name": spreadsheet_name, "location": submission_spreadsheet_path}, storage_manfiest)

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (80 > 79 characters)
          Open

                          with open(storage_manifest_path, "rb") as storage_manifest_file:

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.

          Line too long (82 > 79 characters)
          Open

              def breakdowns_from_submission_summary(submission_summary: SubmissionSummary):
          Severity: Minor
          Found in broker/common/util/tsv_summary_util.py by pep8

          Limit all lines to a maximum of 79 characters.

          There are still many devices around that are limited to 80 character
          lines; plus, limiting windows to 80 characters makes it possible to
          have several windows side-by-side.  The default wrapping on such
          devices looks ugly.  Therefore, please limit all lines to a maximum
          of 79 characters. For flowing long blocks of text (docstrings or
          comments), limiting the length to 72 characters is recommended.
          
          Reports error E501.
          Severity
          Category
          Status
          Source
          Language