batiste/django-page-cms

View on GitHub
pages/plugins/pofiles/utils.py

Summary

Maintainability
C
1 day
Test Coverage

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

def export_po_files(path='poexport', stdout=None):
    """
    Export all the content from the published pages into
    po files. The files will be automatically updated
    with the new content if you run the command again.
Severity: Minor
Found in pages/plugins/pofiles/utils.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 import_po_files has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

def import_po_files(path='poexport', stdout=None):
    """
    Import all the content updates from the po files into
    the pages.
    """
Severity: Minor
Found in pages/plugins/pofiles/utils.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

Avoid deeply nested control flow statements.
Open

                    if page not in pages_to_invalidate:
                        pages_to_invalidate.append(page)

Severity: Major
Found in pages/plugins/pofiles/utils.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                        if target_content:
                            tc_id = str(target_content.id)
                        else:
                            tc_id = ""
                        entry = polib.POEntry(msgid=source_content.body,
    Severity: Major
    Found in pages/plugins/pofiles/utils.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if entry not in po:
                              po.append(entry)
                  po.save(po_path)
      Severity: Major
      Found in pages/plugins/pofiles/utils.py - About 45 mins to fix

        There are no issues that match your filters.

        Category
        Status