django/django

View on GitHub

Showing 2,090 of 2,090 total issues

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

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

    Avoid deeply nested control flow statements.
    Open

                            if rel_to in used_relations:
                                extra_params["related_name"] = "%s_%s_set" % (
                                    model_name.lower(),
                                    att_name,
                                )
    Severity: Major
    Found in django/core/management/commands/inspectdb.py - About 45 mins to fix

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

          def register(self, check=None, *tags, **kwargs):
              """
              Can be used as a function or a decorator. Register given function
              `f` labeled with given `tags`. The function should receive **kwargs
              and return list of Errors and Warnings.
      Severity: Minor
      Found in django/core/checks/registry.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 hasattr(rel_model, "natural_key") and rel_model != model:
                              deps.append(rel_model)
                  # Also add a dependency for any simple M2M relation with a model
                  # that defines a natural key.  M2M relations with explicit through
                  # models don't count as dependencies.
      Severity: Major
      Found in django/core/serializers/__init__.py - About 45 mins to fix

        Avoid deeply nested control flow statements.
        Open

                                if rel_to in known_models:
                                    field_type = "%s(%s" % (rel_type, rel_to)
                                else:
                                    field_type = "%s('%s'" % (rel_type, rel_to)
                                if rel_to in used_relations:
        Severity: Major
        Found in django/core/management/commands/inspectdb.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                  if errors:
                                      self.stderr.write(
                                          "Execution of %s failed: %s" % (self.program, errors)
                                      )
                                  else:
          Severity: Major
          Found in django/core/management/commands/compilemessages.py - About 45 mins to fix

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

                def new_file(
            Severity: Minor
            Found in django/core/files/uploadhandler.py - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                                      if not os.path.isfile(init_path):
                                          open(init_path, "w").close()
                                      # We just do this once per app
                                      directory_created[app_label] = True
              Severity: Major
              Found in django/core/management/commands/makemigrations.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if writer.needs_manual_porting:
                                            migration_path = self.get_relative_path(writer.path)
                                            self.log(
                                                self.style.WARNING(
                                                    f"Updated migration {migration_path} requires "
                Severity: Major
                Found in django/core/management/commands/makemigrations.py - About 45 mins to fix

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

                      def __init__(self, name, value, base, sysid, pubid, notation_name):
                  Severity: Minor
                  Found in django/core/serializers/xml_serializer.py - About 45 mins to fix

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

                            def close(self):
                                if not self.close_called:
                                    self.close_called = True
                                    try:
                                        self.file.close()
                    Severity: Minor
                    Found in django/core/files/temp.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

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

                        @cached_property
                        def django_test_skips(self):
                            skips = super().django_test_skips
                            skips.update(
                                {
                    Severity: Minor
                    Found in django/contrib/gis/db/backends/oracle/features.py and 1 other location - About 45 mins to fix
                    django/contrib/gis/db/backends/spatialite/features.py on lines 16..26

                    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 35.

                    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

                        function ready(fn) {
                            if (document.readyState !== 'loading') {
                                fn();
                            } else {
                                document.addEventListener('DOMContentLoaded', fn);
                    Severity: Minor
                    Found in django/contrib/admin/static/admin/js/cancel.js and 1 other location - About 45 mins to fix
                    django/contrib/admin/static/admin/js/actions.js on lines 190..196

                    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 50.

                    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

                        user_permissions = models.ManyToManyField(
                            Permission,
                            verbose_name=_("user permissions"),
                            blank=True,
                            help_text=_("Specific permissions for this user."),
                    Severity: Minor
                    Found in django/contrib/auth/models.py and 1 other location - About 45 mins to fix
                    django/contrib/auth/models.py on lines 257..261

                    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 35.

                    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

                                with builtin_template_path("csrf_403.html").open(encoding="utf-8") as fh:
                                    t = Engine().from_string(fh.read())
                    Severity: Minor
                    Found in django/views/csrf.py and 1 other location - About 45 mins to fix
                    django/views/i18n.py on lines 216..217

                    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 35.

                    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

                            with builtin_template_path("i18n_catalog.js").open(encoding="utf-8") as fh:
                                template = Engine().from_string(fh.read())
                    Severity: Minor
                    Found in django/views/i18n.py and 1 other location - About 45 mins to fix
                    django/views/csrf.py on lines 74..75

                    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 35.

                    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

                        function ready(fn) {
                            if (document.readyState !== 'loading') {
                                fn();
                            } else {
                                document.addEventListener('DOMContentLoaded', fn);
                    Severity: Minor
                    Found in django/contrib/admin/static/admin/js/actions.js and 1 other location - About 45 mins to fix
                    django/contrib/admin/static/admin/js/cancel.js on lines 6..12

                    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 50.

                    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

                        @cached_property
                        def django_test_skips(self):
                            skips = super().django_test_skips
                            skips.update(
                                {
                    Severity: Minor
                    Found in django/contrib/gis/db/backends/spatialite/features.py and 1 other location - About 45 mins to fix
                    django/contrib/gis/db/backends/oracle/features.py on lines 17..28

                    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 35.

                    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 check(self, **kwargs):
                            errors = super().check(**kwargs)
                            errors.extend(self._check_field_name())
                            return errors
                    Severity: Minor
                    Found in django/contrib/sites/managers.py and 1 other location - About 45 mins to fix
                    django/db/models/fields/mixins.py on lines 56..59

                    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 35.

                    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_field.remote_field.through._meta.get_field(
                                                old_field.m2m_field_name()
                                            ),
                                            new_field.remote_field.through._meta.get_field(
                                                new_field.m2m_field_name()
                    Severity: Minor
                    Found in django/db/backends/sqlite3/schema.py and 1 other location - About 45 mins to fix
                    django/db/backends/sqlite3/schema.py on lines 421..425

                    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 35.

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language