django/django

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

Summary

Maintainability
F
6 days
Test Coverage

File makemessages.py has 578 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 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 handle has a Cognitive Complexity of 31 (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 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 process_locale_dir has a Cognitive Complexity of 25 (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 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 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

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

                  if options['no_location']:
                      self.msgmerge_options = self.msgmerge_options[:] + ['--no-location']
                      self.msguniq_options = self.msguniq_options[:] + ['--no-location']
                      self.msgattrib_options = self.msgattrib_options[:] + ['--no-location']
                      self.xgettext_options = self.xgettext_options[:] + ['--no-location']
          Severity: Major
          Found in django/core/management/commands/makemessages.py and 1 other location - About 5 hrs to fix
          django/core/management/commands/makemessages.py on lines 298..302

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

          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 options['no_wrap']:
                      self.msgmerge_options = self.msgmerge_options[:] + ['--no-wrap']
                      self.msguniq_options = self.msguniq_options[:] + ['--no-wrap']
                      self.msgattrib_options = self.msgattrib_options[:] + ['--no-wrap']
                      self.xgettext_options = self.xgettext_options[:] + ['--no-wrap']
          Severity: Major
          Found in django/core/management/commands/makemessages.py and 1 other location - About 5 hrs to fix
          django/core/management/commands/makemessages.py on lines 303..307

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

          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

                      if errors:
                          if status != STATUS_OK:
                              raise CommandError(
                                  "errors happened while running msguniq\n%s" % errors)
                          elif self.verbosity > 0:
          Severity: Major
          Found in django/core/management/commands/makemessages.py and 2 other locations - About 2 hrs to fix
          django/core/management/commands/makemessages.py on lines 606..611
          django/core/management/commands/makemessages.py on lines 626..631

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

          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

                      if errors:
                          if status != STATUS_OK:
                              raise CommandError(
                                  "errors happened while running msgmerge\n%s" % errors)
                          elif self.verbosity > 0:
          Severity: Major
          Found in django/core/management/commands/makemessages.py and 2 other locations - About 2 hrs to fix
          django/core/management/commands/makemessages.py on lines 432..437
          django/core/management/commands/makemessages.py on lines 626..631

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

          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

                      if errors:
                          if status != STATUS_OK:
                              raise CommandError(
                                  "errors happened while running msgattrib\n%s" % errors)
                          elif self.verbosity > 0:
          Severity: Major
          Found in django/core/management/commands/makemessages.py and 2 other locations - About 2 hrs to fix
          django/core/management/commands/makemessages.py on lines 432..437
          django/core/management/commands/makemessages.py on lines 606..611

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

          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 file_ext not in self.extensions or is_ignored_path(file_path, self.ignore_patterns):
                              if self.verbosity > 1:
                                  self.stdout.write('ignoring file %s in %s\n' % (filename, dirpath))
          Severity: Minor
          Found in django/core/management/commands/makemessages.py and 1 other location - About 30 mins to fix
          django/core/management/commands/compilemessages.py on lines 124..125

          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

          There are no issues that match your filters.

          Category
          Status