django/django

View on GitHub
django/template/base.py

Summary

Maintainability
F
5 days
Test Coverage

File base.py has 838 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
This is the Django template system.

How it works:

Severity: Major
Found in django/template/base.py - About 2 days to fix

    Function _resolve_lookup has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
    Open

        def _resolve_lookup(self, context):
            """
            Perform resolution of a real variable (i.e. not a literal) against the
            given context.
    
    
    Severity: Minor
    Found in django/template/base.py - About 6 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 resolve has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
    Open

        def resolve(self, context, ignore_failures=False):
            if isinstance(self.var, Variable):
                try:
                    obj = self.var.resolve(context)
                except VariableDoesNotExist:
    Severity: Minor
    Found in django/template/base.py - About 5 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 parse has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse(self, parse_until=None):
            """
            Iterate through the parser tokens and compiles each one into a node.
    
            If parse_until is provided, parsing will stop once one of the
    Severity: Minor
    Found in django/template/base.py - About 3 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 token_kwargs has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def token_kwargs(bits, parser, support_legacy=False):
        """
        Parse token keyword arguments and return a dictionary of the arguments
        retrieved from the ``bits`` token list.
    
    
    Severity: Minor
    Found in django/template/base.py - About 3 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 __init__ has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, token, parser):
            self.token = token
            matches = filter_re.finditer(token)
            var_obj = None
            filters = []
    Severity: Minor
    Found in django/template/base.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 create_token has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

        def create_token(self, token_string, position, lineno, in_tag):
            """
            Convert the given token string into a new Token object and return it.
            If in_tag is True, we are processing something that matched a tag,
            otherwise it should be treated as a literal string.
    Severity: Minor
    Found in django/template/base.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 __init__ has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
    Open

        def __init__(self, var):
            self.var = var
            self.literal = None
            self.lookups = None
            self.translate = False
    Severity: Minor
    Found in django/template/base.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 resolve has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def resolve(self, context):
            """Resolve this variable against a given context."""
            if self.lookups is not None:
                # We're dealing with a variable that needs to be resolved
                value = self._resolve_lookup(context)
    Severity: Minor
    Found in django/template/base.py - About 45 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 kwargs
    Severity: Major
    Found in django/template/base.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return kwargs
      Severity: Major
      Found in django/template/base.py - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                        return kwargs
        Severity: Major
        Found in django/template/base.py - About 30 mins to fix

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

              def split_contents(self):
                  split = []
                  bits = smart_split(self.contents)
                  for bit in bits:
                      # Handle translation-marked template pieces
          Severity: Minor
          Found in django/template/base.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