divio/django-cms

View on GitHub
cms/models/pluginmodel.py

Summary

Maintainability
C
1 day
Test Coverage

File pluginmodel.py has 423 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import inspect
import json
import os
import warnings
from datetime import date
Severity: Minor
Found in cms/models/pluginmodel.py - About 6 hrs to fix

    Function save has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(self, no_signals=False, *args, **kwargs):
            if not self.depth:
                if self.parent_id or self.parent:
                    self.parent.add_child(instance=self)
                else:
    Severity: Minor
    Found in cms/models/pluginmodel.py - About 45 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 copy_plugin has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def copy_plugin(self, target_placeholder, target_language, parent_cache, no_signals=False):
    Severity: Minor
    Found in cms/models/pluginmodel.py - About 35 mins to fix

      Function fix_tree has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def fix_tree(cls, **kwargs):
              """
              Fixes the plugin tree by first calling treebeard fix_tree and the
              recalculating the correct position property for each plugin.
              """
      Severity: Minor
      Found in cms/models/pluginmodel.py - About 25 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 __new__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __new__(cls, name, bases, attrs):
              super_new = super().__new__
              # remove RenderMeta from the plugin class
              attr_meta = attrs.pop('RenderMeta', None)
      
      
      Severity: Minor
      Found in cms/models/pluginmodel.py - About 25 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

      There are no issues that match your filters.

      Category
      Status