django/django

View on GitHub

Showing 1,782 of 2,090 total issues

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

    def __init__(
Severity: Minor
Found in django/template/context.py - About 45 mins to fix

    Function simple_tag has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def simple_tag(self, func=None, takes_context=None, name=None):
            """
            Register a callable as a compiled template tag. Example:
    
            @register.simple_tag
    Severity: Minor
    Found in django/template/library.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

    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 deeply nested control flow statements.
    Open

                                    if chunk is None:
                                        # Don't continue if the chunk received by
                                        # the handler is None.
                                        break
    
    
    Severity: Major
    Found in django/http/multipartparser.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                              while ch != terminal_char:
                                  name.append(ch)
                                  ch, escaped = next(pattern_iter)
                              param = "".join(name)
      Severity: Major
      Found in django/utils/regex_helper.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                            for cmatch in cmatches:
                                out.write(" _(%s) " % cmatch)
                        elif t.contents == "comment":
        Severity: Major
        Found in django/utils/translation/template.py - About 45 mins to fix

          Function contains has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

          def contains(source, inst):
              """
              Return True if the "source" contains an instance of "inst". False,
              otherwise.
              """
          Severity: Minor
          Found in django/utils/regex_helper.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

          Function format has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def format(self, formatstr):
                  pieces = []
                  for i, piece in enumerate(re_formatchars.split(str(formatstr))):
                      if i % 2:
                          if type(self.data) is date and hasattr(TimeFormat, piece):
          Severity: Minor
          Found in django/utils/dateformat.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

          Function get_traceback_frames has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_traceback_frames(self):
                  # Get the exception and all its causes
                  exceptions = []
                  exc_value = self.exc_value
                  while exc_value:
          Severity: Minor
          Found in django/views/debug.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

          Function get_dated_queryset has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def get_dated_queryset(self, **lookup):
                  """
                  Get a queryset properly filtered according to `allow_future` and any
                  extra lookup kwargs.
                  """
          Severity: Minor
          Found in django/views/generic/dates.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 deeply nested control flow statements.
          Open

                                  if param in cleansed:
                                      cleansed[param] = self.cleansed_substitute
                              return cleansed
          Severity: Major
          Found in django/views/debug.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if (
                                    translators_comment_start is not None
                                    and lineno >= translators_comment_start
                                ):
                                    out.write(" # %s" % line)
            Severity: Major
            Found in django/utils/translation/template.py - About 45 mins to fix

              Function handle_word has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def handle_word(
              Severity: Minor
              Found in django/utils/html.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                    if line.lstrip().startswith(TRANSLATOR_COMMENT_MARK):
                                        translators_comment_start = lineno
                                for lineno, line in enumerate(content.splitlines(True)):
                Severity: Major
                Found in django/utils/translation/template.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                      if g[0] == '"':
                                          g = g.strip('"')
                                      elif g[0] == "'":
                                          g = g.strip("'")
                                      g = g.replace("%", "%%")
                  Severity: Major
                  Found in django/utils/translation/template.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if ch == "<":
                                                terminal_char = ">"
                                            # We are in a named backreference.
                                            else:
                                                terminal_char = ")"
                    Severity: Major
                    Found in django/utils/regex_helper.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                      while remaining != 0:
                                                          over_chunk = field_stream.read(4 - remaining)
                                                          if not over_chunk:
                                                              break
                                                          stripped_chunk += b"".join(over_chunk.split())
                      Severity: Major
                      Found in django/http/multipartparser.py - About 45 mins to fix

                        Function get_signed_cookie has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def get_signed_cookie(self, key, default=RAISE_ERROR, salt="", max_age=None):
                                """
                                Attempt to return a signed cookie. If the signature fails or the
                                cookie has expired, raise an exception, unless the `default` argument
                                is provided,  in which case return that value.
                        Severity: Minor
                        Found in django/http/request.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 deeply nested control flow statements.
                        Open

                                            for fmatch in constant_re.findall(t.contents):
                                                out.write(" _(%s) " % fmatch)
                                            if bmatch[1]:
                        Severity: Major
                        Found in django/utils/translation/template.py - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                              if p.find(":_(") >= 0:
                                                  out.write(" %s " % p.split(":", 1)[1])
                                              else:
                                                  out.write(blankout(p, "F"))
                                      elif t.token_type == TokenType.COMMENT:
                          Severity: Major
                          Found in django/utils/translation/template.py - About 45 mins to fix
                            Severity
                            Category
                            Status
                            Source
                            Language