django/django

View on GitHub
django/core/validators.py

Summary

Maintainability
C
1 day
Test Coverage

File validators.py has 447 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import ipaddress
import re
import warnings
from pathlib import Path
from urllib.parse import urlsplit, urlunsplit
Severity: Minor
Found in django/core/validators.py - About 6 hrs to fix

    Function __call__ has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, value):
            if not isinstance(value, str):
                raise ValidationError(self.message, code=self.code, params={'value': value})
            # Check if the scheme is valid.
            scheme = value.split('://')[0].lower()
    Severity: Minor
    Found in django/core/validators.py - About 2 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 __call__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, value):
            if not value or '@' not in value:
                raise ValidationError(self.message, code=self.code, params={'value': value})
    
            user_part, domain_part = value.rsplit('@', 1)
    Severity: Minor
    Found in django/core/validators.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 __call__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def __call__(self, value):
            digit_tuple, exponent = value.as_tuple()[1:]
            if exponent in {'F', 'n', 'N'}:
                raise ValidationError(self.messages['invalid'], code='invalid', params={'value': value})
            if exponent >= 0:
    Severity: Minor
    Found in django/core/validators.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 __init__ has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def __init__(self, regex=None, message=None, code=None, inverse_match=None, flags=None):
    Severity: Minor
    Found in django/core/validators.py - About 35 mins to fix

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

          def __init__(self, message=None, code=None, allowlist=None, *, whitelist=None):
      Severity: Minor
      Found in django/core/validators.py - About 35 mins to fix

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

            def __init__(self, regex=None, message=None, code=None, inverse_match=None, flags=None):
                if regex is not None:
                    self.regex = regex
                if message is not None:
                    self.message = message
        Severity: Minor
        Found in django/core/validators.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