django/django

View on GitHub

Showing 1,782 of 2,090 total issues

Avoid deeply nested control flow statements.
Open

                        if ch not in ("<", "="):
                            raise ValueError(
                                "Non-reversible reg-exp portion: '(?P%s'" % ch
                            )
                        # We are in a named capturing group. Extra the name and
Severity: Major
Found in django/utils/regex_helper.py - About 45 mins to fix

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

    def ensure_echo_on():
        """
        Ensure that echo mode is enabled. Some tools such as PDB disable
        it which causes usability issues after reload.
        """
    Severity: Minor
    Found in django/utils/autoreload.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_queryset has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_queryset(self):
            """
            Return the list of items for this view.
    
            The return value must be an iterable and may be an instance of
    Severity: Minor
    Found in django/views/generic/list.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 build_absolute_uri has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def build_absolute_uri(self, location=None):
            """
            Build an absolute URI from the location and the variables available in
            this request. If no ``location`` is specified, build the absolute URI
            using request.get_full_path(). If the location is absolute, convert it
    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

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

        def scheme(self):
            if settings.SECURE_PROXY_SSL_HEADER:
                try:
                    header, secure_value = settings.SECURE_PROXY_SSL_HEADER
                except ValueError:
    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

                        if origin:
                            filemsg = "file %s, " % origin
                        raise SyntaxError(
    Severity: Major
    Found in django/utils/translation/template.py - About 45 mins to fix

      Avoid deeply nested control flow statements.
      Open

                          if imatch[2]:
                              # A context is provided
                              context_match = context_re.match(imatch[2])
                              message_context = context_match[1]
                              if message_context[0] == '"':
      Severity: Major
      Found in django/utils/translation/template.py - About 45 mins to fix

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

            def _get_source(self, filename, loader, module_name):
                source = None
                if hasattr(loader, "get_source"):
                    try:
                        source = loader.get_source(module_name)
        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

        Avoid deeply nested control flow statements.
        Open

                            if bmatch[1]:
                                # A context is provided
                                context_match = context_re.match(bmatch[1])
                                message_context = context_match[1]
                                if message_context[0] == '"':
        Severity: Major
        Found in django/utils/translation/template.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                              if inplural:
                                  if message_context:
                                      out.write(
                                          " npgettext({p}{!r}, {p}{!r}, {p}{!r},count) ".format(
                                              message_context,
          Severity: Major
          Found in django/utils/translation/template.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                if t.token_type != TokenType.COMMENT:
                                    for c in lineno_comment_map[comment_lineno_cache]:
                                        filemsg = ""
                                        if origin:
                                            filemsg = "file %s, " % origin
            Severity: Major
            Found in django/utils/translation/template.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if terminal_char != ")":
                                          result.append(Group((("%%(%s)s" % param), param)))
                                          walk_to_end(ch, pattern_iter)
                                      else:
                                          result.append(Group((("%%(%s)s" % param), None)))
              Severity: Major
              Found in django/utils/regex_helper.py - About 45 mins to fix

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

                    def iterative_dfs(self, start, forwards=True):
                        """Iterative depth-first search for finding dependencies."""
                        visited = []
                        visited_set = set()
                        stack = [(start, False)]
                Severity: Minor
                Found in django/db/migrations/graph.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 parse_duration has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                Open

                def parse_duration(value):
                    """Parse a duration string and return a datetime.timedelta.
                
                    The preferred format for durations in Django is '%d %H:%M:%S.%f'.
                
                
                Severity: Minor
                Found in django/utils/dateparse.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 arg in args[1:-1]:
                                                self.feed(arg)
                                            self.feed("%s," % args[-1])
                Severity: Major
                Found in django/db/migrations/writer.py - About 45 mins to fix

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

                      def __init__(
                          self, app_label, name, fields, options=None, bases=None, managers=None
                      ):
                          self.app_label = app_label
                          self.name = name
                  Severity: Minor
                  Found in django/db/migrations/state.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 not index.name:
                                              index.set_name_with_model(model)
                                      options["indexes"] = indexes
                  Severity: Major
                  Found in django/db/migrations/state.py - About 45 mins to fix

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

                    def localize(value, use_l10n=None):
                        """
                        Check if value is a localizable type (date, number...) and return it
                        formatted as a string using current locale format.
                    
                    
                    Severity: Minor
                    Found in django/utils/formats.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 migration in self.loader.graph.backwards_plan(root):
                                                if migration in applied:
                                                    plan.append((self.loader.graph.nodes[migration], True))
                                                    applied.pop(migration)
                                # If the migration is already applied, do backwards mode,
                    Severity: Major
                    Found in django/db/migrations/executor.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                                  for arg in args[:-1]:
                                                      self.feed(arg)
                                                  self.feed("%s," % args[-1])
                      Severity: Major
                      Found in django/db/migrations/writer.py - About 45 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language