divio/django-cms

View on GitHub
cms/forms/widgets.py

Summary

Maintainability
A
2 hrs
Test Coverage

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

    def create_option(self, name, value, label, selected, index, subindex=None, attrs=None):
Severity: Major
Found in cms/forms/widgets.py - About 1 hr to fix

    Function render has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def render(self, name, value, attrs=None, choices=(), renderer=None):
    Severity: Minor
    Found in cms/forms/widgets.py - About 35 mins to fix

      Function _has_changed has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _has_changed(self, initial, data):
              # THIS IS A COPY OF django.forms.widgets.Widget._has_changed()
              # (except for the first if statement)
      
              """
      Severity: Minor
      Found in cms/forms/widgets.py - About 35 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 _build_option has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

          def _build_option(self, selected_choices, option_value, option_label):
              if option_value is None:
                  option_value = ''
              option_value = force_str(option_value)
              if option_value in selected_choices:
      Severity: Minor
      Found in cms/forms/widgets.py - About 35 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