django/django

View on GitHub

Showing 599 of 2,094 total issues

File lookups.py has 599 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import itertools
import math
import warnings

from django.core.exceptions import EmptyResultSet, FullResultSet
Severity: Major
Found in django/db/models/lookups.py - About 1 day to fix

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

    def mail_managers(
        subject, message, fail_silently=False, connection=None, html_message=None
    ):
        """Send a message to the managers, as defined by the MANAGERS setting."""
        if not settings.MANAGERS:
    Severity: Major
    Found in django/core/mail/__init__.py and 1 other location - About 1 day to fix
    django/core/mail/__init__.py on lines 118..135

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

    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 mail_admins(
        subject, message, fail_silently=False, connection=None, html_message=None
    ):
        """Send a message to the admins, as defined by the ADMINS setting."""
        if not settings.ADMINS:
    Severity: Major
    Found in django/core/mail/__init__.py and 1 other location - About 1 day to fix
    django/core/mail/__init__.py on lines 138..155

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

    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

    File base.py has 589 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    Base classes for writing management commands (named commands which can
    be executed through ``django-admin`` or ``manage.py``).
    """
    
    
    Severity: Major
    Found in django/core/management/base.py - About 1 day to fix

      File request.py has 579 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import codecs
      import copy
      from io import BytesIO
      from itertools import chain
      from urllib.parse import parse_qsl, quote, urlencode, urljoin, urlsplit
      Severity: Major
      Found in django/http/request.py - About 1 day to fix

        OGRGeometry has 65 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class OGRGeometry(GDALBase):
            """Encapsulate an OGR geometry."""
        
            destructor = capi.destroy_geom
        
        
        Severity: Major
        Found in django/contrib/gis/gdal/geometries.py - About 1 day to fix

          File response.py has 554 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import datetime
          import io
          import json
          import mimetypes
          import os
          Severity: Major
          Found in django/http/response.py - About 1 day to fix

            File debug.py has 548 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import functools
            import inspect
            import itertools
            import re
            import sys
            Severity: Major
            Found in django/views/debug.py - About 1 day to fix

              File hashers.py has 545 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import base64
              import binascii
              import functools
              import hashlib
              import importlib
              Severity: Major
              Found in django/contrib/auth/hashers.py - About 1 day to fix

                File multipartparser.py has 544 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                """
                Multi-part parsing for file uploads.
                
                Exposes one class, ``MultiPartParser``, which feeds chunks of uploaded data to
                file upload handlers for processing.
                Severity: Major
                Found in django/http/multipartparser.py - About 1 day to fix

                  File layermapping.py has 539 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  # LayerMapping -- A Django Model/OGR Layer Mapping Utility
                  """
                   The LayerMapping class provides a way to map the contents of OGR
                   vector files (e.g. SHP files) to Geographic-enabled Django models.
                  
                  
                  Severity: Major
                  Found in django/contrib/gis/utils/layermapping.py - About 1 day to fix

                    File validators.py has 524 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import ipaddress
                    import math
                    import re
                    from pathlib import Path
                    from urllib.parse import urlsplit, urlunsplit
                    Severity: Major
                    Found in django/core/validators.py - About 1 day to fix

                      File autoreload.py has 522 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import itertools
                      import logging
                      import os
                      import signal
                      import subprocess
                      Severity: Major
                      Found in django/utils/autoreload.py - About 1 day to fix

                        File main.py has 518 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import warnings
                        from datetime import datetime, timedelta
                        
                        from django import forms
                        from django.conf import settings
                        Severity: Major
                        Found in django/contrib/admin/views/main.py - About 1 day to fix

                          File utils.py has 505 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import datetime
                          import decimal
                          import json
                          from collections import defaultdict
                          from functools import reduce
                          Severity: Major
                          Found in django/contrib/admin/utils.py - About 1 day to fix

                            File json.py has 501 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import json
                            
                            from django import forms
                            from django.core import checks, exceptions
                            from django.db import NotSupportedError, connections, router
                            Severity: Major
                            Found in django/db/models/fields/json.py - About 1 day to fix

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

                                  for index_name, model_labels in indexes.items():
                                      if len(model_labels) > 1:
                                          model_labels = set(model_labels)
                                          errors.append(
                                              Error(
                              Severity: Major
                              Found in django/core/checks/model_checks.py and 1 other location - About 6 hrs to fix
                              django/core/checks/model_checks.py on lines 76..87

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

                              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

                                  for constraint_name, model_labels in constraints.items():
                                      if len(model_labels) > 1:
                                          model_labels = set(model_labels)
                                          errors.append(
                                              Error(
                              Severity: Major
                              Found in django/core/checks/model_checks.py and 1 other location - About 6 hrs to fix
                              django/core/checks/model_checks.py on lines 62..73

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

                              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 len(args) > 1:
                                                          self.feed("%s: %s" % (key_string, args[0]))
                                                          for arg in args[1:-1]:
                                                              self.feed(arg)
                                                          self.feed("%s," % args[-1])
                              Severity: Major
                              Found in django/db/migrations/writer.py and 1 other location - About 6 hrs to fix
                              django/db/migrations/writer.py on lines 65..71

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

                              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 len(args) > 1:
                                                  self.feed("%s=%s" % (_arg_name, args[0]))
                                                  for arg in args[1:-1]:
                                                      self.feed(arg)
                                                  self.feed("%s," % args[-1])
                              Severity: Major
                              Found in django/db/migrations/writer.py and 1 other location - About 6 hrs to fix
                              django/db/migrations/writer.py on lines 36..42

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

                              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