spicycms/spicy.core

View on GitHub
src/spicy/script.py

Summary

Maintainability
F
6 days
Test Coverage

File script.py has 980 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# coding: utf-8
"""SpicyTools command handler implementation

SPICY_BUILD_DIR = '.spicy-build'
SPICY_REQ_FILE = 'requirements.txt'
Severity: Major
Found in src/spicy/script.py - About 2 days to fix

    Function _generate_common_reqfile has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring.
    Open

        def _generate_common_reqfile(self):
            """Project requirements file generator using all applications
    
            return: local agregated requirements.txt file from all applications.
            """
    Severity: Minor
    Found in src/spicy/script.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 handle_create_app has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def handle_create_app(ns):
        spicy_pkg_root_dir = os.path.dirname(__file__)
        #spicy_app_tpl_root = os.path.join(spicy_pkg_root_dir)
        source_app_dir = os.path.join(spicy_pkg_root_dir, 'app')
    
    
    Severity: Minor
    Found in src/spicy/script.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 build_remote_env has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_remote_env(self):
            """
            Build remote enviroment using common for all applications requirements.
    
            Builder use native `virtualenv` utility.
    Severity: Minor
    Found in src/spicy/script.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 configure_templates has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def configure_templates(self):
            """
            Look for `*.spicy` template files in the application directory
            recursively using subdirs. Config templates use Jinja2 template syntax.
            """
    Severity: Minor
    Found in src/spicy/script.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 __init__ has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(
                self, server, version_label, apps_string, static_string=None,
                version_control_util='hg', config=None, force=False):
            """
            :param server: remote server instance
    Severity: Minor
    Found in src/spicy/script.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 install_server_apps has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def install_server_apps(self):
            """
            Copy project to the remote server. Create web applications,
            application and all default config files from templates if original
            files doesnot exists.
    Severity: Minor
    Found in src/spicy/script.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 handle_deploy has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

    def handle_deploy(ns):
        if ns.port:
            env.port = ns.port
    
        if ns.user:
    Severity: Minor
    Found in src/spicy/script.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 _copy_archive has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def _copy_archive(self, path, apps):
            if exists(path):
                overwrite = self.force
                while not overwrite:
                    proceed = raw_input_cyan(
    Severity: Minor
    Found in src/spicy/script.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 __init__ has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(
    Severity: Major
    Found in src/spicy/script.py - About 50 mins to fix

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

      def handle_build_docs(args):
          """
          `build-docs` command handler.
      
          Returns
      Severity: Minor
      Found in src/spicy/script.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

      Avoid deeply nested control flow statements.
      Open

                              with settings(
                                      hide(
                                          'warnings', 'running', 'stdout', 'stderr'),
                                      warn_only=True):
                                  local('rm {0}'.format(file_path))
      Severity: Major
      Found in src/spicy/script.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if module.startswith(rmod) and module != req:
                                    print_err(
                                        '[warning] While prepare requirements sequence'
                                        ' mistmaching version detected: [%s] %s != '
                                        '[%s] %s' % (
        Severity: Major
        Found in src/spicy/script.py - About 45 mins to fix

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

              def get_branch_by_revision_id(self, app_name, revision_id, app_path):
                  with lcd(os.path.join(os.path.abspath('.'), app_name)):
                      branch_name = local(
                          self.cmd_branch_by_revision % dict(revision_id=revision_id),
                          capture=True)
          Severity: Major
          Found in src/spicy/script.py and 1 other location - About 5 hrs to fix
          src/spicy/script.py on lines 475..485

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

          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 get_revision_by_branch(self, app_name, branch_name, app_path):
                  with lcd(os.path.join(os.path.abspath('.'), app_name)):
                      revision_id = local(self.cmd_revision_by_branch % dict(
                          branch_name=branch_name), capture=True)
                      if not revision_id:
          Severity: Major
          Found in src/spicy/script.py and 1 other location - About 5 hrs to fix
          src/spicy/script.py on lines 462..473

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

          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 sync_database(self):
                  with prefix('source {0}/bin/activate'.format(self.remote_env_path)):
                      for app in self.apps:
                          app.sync_database()
                          print_info('Sync database app: {0}'.format(app))
          Severity: Major
          Found in src/spicy/script.py and 1 other location - About 2 hrs to fix
          src/spicy/script.py on lines 1076..1080

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

          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 collectstatic(self):
                  with prefix('source {0}/bin/activate'.format(self.remote_env_path)):
                      for app in self.apps:
                          app.collectstatic()
                          print_info('Collect static files for: {0}'.format(app))
          Severity: Major
          Found in src/spicy/script.py and 1 other location - About 2 hrs to fix
          src/spicy/script.py on lines 1070..1074

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

          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