django/django

View on GitHub
django/contrib/admindocs/utils.py

Summary

Maintainability
A
3 hrs
Test Coverage

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

def parse_docstring(docstring):
    """
    Parse out the parts of a docstring.  Return (title, body, metadata).
    """
    if not docstring:
Severity: Minor
Found in django/contrib/admindocs/utils.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

Function default_reference_role has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

def default_reference_role(
Severity: Major
Found in django/contrib/admindocs/utils.py - About 50 mins to fix

    Function _role has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def _role(name, rawtext, text, lineno, inliner, options=None, content=None):
    Severity: Major
    Found in django/contrib/admindocs/utils.py - About 50 mins to fix

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

      def _get_group_start_end(start, end, pattern):
          # Handle nested parentheses, e.g. '^(?P<a>(x|y))/b' or '^b/((x|y)\w+)$'.
          unmatched_open_brackets, prev_char = 1, None
          for idx, val in enumerate(pattern[end:]):
              # Check for unescaped `(` and `)`. They mark the start and end of a
      Severity: Minor
      Found in django/contrib/admindocs/utils.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 _find_groups has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

      def _find_groups(pattern, group_matcher):
          prev_end = None
          for match in group_matcher.finditer(pattern):
              if indices := _get_group_start_end(match.start(0), match.end(0), pattern):
                  start, end = indices
      Severity: Minor
      Found in django/contrib/admindocs/utils.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