django/django

View on GitHub

Showing 1,663 of 2,133 total issues

File __init__.py has 1987 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import collections.abc
import copy
import datetime
import decimal
import operator
Severity: Major
Found in django/db/models/fields/__init__.py - About 5 days to fix

    File query.py has 1836 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    Create SQL statements for QuerySets.
    
    The code in here encapsulates all of the SQL construction so that QuerySets
    themselves do not have to (and could be backed by things other than SQL
    Severity: Major
    Found in django/db/models/sql/query.py - About 5 days to fix

      File options.py has 1787 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import copy
      import json
      import operator
      import re
      from functools import partial, reduce, update_wrapper
      Severity: Major
      Found in django/contrib/admin/options.py - About 4 days to fix

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

        import copy
        import inspect
        import warnings
        from functools import partialmethod
        from itertools import chain
        Severity: Major
        Found in django/db/models/base.py - About 4 days to fix

          File query.py has 1569 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """
          The main QuerySet implementation. This provides the public API for the ORM.
          """
          
          import copy
          Severity: Major
          Found in django/db/models/query.py - About 4 days to fix

            Function templatize has a Cognitive Complexity of 194 (exceeds 5 allowed). Consider refactoring.
            Open

            def templatize(src, origin=None):
                """
                Turn a Django template into something that is understood by xgettext. It
                does so by translating the Django translation tags into standard gettext
                function invocations.
            Severity: Minor
            Found in django/utils/translation/template.py - About 3 days 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

            File related.py has 1385 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            import functools
            import inspect
            from functools import partial
            
            from django import forms
            Severity: Major
            Found in django/db/models/fields/related.py - About 3 days to fix

              File compiler.py has 1300 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              import collections
              import re
              from functools import partial
              from itertools import chain
              
              
              Severity: Major
              Found in django/db/models/sql/compiler.py - About 3 days to fix

                File autodetector.py has 1139 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

                  File defaulttags.py has 1126 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

                  """Default tags used by the template system, available to all templates."""
                  import re
                  import sys
                  import warnings
                  from collections import namedtuple
                  Severity: Major
                  Found in django/template/defaulttags.py - About 2 days to fix

                    File expressions.py has 1061 lines of code (exceeds 250 allowed). Consider refactoring.
                    Open

                    import copy
                    import datetime
                    import inspect
                    from decimal import Decimal
                    
                    
                    Severity: Major
                    Found in django/db/models/expressions.py - About 2 days to fix

                      File models.py has 1061 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      """
                      Helper functions for creating Form classes from Django models
                      and database field objects.
                      """
                      import warnings
                      Severity: Major
                      Found in django/forms/models.py - About 2 days to fix

                        Function __new__ has a Cognitive Complexity of 127 (exceeds 5 allowed). Consider refactoring.
                        Open

                            def __new__(cls, name, bases, attrs, **kwargs):
                                super_new = super().__new__
                        
                                # Also ensure initialization is only performed for subclasses of Model
                                # (excluding Model class itself).
                        Severity: Minor
                        Found in django/db/models/base.py - About 2 days 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

                        File schema.py has 1015 lines of code (exceeds 250 allowed). Consider refactoring.
                        Open

                        import logging
                        from datetime import datetime
                        
                        from django.db.backends.ddl_references import (
                            Columns, ForeignKeyName, IndexName, Statement, Table,
                        Severity: Major
                        Found in django/db/backends/base/schema.py - About 2 days to fix

                          File checks.py has 1001 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

                          import collections
                          from itertools import chain
                          
                          from django.apps import apps
                          from django.conf import settings
                          Severity: Major
                          Found in django/contrib/admin/checks.py - About 2 days to fix

                            File fields.py has 998 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            """
                            Field classes.
                            """
                            
                            import copy
                            Severity: Major
                            Found in django/forms/fields.py - About 2 days to fix

                              File related_descriptors.py has 887 lines of code (exceeds 250 allowed). Consider refactoring.
                              Open

                              """
                              Accessors for related objects.
                              
                              When a field defines a relation between two models, each model class provides
                              an attribute to access related instances of the other model class (unless the
                              Severity: Major
                              Found in django/db/models/fields/related_descriptors.py - About 2 days to fix

                                File widgets.py has 859 lines of code (exceeds 250 allowed). Consider refactoring.
                                Open

                                """
                                HTML Widget classes
                                """
                                
                                import copy
                                Severity: Major
                                Found in django/forms/widgets.py - About 2 days to fix

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

                                  """
                                  This is the Django template system.
                                  
                                  How it works:
                                  
                                  
                                  Severity: Major
                                  Found in django/template/base.py - About 2 days to fix

                                    Function handle has a Cognitive Complexity of 90 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                        def handle(self, *app_labels, **options):
                                            format = options['format']
                                            indent = options['indent']
                                            using = options['database']
                                            excludes = options['exclude']
                                    Severity: Minor
                                    Found in django/core/management/commands/dumpdata.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

                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language