django/django

View on GitHub
django/dispatch/dispatcher.py

Summary

Maintainability
D
1 day
Test Coverage

File dispatcher.py has 377 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import asyncio
import logging
import threading
import weakref

Severity: Minor
Found in django/dispatch/dispatcher.py - About 5 hrs to fix

    Function _live_receivers has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        def _live_receivers(self, sender):
            """
            Filter sequence of receivers to get resolved, live receivers.
    
            This checks for weak references and resolves them, then returning only
    Severity: Minor
    Found in django/dispatch/dispatcher.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 connect has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

        def connect(self, receiver, sender=None, weak=True, dispatch_uid=None):
            """
            Connect receiver to sender for signal.
    
            Arguments:
    Severity: Minor
    Found in django/dispatch/dispatcher.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 send_robust has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def send_robust(self, sender, **named):
            """
            Send signal from sender to all connected receivers catching errors.
    
            If any receivers are asynchronous, they are called after all the
    Severity: Minor
    Found in django/dispatch/dispatcher.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 too many return statements within this function.
    Open

            return responses
    Severity: Major
    Found in django/dispatch/dispatcher.py - About 30 mins to fix

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

                  def sync_send():
                      responses = []
                      for receiver in sync_receivers:
                          try:
                              response = receiver(signal=self, sender=sender, **named)
      Severity: Minor
      Found in django/dispatch/dispatcher.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 receiver has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def receiver(signal, **kwargs):
          """
          A decorator for connecting receivers to signals. Used by passing in the
          signal (or list of signals) and keyword arguments to connect::
      
      
      Severity: Minor
      Found in django/dispatch/dispatcher.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