django/django

View on GitHub

Showing 2,090 of 2,090 total issues

Avoid deeply nested control flow statements.
Open

                        if extra_params.pop("unique", False) or extra_params.get(
                            "primary_key"
                        ):
                            rel_type = "OneToOneField"
                        else:
Severity: Major
Found in django/core/management/commands/inspectdb.py - About 45 mins to fix

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

    def _route_to_regex(route, is_endpoint):
        """
        Convert a path pattern into a regular expression. Return the regular
        expression and a dictionary mapping the capture names to the converters.
        For example, 'foo/<int:pk>' returns '^foo\\/(?P<pk>[0-9]+)'
    Severity: Minor
    Found in django/urls/resolvers.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 applied_migration:
                                if plan_node in recorded_migrations:
                                    output = " [X] %s" % title
                                else:
                                    title += " Run 'manage.py migrate' to finish recording."
    Severity: Major
    Found in django/core/management/commands/showmigrations.py - About 45 mins to fix

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

      def create_default_site(
      Severity: Minor
      Found in django/contrib/sites/management.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if kwargs.get(k, v) != v:
                                    matches = False
                                    break
                            if not matches:
        Severity: Major
        Found in django/urls/resolvers.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if self.verbosity > 0:
                                      self.stdout.write(self.style.SUCCESS(" OK"))
                          elif self.verbosity > 0:
          Severity: Major
          Found in django/core/management/commands/migrate.py - About 45 mins to fix

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

            def intcomma(value, use_l10n=True):
                """
                Convert an integer to a string containing commas every three digits.
                For example, 3000 becomes '3,000' and 45000 becomes '45,000'.
                """
            Severity: Minor
            Found in django/contrib/humanize/templatetags/humanize.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 __init__ has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def __init__(self, *args, **kwargs):
                    if self.support_js_module_import_aggregation:
                        self.patterns += (self._js_module_import_aggregation_patterns,)
                    super().__init__(*args, **kwargs)
                    self._patterns = {}
            Severity: Minor
            Found in django/contrib/staticfiles/storage.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 check_response has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def check_response(self, response, callback, name=None):
                    """
                    Raise an error if the view returned None or an uncalled coroutine.
                    """
                    if not (response is None or asyncio.iscoroutine(response)):
            Severity: Minor
            Found in django/core/handlers/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

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

                def find(self, path, all=False):
                    """
                    Look for files in the extra locations as defined in STATICFILES_DIRS.
                    """
                    matches = []
            Severity: Minor
            Found in django/contrib/staticfiles/finders.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 len(primary_key_columns) > 1:
                                        comment_notes.append(
                                            "The composite primary key (%s) found, that is not "
                                            "supported. The first column is selected."
                                            % ", ".join(primary_key_columns)
            Severity: Major
            Found in django/core/management/commands/inspectdb.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                          for (
                                              matches,
                                              pat,
                                              defaults,
                                              converters,
              Severity: Major
              Found in django/urls/resolvers.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if self.verbosity > 0:
                                            self.stdout.write(
                                                self.style.MIGRATE_LABEL(f"  Pruning {app}.{name}"),
                                                ending="",
                                            )
                Severity: Major
                Found in django/core/management/commands/migrate.py - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                                          if not found and (not line or plural_forms_re.search(line)):
                                              line = plural_form_line
                                              found = True
                                          lines.append(line)
                  Severity: Major
                  Found in django/core/management/commands/makemessages.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                            if (
                                                self.selected_fields is None
                                                or field.attname in self.selected_fields
                                            ):
                                                self.handle_field(obj, field)
                    Severity: Major
                    Found in django/core/serializers/base.py - About 45 mins to fix

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

                      def forbid_multi_line_headers(name, val, encoding):
                          """Forbid multi-line headers to prevent header injection."""
                          encoding = encoding or settings.DEFAULT_CHARSET
                          val = str(val)  # val may be lazy
                          if "\n" in val or "\r" in val:
                      Severity: Minor
                      Found in django/core/mail/message.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

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

                        Avoid deeply nested control flow statements.
                        Open

                                                if (
                                                    self.selected_fields is None
                                                    or field.attname[:-3] in self.selected_fields
                                                ):
                                                    self.handle_fk_field(obj, field)
                        Severity: Major
                        Found in django/core/serializers/base.py - About 45 mins to fix

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

                          def loads(
                          Severity: Minor
                          Found in django/core/signing.py - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                                if hasattr(rel_model, "natural_key") and rel_model != model:
                                                    deps.append(rel_model)
                                        model_dependencies.append((model, deps))
                            Severity: Major
                            Found in django/core/serializers/__init__.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language