django/django

View on GitHub
django/core/management/commands/makemessages.py

Summary

Maintainability
F
4 days
Test Coverage

File makemessages.py has 688 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import glob
import os
import re
import sys
from functools import total_ordering
Severity: Major
Found in django/core/management/commands/makemessages.py - About 1 day to fix

    Function handle has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            locale = options["locale"]
            exclude = options["exclude"]
            self.domain = options["domain"]
            self.verbosity = options["verbosity"]
    Severity: Minor
    Found in django/core/management/commands/makemessages.py - About 6 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 process_locale_dir has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
    Open

        def process_locale_dir(self, locale_dir, files):
            """
            Extract translatable literals from the specified files, creating or
            updating the POT file for a given locale directory.
    
    
    Severity: Minor
    Found in django/core/management/commands/makemessages.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 find_files has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        def find_files(self, root):
            """
            Get all files in the given root. Also check that there is a matching
            locale dir for each file.
            """
    Severity: Minor
    Found in django/core/management/commands/makemessages.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 copy_plural_forms has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def copy_plural_forms(self, msgs, locale):
            """
            Copy plural forms header contents from a Django catalog of locale to
            the msgs string, inserting it at the right place. msgs should be the
            contents of a newly created .po file.
    Severity: Minor
    Found in django/core/management/commands/makemessages.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 write_po_file has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def write_po_file(self, potfile, locale):
            """
            Create or update the PO file for self.domain and `locale`.
            Use contents of the existing `potfile`.
    
    
    Severity: Minor
    Found in django/core/management/commands/makemessages.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 write_pot_file has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    def write_pot_file(potfile, msgs):
        """
        Write the `potfile` with the `msgs` contents, making sure its format is
        valid.
        """
    Severity: Minor
    Found in django/core/management/commands/makemessages.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 has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def handle(self, *args, **options):
            locale = options["locale"]
            exclude = options["exclude"]
            self.domain = options["domain"]
            self.verbosity = options["verbosity"]
    Severity: Minor
    Found in django/core/management/commands/makemessages.py - About 1 hr to fix

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

          def build_potfiles(self):
              """
              Build pot files and apply msguniq to them.
              """
              file_list = self.find_files(".")
      Severity: Minor
      Found in django/core/management/commands/makemessages.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

      Avoid deeply nested control flow statements.
      Open

                              if not found and (not line or plural_forms_re.search(line)):
                                  line = plural_form_line
                                  found = True
                              lines.append(line)
      Severity: Major
      Found in django/core/management/commands/makemessages.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if os.path.abspath(dirpath).startswith(os.path.dirname(path)):
                                    locale_dir = path
                                    break
                            locale_dir = locale_dir or self.default_locale_path or NO_LOCALE_DIR
        Severity: Major
        Found in django/core/management/commands/makemessages.py - About 45 mins to fix

          There are no issues that match your filters.

          Category
          Status