nephila/djangocms-helper

View on GitHub

Showing 93 of 93 total issues

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

    def _prepare_request(self, request, page, user, lang, use_middlewares, use_toolbar=False, secure=False):
        from importlib import import_module

        from django.contrib.auth.models import AnonymousUser

Severity: Minor
Found in app_helper/base_test.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 create_user has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def create_user(
    username,
    email,
    password,
    is_staff=False,
Severity: Minor
Found in app_helper/utils.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 _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 towncrier_check has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

def towncrier_check(c):  # NOQA
    """Check towncrier files."""
    output = io.StringIO()
    c.run("git branch -a --contains HEAD", out_stream=output)
    skipped_branch_prefix = ["pull/", "release/", "develop", "master", "HEAD"]
Severity: Minor
Found in tasks.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

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

    if len(argv) < 3 and "test" not in argv[:2]:
        # test argument is given if not argument is passed
        argv.insert(2, "test")
Severity: Major
Found in app_helper/runner.py and 1 other location - About 1 hr to fix
app_helper/runner.py on lines 41..43

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

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

            with captured_output() as (out, err):
                args = copy(DEFAULT_ARGS)
                args["server"] = True
                core(args, self.application)
Severity: Major
Found in tests/test_commands.py and 2 other locations - About 1 hr to fix
tests/test_commands.py on lines 455..458
tests/test_commands.py on lines 895..899

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

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 len(argv) < 3 and "test" not in argv[:2]:
        # test argument is given if not argument is passed
        argv.insert(2, "test")
Severity: Major
Found in app_helper/runner.py and 1 other location - About 1 hr to fix
app_helper/runner.py on lines 17..19

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

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

    def _clean_modules_directories(self):
        """
        Cleanup all the leftover of migration and po files tests.
        Executed in setup and teardown for simplicity.
        """
Severity: Minor
Found in tests/test_commands.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 3 locations. Consider refactoring.
Open

        with work_in(self.basedir):
            with captured_output() as (out, err):
                args = copy(DEFAULT_ARGS)
                args["authors"] = True
                core(args, self.application)
Severity: Major
Found in tests/test_commands.py and 2 other locations - About 1 hr to fix
tests/test_commands.py on lines 391..394
tests/test_commands.py on lines 455..458

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

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

        with captured_output() as (out, err):
            args = copy(DEFAULT_ARGS)
            args["makemigrations"] = True
            core(args, self.application)
Severity: Major
Found in tests/test_commands.py and 2 other locations - About 1 hr to fix
tests/test_commands.py on lines 391..394
tests/test_commands.py on lines 895..899

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

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 request has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def request(
Severity: Major
Found in app_helper/base_test.py - About 1 hr to fix

    Function _make_settings has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    def _make_settings(args, application, settings, STATIC_ROOT, MEDIA_ROOT):  # NOQA
        """
        Setup the Django settings
        :param args: docopt arguments
        :param application: application module name
    Severity: Minor
    Found in app_helper/utils.py - About 1 hr to fix

      Function post_request has 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def post_request(
      Severity: Major
      Found in app_helper/base_test.py - About 1 hr to fix

        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 create_user has 7 arguments (exceeds 4 allowed). Consider refactoring.
        Open

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

          Function create_user has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

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

            Function get_toolbar_request has 7 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def get_toolbar_request(self, page, user, path=None, edit=False, lang="en", use_middlewares=False, secure=False):
            Severity: Major
            Found in app_helper/base_test.py - About 50 mins to fix

              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

                Function get_request has 7 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def get_request(self, page, lang, user=None, path=None, use_middlewares=False, secure=False, use_toolbar=False):
                Severity: Major
                Found in app_helper/base_test.py - About 50 mins to fix
                  Severity
                  Category
                  Status
                  Source
                  Language