django/django

View on GitHub

Showing 1,782 of 2,090 total issues

Avoid deeply nested control flow statements.
Open

                        if migration in applied:
                            plan.append((self.loader.graph.nodes[migration], True))
                            applied.pop(migration)
            else:
Severity: Major
Found in django/db/migrations/executor.py - About 45 mins to fix

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

        def _reload(self, related_models):
            # Unregister all related models
            with self.apps.bulk_update():
                for rel_app_label, rel_model_name in related_models:
                    self.apps.unregister_model(rel_app_label, rel_model_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 all(
                                m in applied for m in self.replacements[parent].replaces
                            ):
                                continue
                        raise InconsistentMigrationHistory(
    Severity: Major
    Found in django/db/migrations/loader.py - About 45 mins to fix

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

          def _generate_plan(self, nodes, at_end):
              plan = []
              for node in nodes:
                  for migration in self.forwards_plan(node):
                      if migration not in plan and (at_end or migration not in nodes):
      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 remove_replacement_node has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def remove_replacement_node(self, replacement, replaced):
              """
              The inverse operation to `remove_replaced_nodes`. Almost. Remove the
              replacement node `replacement` and remap its child nodes to `replaced`
              - the list of nodes it would have replaced. Don't remap its parent
      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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(
      Severity: Minor
      Found in django/db/migrations/state.py - About 45 mins to fix

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

            def __init__(
        Severity: Minor
        Found in django/db/migrations/questioner.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if (
                                      not args
                                      and new_index.fields == list(removed_index_together)
                                      and set(kwargs) == {"name", "fields"}
                                  ):
          Severity: Major
          Found in django/db/migrations/autodetector.py - About 45 mins to fix

            Avoid deeply nested control flow statements.
            Open

                                    if old_rel_to in self.renamed_models_rel:
                                        old_field_dec[2]["to"] = self.renamed_models_rel[old_rel_to]
                                old_field.set_attributes_from_name(rem_field_name)
            Severity: Major
            Found in django/db/migrations/autodetector.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if new_default is not models.NOT_PROVIDED:
                                          field.default = new_default
                                          preserve_default = False
                                  else:
              Severity: Major
              Found in django/db/migrations/autodetector.py - About 45 mins to fix

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

                    def resolve_expression(
                Severity: Minor
                Found in django/db/models/expressions.py - About 45 mins to fix

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

                      def references_model(self, name, app_label):
                          name_lower = name.lower()
                          if name_lower == self.name_lower:
                              return True
                  
                  
                  Severity: Minor
                  Found in django/db/migrations/operations/models.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 save_base has 6 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def save_base(
                  Severity: Minor
                  Found in django/db/models/base.py - About 45 mins to fix

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

                        def resolve_expression(
                    Severity: Minor
                    Found in django/db/models/expressions.py - About 45 mins to fix

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

                          def resolve_expression(
                      Severity: Minor
                      Found in django/db/models/expressions.py - About 45 mins to fix

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

                            def __get__(self, instance, cls=None):
                                """
                                Retrieve and caches the value from the datastore on the first lookup.
                                Return the cached value.
                                """
                        Severity: Minor
                        Found in django/db/models/query_utils.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 process_rhs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def process_rhs(self, compiler, connection):
                                value = self.rhs
                                if self.bilateral_transforms:
                                    if self.rhs_is_direct_value():
                                        # Do not call get_db_prep_lookup here as the value will be
                        Severity: Minor
                        Found in django/db/models/lookups.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_fields has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def _get_fields(
                        Severity: Minor
                        Found in django/db/models/options.py - About 45 mins to fix

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

                              def _save_parents(
                          Severity: Minor
                          Found in django/db/models/base.py - About 45 mins to fix

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

                                def resolve_expression(
                            Severity: Minor
                            Found in django/db/models/expressions.py - About 45 mins to fix
                              Severity
                              Category
                              Status
                              Source
                              Language