HumanCellAtlas/metadata-schema-publisher

View on GitHub

Showing 37 of 37 total issues

Function _process_directory has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
Open

def _process_directory(repo, branch_name, base_server_path, server_path, version_numbers, context, dryrun=False):
    print("Processing " + server_path + " in " + branch_name + " branch of " + repo.name)
    created_list = []
    contents = repo.get_dir_contents(server_path, branch_name)
    for content in contents:
Severity: Minor
Found in handler.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 _find_value has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

    def _find_value(self, key, dictionary):
        for k, v in dictionary.items():
            if k == key:
                yield v
            elif isinstance(v, dict):
Severity: Minor
Found in release_prep.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 expand_urls has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    def expand_urls(self, relative_path, file_data):
        version = self._find_schema_version(relative_path)

        el = relative_path.split("/")
        el.insert(len(el) - 1, version)
Severity: Minor
Found in release_prep.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 _replace_value has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def _replace_value(self, key, dictionary, old, new):
        for k in dictionary.keys():
            if k == key and dictionary[k] == old:
                dictionary[k] = new
            elif isinstance(dictionary[k], dict):
Severity: Minor
Found in release_prep.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 _upload has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def _upload(key, branch_name, file_data, context, dryrun=False):
    if dryrun:
        output_dir = 'dryrun'
        output_path = output_dir + '/' + key
        pos = output_path.rfind('/')
Severity: Minor
Found in handler.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 _process_directory has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def _process_directory(repo, branch_name, base_server_path, server_path, version_numbers, context, dryrun=False):
Severity: Major
Found in handler.py - About 50 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if created:
                                created_list.append(key)
                    else:
    Severity: Major
    Found in handler.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              if "#" in el[i]:
                                  el.insert(i, v)
                                  break
                      else:
      Severity: Major
      Found in release_prep.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                for result in self._find_value(key, d):
                                    yield result
        
        
        Severity: Major
        Found in release_prep.py - About 45 mins to fix

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

          def _upload(key, branch_name, file_data, context, dryrun=False):
          Severity: Minor
          Found in handler.py - About 35 mins to fix

            Line too long (107 > 79 characters)
            Open

                    return {k: v for k, v in (list(dict.items())[:pos] + list(obj.items()) + list(dict.items())[pos:])}
            Severity: Minor
            Found in release_prep.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 (89 > 79 characters)
            Open

                           for f in files if f.endswith('.json') and not f.endswith('versions.json')]
            Severity: Minor
            Found in release_prep.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 (83 > 79 characters)
            Open

                                  help="Base path to the HCA metadata schemas", metavar="FILE")
            Severity: Minor
            Found in release_prep.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

                    result = _process_directory(repo, branch.name, server_path, server_path, version_numbers, context, dryrun)
            Severity: Minor
            Found in handler.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.

            Continuation line under-indented for visual indent
            Open

                           for f in files if f.endswith('.json') and not f.endswith('versions.json')]
            Severity: Minor
            Found in release_prep.py by pep8

            Continuation lines indentation.

            Continuation lines should align wrapped elements either vertically
            using Python's implicit line joining inside parentheses, brackets
            and braces, or using a hanging indent.
            
            When using a hanging indent these considerations should be applied:
            - there should be no arguments on the first line, and
            - further indentation should be used to clearly distinguish itself
              as a continuation line.
            
            Okay: a = (\n)
            E123: a = (\n    )
            
            Okay: a = (\n    42)
            E121: a = (\n   42)
            E122: a = (\n42)
            E123: a = (\n    42\n    )
            E124: a = (24,\n     42\n)
            E125: if (\n    b):\n    pass
            E126: a = (\n        42)
            E127: a = (24,\n      42)
            E128: a = (24,\n    42)
            E129: if (a or\n    b):\n    pass
            E131: a = (\n    42\n 24)

            Line too long (91 > 79 characters)
            Open

                            s3.put_object(Bucket=bucket, Key=key, Body=json.dumps(file_data, indent=2),
            Severity: Minor
            Found in handler.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 (84 > 79 characters)
            Open

                            if file_extension == '.json' and not path.endswith('versions.json'):
            Severity: Minor
            Found in handler.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.

            Continuation line under-indented for visual indent
            Open

                           for dirpath, dirnames, files in os.walk(path)
            Severity: Minor
            Found in release_prep.py by pep8

            Continuation lines indentation.

            Continuation lines should align wrapped elements either vertically
            using Python's implicit line joining inside parentheses, brackets
            and braces, or using a hanging indent.
            
            When using a hanging indent these considerations should be applied:
            - there should be no arguments on the first line, and
            - further indentation should be used to clearly distinguish itself
              as a continuation line.
            
            Okay: a = (\n)
            E123: a = (\n    )
            
            Okay: a = (\n    42)
            E121: a = (\n   42)
            E122: a = (\n42)
            E123: a = (\n    42\n    )
            E124: a = (24,\n     42\n)
            E125: if (\n    b):\n    pass
            E126: a = (\n        42)
            E127: a = (24,\n      42)
            E128: a = (24,\n    42)
            E129: if (a or\n    b):\n    pass
            E131: a = (\n    42\n 24)

            Line too long (86 > 79 characters)
            Open

                    versions_file = repo.get_contents(server_path + "/versions.json", branch.name)
            Severity: Minor
            Found in handler.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 (102 > 79 characters)
            Open

                                    expanded_file_data = release_preparation.expand_urls(relative_path, json_data)
            Severity: Minor
            Found in handler.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