django/django

View on GitHub

Showing 2,116 of 2,116 total issues

File qunit.js has 3181 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*!
 * QUnit 2.0.1
 * https://qunitjs.com/
 *
 * Copyright jQuery Foundation and other contributors
Severity: Major
Found in js_tests/qunit/qunit.js - About 1 wk to fix

    File __init__.py has 1889 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 options.py has 1746 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import copy
      import json
      import operator
      import re
      from collections import OrderedDict
      Severity: Major
      Found in django/contrib/admin/options.py - About 4 days to fix

        File query.py has 1701 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 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 query.py has 1478 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 3 days to fix

            Function diff has 732 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            QUnit.diff = ( function() {
                function DiffMatchPatch() {
                }
            
                //  DIFF FUNCTIONS
            Severity: Major
            Found in js_tests/qunit/qunit.js - About 3 days to fix

              File base.py has 1385 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 3 days to fix

                File related.py has 1339 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 1210 lines of code (exceeds 250 allowed). Consider refactoring.
                  Open

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

                    File autodetector.py has 1132 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 1114 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 1042 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 1023 lines of code (exceeds 250 allowed). Consider refactoring.
                          Open

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

                            Function __new__ has a Cognitive Complexity of 123 (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 checks.py has 961 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import warnings
                            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 936 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

                                Function create_forward_many_to_many_manager has a Cognitive Complexity of 104 (exceeds 5 allowed). Consider refactoring.
                                Open

                                def create_forward_many_to_many_manager(superclass, rel, reverse):
                                    """
                                    Create a manager for the either side of a many-to-many relation.
                                
                                    This manager subclasses another manager, generally the default manager of
                                Severity: Minor
                                Found in django/db/models/fields/related_descriptors.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 related_descriptors.py has 859 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

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

                                  class SHA1PasswordHasher(BasePasswordHasher):
                                      """
                                      The SHA1 password hashing algorithm (not recommended)
                                      """
                                      algorithm = "sha1"
                                  Severity: Major
                                  Found in django/contrib/auth/hashers.py and 1 other location - About 2 days to fix
                                  django/contrib/auth/hashers.py on lines 499..526

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

                                  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