fabiocaccamo/django-maintenance-mode

View on GitHub

Showing 12 of 12 total issues

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

def _need_maintenance_ignore_ip_addresses(request):
    if not settings.MAINTENANCE_MODE_IGNORE_IP_ADDRESSES:
        return

    if settings.MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS:
Severity: Minor
Found in maintenance_mode/http.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 need_maintenance_response has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

def need_maintenance_response(request):
    """
    Tells if the given request needs a maintenance response or not.
    """

Severity: Minor
Found in maintenance_mode/http.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 _need_maintenance_ignore_users has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

def _need_maintenance_ignore_users(request):
    if not hasattr(request, "user"):
        return

    user = request.user
Severity: Minor
Found in maintenance_mode/http.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

Avoid too many return statements within this function.
Open

        return value
Severity: Major
Found in maintenance_mode/http.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return False
    Severity: Major
    Found in maintenance_mode/http.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return value
      Severity: Major
      Found in maintenance_mode/http.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return value
        Severity: Major
        Found in maintenance_mode/http.py - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return value
          Severity: Major
          Found in maintenance_mode/http.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return value
            Severity: Major
            Found in maintenance_mode/http.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return True
              Severity: Major
              Found in maintenance_mode/http.py - About 30 mins to fix

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

                def _need_maintenance_ignore_urls(request):
                    if not settings.MAINTENANCE_MODE_IGNORE_URLS:
                        return
                
                    for url in settings.MAINTENANCE_MODE_IGNORE_URLS:
                Severity: Minor
                Found in maintenance_mode/http.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 _need_maintenance_ignore_tests has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def _need_maintenance_ignore_tests(request):
                    if not settings.MAINTENANCE_MODE_IGNORE_TESTS:
                        return
                
                    is_testing = False
                Severity: Minor
                Found in maintenance_mode/http.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

                Severity
                Category
                Status
                Source
                Language