KarrLab/wc_env_manager

View on GitHub

Showing 22 of 22 total issues

File core.py has 674 lines of code (exceeds 250 allowed). Consider refactoring.
Open

""" Tools for managing computing environments for whole-cell modeling

* Build the Docker image

    * *wc_env*: image with WC models and WC modeling tools and their dependencies
Severity: Major
Found in wc_env_manager/core.py - About 1 day to fix

    Function get_required_python_packages has a Cognitive Complexity of 51 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_required_python_packages(self):
            """ Get Python packages required for the WC models and WC modeling
                tools (`config['image']['python_packages']`)
    
            Returns:
    Severity: Minor
    Found in wc_env_manager/core.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

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

        @cement.ex(help='Build base image')
        def build(self):
            mgr = wc_env_manager.core.WcEnvManager({'verbose': VERBOSE})
            mgr.build_base_image()
            print('Built base image {}:{{{}}}'.format(
    Severity: Major
    Found in wc_env_manager/__main__.py and 1 other location - About 4 hrs to fix
    wc_env_manager/__main__.py on lines 97..102

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

    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

        @cement.ex(help='Build image')
        def build(self):
            mgr = wc_env_manager.core.WcEnvManager({'verbose': VERBOSE})
            mgr.build_image()
            print('Built image {}:{{{}}}'.format(
    Severity: Major
    Found in wc_env_manager/__main__.py and 1 other location - About 4 hrs to fix
    wc_env_manager/__main__.py on lines 47..52

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

    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 _build_image has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def _build_image(self, image_repo, image_tags,
                         dockerfile_path, build_args, context_path,
                         pull_base_image=False):
            """ Build Docker image
    
    
    Severity: Minor
    Found in wc_env_manager/core.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 setup_container has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def setup_container(self, upgrade=False):
            """ Install Python packages into Docker container
    
            Args:
                upgrade (:obj:`bool`, optional): if :obj:`True`, upgrade package
    Severity: Minor
    Found in wc_env_manager/core.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 get_config_file_paths_to_copy_to_image has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_config_file_paths_to_copy_to_image(self):
            """ Get list of configuration file paths to copy from ~/.wc to Docker image
    
            Returns:
                :obj:`list` of :obj:`dict`: configuration file paths to copy from ~/.wc to Docker image
    Severity: Minor
    Found in wc_env_manager/core.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

        @cement.ex(help='Get base image version')
        def version(self):
            mgr = wc_env_manager.core.WcEnvManager({'verbose': VERBOSE})
            print(mgr.get_image_version(mgr._base_image))
    Severity: Major
    Found in wc_env_manager/__main__.py and 1 other location - About 1 hr to fix
    wc_env_manager/__main__.py on lines 123..126

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

    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

        @cement.ex(help='Get image version')
        def version(self):
            mgr = wc_env_manager.core.WcEnvManager({'verbose': VERBOSE})
            print(mgr.get_image_version(mgr._image))
    Severity: Major
    Found in wc_env_manager/__main__.py and 1 other location - About 1 hr to fix
    wc_env_manager/__main__.py on lines 76..79

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

    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

        @cement.ex(help='Build network')
        def build(self):
            mgr = wc_env_manager.core.WcEnvManager({'verbose': VERBOSE})
            mgr.build_network()
    Severity: Major
    Found in wc_env_manager/__main__.py and 1 other location - About 1 hr to fix
    wc_env_manager/__main__.py on lines 149..152

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

    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

        @cement.ex(help='Remove network')
        def remove(self):
            mgr = wc_env_manager.core.WcEnvManager({'verbose': VERBOSE})
            mgr.remove_network()
    Severity: Major
    Found in wc_env_manager/__main__.py and 1 other location - About 1 hr to fix
    wc_env_manager/__main__.py on lines 144..147

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

    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 build_image has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_image(self):
            """ Build Docker image for WC modeling environment
    
            Returns:
                :obj:`docker.models.images.Image`: Docker image
    Severity: Minor
    Found in wc_env_manager/core.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 _build_image has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _build_image(self, image_repo, image_tags,
    Severity: Minor
    Found in wc_env_manager/core.py - About 45 mins to fix

      Function run_process_in_container has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def run_process_in_container(self, cmd, work_dir=None, env=None, check=True,
      Severity: Minor
      Found in wc_env_manager/core.py - About 45 mins to fix

        Function push_image has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def push_image(self, image_repo, image_tags):
                """ Push Docker image to DockerHub
        
                Args:
                    image_repo (:obj:`str`): image repository
        Severity: Minor
        Found in wc_env_manager/core.py - About 45 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 copy_path_to_container has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def copy_path_to_container(self, local_path, container_path, overwrite=True, container_user=WcEnvUser.root):
        Severity: Minor
        Found in wc_env_manager/core.py - About 35 mins to fix

          Function run_process_in_container has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def run_process_in_container(self, cmd, work_dir=None, env=None, check=True,
                                           container_user=WcEnvUser.root):
                  """ Run a process in the current Docker container
          
                  Args:
          Severity: Minor
          Found in wc_env_manager/core.py - About 35 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 5 locations. Consider refactoring.
          Open

              class Meta:
                  label = 'container'
                  description = 'Build and remove containers of `wc_env`'
                  help = 'Build and remove containers of `wc_env`'
                  stacked_on = 'base'
          Severity: Major
          Found in wc_env_manager/__main__.py and 4 other locations - About 30 mins to fix
          wc_env_manager/__main__.py on lines 35..41
          wc_env_manager/__main__.py on lines 85..91
          wc_env_manager/__main__.py on lines 132..138
          wc_env_manager/__main__.py on lines 187..193

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

          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 5 locations. Consider refactoring.
          Open

              class Meta:
                  label = 'network'
                  description = 'Build and remove a Docker network'
                  help = 'Build and remove a Docker network'
                  stacked_on = 'base'
          Severity: Major
          Found in wc_env_manager/__main__.py and 4 other locations - About 30 mins to fix
          wc_env_manager/__main__.py on lines 35..41
          wc_env_manager/__main__.py on lines 85..91
          wc_env_manager/__main__.py on lines 158..164
          wc_env_manager/__main__.py on lines 187..193

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

          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 5 locations. Consider refactoring.
          Open

              class Meta:
                  label = 'base-image'
                  description = 'Build, push, pull, and remove the base image, `wc_env_dependencies`'
                  help = 'Build, push, pull, and remove the base image, `wc_env_dependencies`'
                  stacked_on = 'base'
          Severity: Major
          Found in wc_env_manager/__main__.py and 4 other locations - About 30 mins to fix
          wc_env_manager/__main__.py on lines 85..91
          wc_env_manager/__main__.py on lines 132..138
          wc_env_manager/__main__.py on lines 158..164
          wc_env_manager/__main__.py on lines 187..193

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

          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

          Severity
          Category
          Status
          Source
          Language