neurodata/ndmg

View on GitHub
ndmg/scripts/ndmg_cloud.py

Summary

Maintainability
D
2 days
Test Coverage

Function create_json has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring.
Open

def create_json(bucket, path, threads, jobdir, group=False, credentials=None,
                debug=False, dataset=None, log=False):
    """
    Takes parameters to make jsons
    """
Severity: Minor
Found in ndmg/scripts/ndmg_cloud.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

File ndmg_cloud.py has 263 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python

# Copyright 2016 NeuroData (http://neurodata.io)
#
# Licensed under the Apache License, Version 2.0 (the "License");
Severity: Minor
Found in ndmg/scripts/ndmg_cloud.py - About 2 hrs to fix

    Function create_json has 9 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def create_json(bucket, path, threads, jobdir, group=False, credentials=None,
    Severity: Major
    Found in ndmg/scripts/ndmg_cloud.py - About 1 hr to fix

      Function main has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

      def main():
          parser = ArgumentParser(description="This is an end-to-end connectome \
                                  estimation pipeline from sMRI and DTI images")
      
          parser.add_argument('state', choices=['session',
      Severity: Minor
      Found in ndmg/scripts/ndmg_cloud.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 batch_submit has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def batch_submit(bucket, path, jobdir, credentials=None, state='session',
      Severity: Major
      Found in ndmg/scripts/ndmg_cloud.py - About 1 hr to fix

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

        def crawl_bucket(bucket, path, group=False):
            """
            Gets subject list for a given S3 bucket and path
            """
            if group:
        Severity: Minor
        Found in ndmg/scripts/ndmg_cloud.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 kill_jobs has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

        def kill_jobs(jobdir, reason='"Killing job"'):
            """
            Given a list of jobs, kills them all.
            """
            cmd_template1 = 'aws batch cancel-job --job-id {} --reason {}'
        Severity: Minor
        Found in ndmg/scripts/ndmg_cloud.py - About 25 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

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

                env[1]['value'] = [cred[1][idx]
                                   for idx, val in enumerate(cred[0])
                                   if "Secret" in val][0]  # Adds secret key to env
        Severity: Major
        Found in ndmg/scripts/ndmg_cloud.py and 1 other location - About 3 hrs to fix
        ndmg/scripts/ndmg_cloud.py on lines 111..113

        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 64.

        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

                env[0]['value'] = [cred[1][idx]
                                   for idx, val in enumerate(cred[0])
                                   if "ID" in val][0]  # Adds public key ID to env
        Severity: Major
        Found in ndmg/scripts/ndmg_cloud.py and 1 other location - About 3 hrs to fix
        ndmg/scripts/ndmg_cloud.py on lines 114..116

        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 64.

        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

                elif status in ['STARTING', 'RUNNING']:
                    cmd = cmd_template2.format(jid, reason)
                    print("... Terminating job {}...".format(name))
                    out, err = mgu.execute_cmd(cmd)
        Severity: Minor
        Found in ndmg/scripts/ndmg_cloud.py and 1 other location - About 50 mins to fix
        ndmg/scripts/ndmg_cloud.py on lines 249..252

        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 36.

        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

                elif status in ['SUBMITTED', 'PENDING', 'RUNNABLE']:
                    cmd = cmd_template1.format(jid, reason)
                    print("... Cancelling job {}...".format(name))
                    out, err = mgu.execute_cmd(cmd)
        Severity: Minor
        Found in ndmg/scripts/ndmg_cloud.py and 1 other location - About 50 mins to fix
        ndmg/scripts/ndmg_cloud.py on lines 253..256

        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 36.

        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

        There are no issues that match your filters.

        Category
        Status