django/django

View on GitHub
django/db/migrations/autodetector.py

Summary

Maintainability
F
3 wks
Test Coverage

File autodetector.py has 1130 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import functools
import re
from itertools import chain

from django.conf import settings
Severity: Major
Found in django/db/migrations/autodetector.py - About 2 days to fix

    Function _build_migration_list has a Cognitive Complexity of 83 (exceeds 5 allowed). Consider refactoring.
    Open

        def _build_migration_list(self, graph=None):
            """
            Chop the lists of operations up into migrations with dependencies on
            each other. Do this by going through an app's list of operations until
            one is found that has an outgoing dependency that isn't in another
    Severity: Minor
    Found in django/db/migrations/autodetector.py - About 1 day 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 generate_created_models has a Cognitive Complexity of 55 (exceeds 5 allowed). Consider refactoring.
    Open

        def generate_created_models(self):
            """
            Find all new models (both managed and unmanaged) and make create
            operations for them as well as separate operations to create any
            foreign key or M2M relationships (these are optimized later, if
    Severity: Minor
    Found in django/db/migrations/autodetector.py - About 1 day 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

    Consider simplifying this complex logical expression.
    Open

            if dependency[2] is None and dependency[3] is True:
                return (
                    isinstance(operation, operations.CreateModel) and
                    operation.name_lower == dependency[1].lower()
                )
    Severity: Critical
    Found in django/db/migrations/autodetector.py - About 6 hrs to fix

      Function generate_altered_fields has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
      Open

          def generate_altered_fields(self):
              """
              Make AlterField operations, or possibly RemovedField/AddField if alter
              isn's possible.
              """
      Severity: Minor
      Found in django/db/migrations/autodetector.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

      MigrationAutodetector has 43 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class MigrationAutodetector:
          """
          Take a pair of ProjectStates and compare them to see what the first would
          need doing to make it match the second (the second usually being the
          project's current state).
      Severity: Minor
      Found in django/db/migrations/autodetector.py - About 5 hrs to fix

        Function generate_deleted_models has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
        Open

            def generate_deleted_models(self):
                """
                Find all deleted models (managed and unmanaged) and make delete
                operations for them as well as separate operations to delete any
                foreign key or M2M relationships (these are optimized later, if
        Severity: Minor
        Found in django/db/migrations/autodetector.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 arrange_for_graph has a Cognitive Complexity of 36 (exceeds 5 allowed). Consider refactoring.
        Open

            def arrange_for_graph(self, changes, graph, migration_name=None):
                """
                Take a result from changes() and a MigrationGraph, and fix the names
                and dependencies of the changes so they extend the graph from the leaf
                nodes for each app.
        Severity: Minor
        Found in django/db/migrations/autodetector.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 generate_renamed_models has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
        Open

            def generate_renamed_models(self):
                """
                Find any renamed models, generate the operations for them, and remove
                the old entry from the model lists. Must be run before other
                model-level generation.
        Severity: Minor
        Found in django/db/migrations/autodetector.py - About 4 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 generate_renamed_fields has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
        Open

            def generate_renamed_fields(self):
                """Work out renamed fields."""
                self.renamed_fields = {}
                for app_label, model_name, field_name in sorted(self.new_field_keys - self.old_field_keys):
                    old_model_name = self.renamed_models.get((app_label, model_name), model_name)
        Severity: Minor
        Found in django/db/migrations/autodetector.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 _sort_migrations has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

            def _sort_migrations(self):
                """
                Reorder to make things possible. Reordering may be needed so FKs work
                nicely inside the same app.
                """
        Severity: Minor
        Found in django/db/migrations/autodetector.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 check_dependency has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            def check_dependency(self, operation, dependency):
                """
                Return True if the given operation depends on the given dependency,
                False otherwise.
                """
        Severity: Minor
        Found in django/db/migrations/autodetector.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 _generate_altered_foo_together has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
        Open

            def _generate_altered_foo_together(self, operation):
                option_name = operation.option_name
                for app_label, model_name in sorted(self.kept_model_keys):
                    old_model_name = self.renamed_models.get((app_label, model_name), model_name)
                    old_model_state = self.from_state.models[app_label, old_model_name]
        Severity: Minor
        Found in django/db/migrations/autodetector.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 _detect_changes has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            def _detect_changes(self, convert_apps=None, graph=None):
                """
                Return a dict of migration plans which will achieve the
                change from from_state to to_state. The dict has app labels
                as keys and a list of migrations as values.
        Severity: Minor
        Found in django/db/migrations/autodetector.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 _detect_changes has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def _detect_changes(self, convert_apps=None, graph=None):
                """
                Return a dict of migration plans which will achieve the
                change from from_state to to_state. The dict has app labels
                as keys and a list of migrations as values.
        Severity: Minor
        Found in django/db/migrations/autodetector.py - About 1 hr to fix

          Function deep_deconstruct has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def deep_deconstruct(self, obj):
                  """
                  Recursive deconstruction for a field and its arguments.
                  Used for full comparison for rename/alter; sometimes a single-level
                  deconstruction will not compare correctly.
          Severity: Minor
          Found in django/db/migrations/autodetector.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 _trim_to_apps has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def _trim_to_apps(self, changes, app_labels):
                  """
                  Take changes from arrange_for_graph() and set of app labels, and return
                  a modified set of changes which trims out as many migrations that are
                  not in app_labels as possible. Note that some other migrations may
          Severity: Minor
          Found in django/db/migrations/autodetector.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 _generate_added_field has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def _generate_added_field(self, app_label, model_name, field_name):
                  field = self.new_apps.get_model(app_label, model_name)._meta.get_field(field_name)
                  # Fields that are foreignkeys/m2ms depend on stuff
                  dependencies = []
                  if field.remote_field and field.remote_field.model:
          Severity: Minor
          Found in django/db/migrations/autodetector.py - About 55 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 _optimize_migrations has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def _optimize_migrations(self):
                  # Add in internal dependencies among the migrations
                  for app_label, migrations in self.migrations.items():
                      for m1, m2 in zip(migrations, migrations[1:]):
                          m2.dependencies.append((app_label, m1.name))
          Severity: Minor
          Found in django/db/migrations/autodetector.py - About 55 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 suggest_name has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              def suggest_name(cls, ops):
                  """
                  Given a set of operations, suggest a name for the migration they might
                  represent. Names are not guaranteed to be unique, but put some effort
                  into the fallback name to avoid VCS conflicts if possible.
          Severity: Minor
          Found in django/db/migrations/autodetector.py - About 55 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 op2 in ops:
                                      if self.check_dependency(op2, dep):
                                          dependency_graph[op].add(op2)
          
                      # we use a stable sort for deterministic tests & general behavior
          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 self.questioner.ask_rename_model(rem_model_state, model_state):
                                          model_opts = self.new_apps.get_model(app_label, model_name)._meta
                                          dependencies = []
                                          for field in model_opts.get_fields():
                                              if field.is_relation:
              Severity: Major
              Found in django/db/migrations/autodetector.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if dep[0] != app_label:
                                            # External app dependency. See if it's not yet
                                            # satisfied.
                                            for other_operation in self.generated_operations.get(dep[0], []):
                                                if self.check_dependency(other_operation, dep):
                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

                    Avoid deeply nested control flow statements.
                    Open

                                            if field.primary_key:
                                                primary_key_rel = field.remote_field.model
                                            elif not field.remote_field.parent_link:
                                                related_fields[field.name] = field
                                        # through will be none on M2Ms on swapped-out models;
                    Severity: Major
                    Found in django/db/migrations/autodetector.py - About 45 mins to fix

                      Avoid deeply nested control flow statements.
                      Open

                                              if self.questioner.ask_rename(model_name, rem_field_name, field_name, field):
                                                  self.add_operation(
                                                      app_label,
                                                      operations.RenameField(
                                                          model_name=model_name,
                      Severity: Major
                      Found in django/db/migrations/autodetector.py - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                                if field.remote_field and field.remote_field.model:
                                                    dependencies.extend(self._get_dependencies_for_foreign_key(field))
                        
                        
                        Severity: Major
                        Found in django/db/migrations/autodetector.py - About 45 mins to fix

                          Function _generate_through_model_map has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def _generate_through_model_map(self):
                                  """Through model map generation."""
                                  for app_label, model_name in sorted(self.old_model_keys):
                                      old_model_name = self.renamed_models.get((app_label, model_name), model_name)
                                      old_model_state = self.from_state.models[app_label, old_model_name]
                          Severity: Minor
                          Found in django/db/migrations/autodetector.py - About 35 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 "auto_%s" % get_migration_name_timestamp()
                          Severity: Major
                          Found in django/db/migrations/autodetector.py - About 30 mins to fix

                            Avoid too many return statements within this function.
                            Open

                                        return obj
                            Severity: Major
                            Found in django/db/migrations/autodetector.py - About 30 mins to fix

                              Avoid too many return statements within this function.
                              Open

                                          return (
                              Severity: Major
                              Found in django/db/migrations/autodetector.py - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                            return (
                                Severity: Major
                                Found in django/db/migrations/autodetector.py - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                                  return "_".join(sorted(o.name_lower for o in ops))
                                  Severity: Major
                                  Found in django/db/migrations/autodetector.py - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                                return obj
                                    Severity: Major
                                    Found in django/db/migrations/autodetector.py - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                                  return (
                                      Severity: Major
                                      Found in django/db/migrations/autodetector.py - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                                    return RegexObject(obj)
                                        Severity: Major
                                        Found in django/db/migrations/autodetector.py - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                      return (
                                          Severity: Major
                                          Found in django/db/migrations/autodetector.py - About 30 mins to fix

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

                                                def generate_altered_order_with_respect_to(self):
                                                    for app_label, model_name in sorted(self.kept_model_keys):
                                                        old_model_name = self.renamed_models.get((app_label, model_name), model_name)
                                                        old_model_state = self.from_state.models[app_label, old_model_name]
                                                        new_model_state = self.to_state.models[app_label, model_name]
                                            Severity: Minor
                                            Found in django/db/migrations/autodetector.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

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

                                                def generate_created_proxies(self):
                                                    """
                                                    Make CreateModel statements for proxy models. Use the same statements
                                                    as that way there's less code duplication, but of course for proxy
                                                    models it's safe to skip all the pointless field stuff and just chuck
                                            Severity: Minor
                                            Found in django/db/migrations/autodetector.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

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                def create_altered_constraints(self):
                                                    option_name = operations.AddConstraint.option_name
                                                    for app_label, model_name in sorted(self.kept_model_keys):
                                                        old_model_name = self.renamed_models.get((app_label, model_name), model_name)
                                                        old_model_state = self.from_state.models[app_label, old_model_name]
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 1 day to fix
                                            django/db/migrations/autodetector.py on lines 980..994

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 175.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                def create_altered_indexes(self):
                                                    option_name = operations.AddIndex.option_name
                                                    for app_label, model_name in sorted(self.kept_model_keys):
                                                        old_model_name = self.renamed_models.get((app_label, model_name), model_name)
                                                        old_model_state = self.from_state.models[app_label, old_model_name]
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 1 day to fix
                                            django/db/migrations/autodetector.py on lines 1020..1034

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 175.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Identical blocks of code found in 3 locations. Consider refactoring.
                                            Open

                                                        for field in model_opts.local_many_to_many:
                                                            if field.remote_field.model:
                                                                related_fields[field.name] = field
                                                            if getattr(field.remote_field, "through", None) and not field.remote_field.through._meta.auto_created:
                                                                related_fields[field.name] = field
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 2 other locations - About 3 hrs to fix
                                            django/db/migrations/autodetector.py on lines 727..734
                                            django/db/migrations/autodetector.py on lines 735..739

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 64.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Identical blocks of code found in 3 locations. Consider refactoring.
                                            Open

                                                        for field in model._meta.local_many_to_many:
                                                            if field.remote_field.model:
                                                                related_fields[field.name] = field
                                                            if getattr(field.remote_field, "through", None) and not field.remote_field.through._meta.auto_created:
                                                                related_fields[field.name] = field
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 2 other locations - About 3 hrs to fix
                                            django/db/migrations/autodetector.py on lines 543..547
                                            django/db/migrations/autodetector.py on lines 727..734

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 64.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Identical blocks of code found in 3 locations. Consider refactoring.
                                            Open

                                                            if field.remote_field:
                                                                if field.remote_field.model:
                                                                    related_fields[field.name] = field
                                                                # through will be none on M2Ms on swapped-out models;
                                                                # we can treat lack of through as auto_created=True, though.
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 2 other locations - About 3 hrs to fix
                                            django/db/migrations/autodetector.py on lines 543..547
                                            django/db/migrations/autodetector.py on lines 735..739

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 64.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                def generate_removed_indexes(self):
                                                    for (app_label, model_name), alt_indexes in self.altered_indexes.items():
                                                        for index in alt_indexes['removed_indexes']:
                                                            self.add_operation(
                                                                app_label,
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 2 hrs to fix
                                            django/db/migrations/autodetector.py on lines 1049..1056

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 59.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                def generate_removed_constraints(self):
                                                    for (app_label, model_name), alt_constraints in self.altered_constraints.items():
                                                        for constraint in alt_constraints['removed_constraints']:
                                                            self.add_operation(
                                                                app_label,
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 2 hrs to fix
                                            django/db/migrations/autodetector.py on lines 1009..1016

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 59.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                def generate_added_indexes(self):
                                                    for (app_label, model_name), alt_indexes in self.altered_indexes.items():
                                                        for index in alt_indexes['added_indexes']:
                                                            self.add_operation(
                                                                app_label,
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 2 hrs to fix
                                            django/db/migrations/autodetector.py on lines 1038..1043

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 57.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                def generate_added_constraints(self):
                                                    for (app_label, model_name), alt_constraints in self.altered_constraints.items():
                                                        for constraint in alt_constraints['added_constraints']:
                                                            self.add_operation(
                                                                app_label,
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 2 hrs to fix
                                            django/db/migrations/autodetector.py on lines 998..1003

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 57.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Identical blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                        for base in model_state.bases:
                                                            if isinstance(base, str) and "." in base:
                                                                base_app_label, base_name = base.split(".", 1)
                                                                dependencies.append((base_app_label, base_name, None, True))
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 2 hrs to fix
                                            django/db/migrations/autodetector.py on lines 559..562

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 57.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Identical blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                        for base in model_state.bases:
                                                            if isinstance(base, str) and "." in base:
                                                                base_app_label, base_name = base.split(".", 1)
                                                                dependencies.append((base_app_label, base_name, None, True))
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 2 hrs to fix
                                            django/db/migrations/autodetector.py on lines 689..692

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 57.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                    elif dependency[2] is not None and dependency[3] is False:
                                                        return (
                                                            isinstance(operation, operations.RemoveField) and
                                                            operation.model_name_lower == dependency[1].lower() and
                                                            operation.name_lower == dependency[2].lower()
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 2 hrs to fix
                                            django/db/migrations/autodetector.py on lines 413..417

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 52.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                    elif dependency[2] is not None and dependency[3] == "alter":
                                                        return (
                                                            isinstance(operation, operations.AlterField) and
                                                            operation.model_name_lower == dependency[1].lower() and
                                                            operation.name_lower == dependency[2].lower()
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 2 hrs to fix
                                            django/db/migrations/autodetector.py on lines 400..404

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 52.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                def generate_removed_fields(self):
                                                    """Make RemoveField operations."""
                                                    for app_label, model_name, field_name in sorted(self.old_field_keys - self.new_field_keys):
                                                        self._generate_removed_field(app_label, model_name, field_name)
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 1 hr to fix
                                            django/db/migrations/autodetector.py on lines 847..850

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 44.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                def generate_added_fields(self):
                                                    """Make AddField operations."""
                                                    for app_label, model_name, field_name in sorted(self.new_field_keys - self.old_field_keys):
                                                        self._generate_added_field(app_label, model_name, field_name)
                                            Severity: Major
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 1 hr to fix
                                            django/db/migrations/autodetector.py on lines 883..886

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 44.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                        elif (
                                                            al not in self.from_state.real_apps or
                                                            (convert_apps and al in convert_apps)
                                                        ):
                                                            if model._meta.proxy:
                                            Severity: Minor
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 55 mins to fix
                                            django/db/migrations/autodetector.py on lines 140..144

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 37.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                        elif al not in self.from_state.real_apps:
                                                            if model._meta.proxy:
                                                                self.old_proxy_keys.add((al, mn))
                                                            else:
                                                                self.old_model_keys.add((al, mn))
                                            Severity: Minor
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 55 mins to fix
                                            django/db/migrations/autodetector.py on lines 150..157

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 37.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                        new_options = {
                                                            key: value for key, value in new_model_state.options.items()
                                                            if key in AlterModelOptions.ALTER_OPTION_KEYS
                                            Severity: Minor
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 40 mins to fix
                                            django/db/migrations/autodetector.py on lines 1158..1160

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 34.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                        old_options = {
                                                            key: value for key, value in old_model_state.options.items()
                                                            if key in AlterModelOptions.ALTER_OPTION_KEYS
                                            Severity: Minor
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 40 mins to fix
                                            django/db/migrations/autodetector.py on lines 1162..1164

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 34.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                    elif dependency[2] is None and dependency[3] is False:
                                                        return (
                                                            isinstance(operation, operations.DeleteModel) and
                                                            operation.name_lower == dependency[1].lower()
                                            Severity: Minor
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 35 mins to fix
                                            django/db/migrations/autodetector.py on lines 380..383

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 33.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            Similar blocks of code found in 2 locations. Consider refactoring.
                                            Open

                                                    if dependency[2] is None and dependency[3] is True:
                                                        return (
                                                            isinstance(operation, operations.CreateModel) and
                                                            operation.name_lower == dependency[1].lower()
                                            Severity: Minor
                                            Found in django/db/migrations/autodetector.py and 1 other location - About 35 mins to fix
                                            django/db/migrations/autodetector.py on lines 407..410

                                            Duplicated Code

                                            Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                                            Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                                            When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                                            Tuning

                                            This issue has a mass of 33.

                                            We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                            The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                            If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                            See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                            Refactorings

                                            Further Reading

                                            There are no issues that match your filters.

                                            Category
                                            Status