django/django

View on GitHub

Showing 1,782 of 2,090 total issues

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

    def __init__(self, field, request, params, model, model_admin, field_path):
Severity: Minor
Found in django/contrib/admin/filters.py - About 45 mins to fix

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

    def display_for_value(value, empty_value_display, boolean=False):
        from django.contrib.admin.templatetags.admin_list import _boolean_icon
    
        if boolean:
            return _boolean_icon(value)
    Severity: Minor
    Found in django/contrib/admin/utils.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

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

    def create_contenttypes(
    Severity: Minor
    Found in django/contrib/contenttypes/management/__init__.py - About 45 mins to fix

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

          def __init__(
      Severity: Minor
      Found in django/contrib/postgres/forms/array.py - About 45 mins to fix

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

            def __init__(self, field, request, params, model, model_admin, field_path):
        Severity: Minor
        Found in django/contrib/admin/filters.py - About 45 mins to fix

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

          def add_srs_entry(
              srs, auth_name="EPSG", auth_srid=None, ref_sys_name=None, database=None
          ):
              """
              Take a GDAL SpatialReference system and add its information to the
          Severity: Minor
          Found in django/contrib/gis/utils/srs.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

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

              def _store(self, messages, response, remove_oldest=True, *args, **kwargs):
                  """
                  Store the messages to a cookie and return a list of any messages which
                  could not be stored.
          
          
          Severity: Minor
          Found in django/contrib/messages/storage/cookie.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

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

              def log_actions(
          Severity: Minor
          Found in django/contrib/admin/models.py - About 45 mins to fix

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

                def get_formset(self, request, obj=None, **kwargs):
                    if "fields" in kwargs:
                        fields = kwargs.pop("fields")
                    else:
                        fields = flatten_fieldsets(self.get_fieldsets(request, obj))
            Severity: Minor
            Found in django/contrib/contenttypes/admin.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

                                    for obj_type, objs in collector.data.items():
                                        if objs != {ct}:
                                            ct_info.append(
                                                "    - %s %s object(s)"
                                                % (

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

                  def process_messages(self, obj):
                      if isinstance(obj, list) and obj:
                          if obj[0] == MessageEncoder.message_key:
                              if obj[1]:
                                  obj[3] = mark_safe(obj[3])
              Severity: Minor
              Found in django/contrib/messages/storage/cookie.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 isinstance(expr, F) and expr.name in exclude:
                                          return
                          rhs_expression = expression.replace_expressions(replacements)
              Severity: Major
              Found in django/contrib/postgres/constraints.py - About 45 mins to fix

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

                    def to_python(self, value):
                        if not value:
                            return {}
                        if not isinstance(value, dict):
                            try:
                Severity: Minor
                Found in django/contrib/postgres/forms/hstore.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

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

                    def __init__(self, field, request, params, model, model_admin, field_path):
                Severity: Minor
                Found in django/contrib/admin/filters.py - About 45 mins to fix

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

                      def __init__(self, field, request, params, model, model_admin, field_path):
                  Severity: Minor
                  Found in django/contrib/admin/filters.py - About 45 mins to fix

                    Avoid deeply nested control flow statements.
                    Open

                                        if site is not None:
                                            object_domain = site.domain
                                            break
                    
                        # If all that malarkey found an object domain, use it. Otherwise, fall back
                    Severity: Major
                    Found in django/contrib/contenttypes/views.py - About 45 mins to fix

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

                      def display(
                      Severity: Minor
                      Found in django/contrib/admin/decorators.py - About 45 mins to fix

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

                            def choices(self, changelist):
                                add_facets = changelist.add_facets
                                facet_counts = self.get_facet_queryset(changelist) if add_facets else None
                                yield {
                                    "selected": self.value() is None,
                        Severity: Minor
                        Found in django/contrib/admin/filters.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 form.has_changed():
                                                    obj = self.save_form(request, form, change=True)
                                                    self.save_model(request, obj, form, change=True)
                                                    self.save_related(request, form, formsets=[], change=True)
                                                    change_msg = self.construct_change_message(
                        Severity: Major
                        Found in django/contrib/admin/options.py - About 45 mins to fix

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

                              def get_context(self, name, value, attrs):
                                  context = super().get_context(name, value, attrs)
                                  rel_to = self.rel.model
                                  if self.admin_site.is_registered(rel_to):
                                      # The related object is registered with the same AdminSite
                          Severity: Minor
                          Found in django/contrib/admin/widgets.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

                          Severity
                          Category
                          Status
                          Source
                          Language