django/django

View on GitHub

Showing 2,092 of 2,092 total issues

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

    groups = models.ManyToManyField(
        Group,
        verbose_name=_("groups"),
        blank=True,
        help_text=_(
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 268..272

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

                        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 419..423

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

            } else {
                // Otherwise, just insert the remove button as the
                // last child element of the form's container:
                row.children(":first").append('<span><a class="' + options.deleteCssClass + '" href="#">' + options.deleteText + "</a></span>");
            }
Severity: Minor
Found in django/contrib/admin/static/admin/js/inlines.js and 1 other location - About 40 mins to fix
django/contrib/admin/static/admin/js/inlines.js on lines 104..108

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

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

    function show(selector) {
        document.querySelectorAll(selector).forEach(function(el) {
            el.classList.remove('hidden');
        });
    }
Severity: Minor
Found in django/contrib/admin/static/admin/js/actions.js and 1 other location - About 40 mins to fix
django/contrib/admin/static/admin/js/actions.js on lines 10..14

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

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

    function hide(selector) {
        document.querySelectorAll(selector).forEach(function(el) {
            el.classList.add('hidden');
        });
    }
Severity: Minor
Found in django/contrib/admin/static/admin/js/actions.js and 1 other location - About 40 mins to fix
django/contrib/admin/static/admin/js/actions.js on lines 4..8

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

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 (row.is("tr")) {
                // If the forms are laid out in table rows, insert
                // the remove button into the last table cell:
                row.children(":last").append('<div><a class="' + options.deleteCssClass + '" href="#">' + options.deleteText + "</a></div>");
            } else if (row.is("ul") || row.is("ol")) {
Severity: Minor
Found in django/contrib/admin/static/admin/js/inlines.js and 1 other location - About 40 mins to fix
django/contrib/admin/static/admin/js/inlines.js on lines 112..116

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

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

Consider simplifying this complex logical expression.
Open

            if (isinstance(value, bytes) and (b"\n" in value or b"\r" in value)) or (
                isinstance(value, str) and ("\n" in value or "\r" in value)
            ):
                raise BadHeaderError(
                    f"Header values can't contain newlines (got {value!r})"
Severity: Major
Found in django/http/response.py - About 40 mins to fix

    Consider simplifying this complex logical expression.
    Open

            if (
                reference_field_name is None
                or
                # Unspecified to_field(s).
                to_fields is None
    Severity: Major
    Found in django/db/migrations/utils.py - About 40 mins to fix

      Consider simplifying this complex logical expression.
      Open

              if (
                  field.is_relation
                  and opts.ordering
                  and getattr(field, "attname", None) != pieces[-1]
                  and name != "pk"
      Severity: Major
      Found in django/db/models/sql/compiler.py - About 40 mins to fix

        Consider simplifying this complex logical expression.
        Open

                if (
                    old_field.column != new_field.column
                    and self.column_sql(model, old_field) == self.column_sql(model, new_field)
                    and not (
                        old_field.remote_field
        Severity: Major
        Found in django/db/backends/sqlite3/schema.py - About 40 mins to fix

          Consider simplifying this complex logical expression.
          Open

                  if field.many_to_many:
                      # For implicit M2M tables, delete the auto-created table
                      if field.remote_field.through._meta.auto_created:
                          self.delete_model(field.remote_field.through)
                      # For explicit "through" M2M fields, do nothing
          Severity: Major
          Found in django/db/backends/sqlite3/schema.py - About 40 mins to fix

            Consider simplifying this complex logical expression.
            Open

                                if (
                                    (self.allow_files and f.is_file())
                                    or (self.allow_folders and f.is_dir())
                                ) and (self.match is None or self.match_re.search(f.name)):
                                    choices.append((f.path, f.name))
            Severity: Major
            Found in django/forms/fields.py - About 40 mins to fix

              Consider simplifying this complex logical expression.
              Open

                      if (
                          self.connection.features.supports_foreign_keys
                          and new_field.remote_field
                          and (
                              fks_dropped or not old_field.remote_field or not old_field.db_constraint
              Severity: Major
              Found in django/db/backends/base/schema.py - About 40 mins to fix

                Consider simplifying this complex logical expression.
                Open

                        if y is not None and m is not None and d is not None:
                            input_format = get_format("DATE_INPUT_FORMATS")[0]
                            input_format = formats.sanitize_strftime_format(input_format)
                            try:
                                date_value = datetime.date(int(y), int(m), int(d))
                Severity: Major
                Found in django/forms/widgets.py - About 40 mins to fix

                  Consider simplifying this complex logical expression.
                  Open

                              if (
                                  not isinstance(fk, ForeignKey)
                                  or (
                                      # ForeignKey to proxy models.
                                      fk.remote_field.model._meta.proxy
                  Severity: Major
                  Found in django/forms/models.py - About 40 mins to fix

                    Consider simplifying this complex logical expression.
                    Open

                            if all_issues:
                                debugs = [
                                    e for e in all_issues if e.level < checks.INFO and not e.is_silenced()
                                ]
                                infos = [
                    Severity: Major
                    Found in django/core/management/base.py - About 40 mins to fix

                      Consider simplifying this complex logical expression.
                      Open

                                      if isinstance(func, (cached_property, property)):
                                          fields.append(
                                              {
                                                  "name": func_name,
                                                  "data_type": get_return_data_type(func_name),
                      Severity: Major
                      Found in django/contrib/admindocs/views.py - About 40 mins to fix
                        Severity
                        Category
                        Status
                        Source
                        Language