nephila/djangocms-helper

View on GitHub
app_helper/main.py

Summary

Maintainability
D
2 days
Test Coverage

Function core has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

def core(args, application):
    from django.conf import settings

    # configure django
    warnings.filterwarnings(
Severity: Minor
Found in app_helper/main.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

File main.py has 294 lines of code (exceeds 250 allowed). Consider refactoring.
Open

#!/usr/bin/env python
import argparse
import contextlib
import os
import subprocess
Severity: Minor
Found in app_helper/main.py - About 3 hrs to fix

    Function _map_argv has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

    def _map_argv(argv, application_module):
        try:
            # by default docopt uses sys.argv[1:]; ensure correct args passed
            args = docopt(__doc__, argv=argv[1:], version=application_module.__version__)
            if argv[2] == "help":
    Severity: Minor
    Found in app_helper/main.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 generate_authors has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    def generate_authors():
        """
        Updates the authors list
        """
        print("Generating AUTHORS")
    Severity: Minor
    Found in app_helper/main.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 _test_run_worker has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    def _test_run_worker(test_labels, test_runner, failfast=False, runner_options=None, verbose=1):
        warnings.filterwarnings(
            "error",
            r"DateTimeField received a naive datetime",
            RuntimeWarning,
    Severity: Minor
    Found in app_helper/main.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 server has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def server(
    Severity: Major
    Found in app_helper/main.py - About 50 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          with context:
                              num_failures = test(
                                  args["<test-label>"],
                                  application,
                                  args["--failfast"],
      Severity: Major
      Found in app_helper/main.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            if args["--runner"]:
                                runner = args["--runner"]
                            else:
                                runner = settings.TEST_RUNNER
        
        
        Severity: Major
        Found in app_helper/main.py - About 45 mins to fix

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

          def test(test_labels, application, failfast=False, test_runner=None, runner_options=None, verbose=1):
          Severity: Minor
          Found in app_helper/main.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if args["--xvfb"]:  # pragma: no cover
                                    import xvfbwrapper
            
                                    context = xvfbwrapper.Xvfb(width=1280, height=720)
                                else:
            Severity: Major
            Found in app_helper/main.py - About 45 mins to fix

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

              def makemigrations(application, merge=False, dry_run=False, empty=False, extra_applications=None):
              Severity: Minor
              Found in app_helper/main.py - About 35 mins to fix

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

                def _test_run_worker(test_labels, test_runner, failfast=False, runner_options=None, verbose=1):
                Severity: Minor
                Found in app_helper/main.py - About 35 mins to fix

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

                  def test(test_labels, application, failfast=False, test_runner=None, runner_options=None, verbose=1):
                      """
                      Runs the test suite
                      :param test_labels: space separated list of test labels
                      :param failfast: option to stop the testsuite on the first error
                  Severity: Minor
                  Found in app_helper/main.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

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

                          if author.lower() not in seen_authors:
                              seen_authors.append(author.lower())
                              authors.append(author)
                  Severity: Minor
                  Found in app_helper/main.py and 1 other location - About 50 mins to fix
                  app_helper/main.py on lines 186..188

                  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

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

                                  if author.lower() not in seen_authors:
                                      seen_authors.append(author.lower())
                                      authors.append(author)
                  Severity: Minor
                  Found in app_helper/main.py and 1 other location - About 50 mins to fix
                  app_helper/main.py on lines 191..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 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

                          if arg.startswith("--runner="):
                              args["--runner"] = arg.split("=")[1]
                  Severity: Minor
                  Found in app_helper/main.py and 1 other location - About 35 mins to fix
                  app_helper/main.py on lines 227..228

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

                  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

                          if arg.startswith("--extra-settings="):
                              args["--extra-settings"] = arg.split("=")[1]
                  Severity: Minor
                  Found in app_helper/main.py and 1 other location - About 35 mins to fix
                  app_helper/main.py on lines 229..230

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

                  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