django/django

View on GitHub

Showing 2,094 of 2,094 total issues

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

    def date_extract_sql(self, lookup_type, sql, params):
        extract_sql = f"TO_CHAR({sql}, %s)"
        extract_param = None
        if lookup_type == "week_day":
            # TO_CHAR(field, 'D') returns an integer from 1-7, where 1=Sunday.
Severity: Minor
Found in django/db/backends/oracle/operations.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__(
Severity: Minor
Found in django/forms/fields.py - About 45 mins to fix

    Avoid deeply nested control flow statements.
    Open

                            if self.match is None or self.match_re.search(f):
                                f = os.path.join(root, f)
                                self.choices.append((f, f.replace(path, "", 1)))
                    if self.allow_folders:
    Severity: Major
    Found in django/forms/fields.py - About 45 mins to fix

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

          def _alter_column_type_sql(
      Severity: Minor
      Found in django/db/backends/base/schema.py - About 45 mins to fix

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

            def _alter_column_type_sql(
        Severity: Minor
        Found in django/db/backends/oracle/schema.py - About 45 mins to fix

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

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

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

                def quote_value(self, value):
                    if isinstance(value, (datetime.date, datetime.time, datetime.datetime)):
                        return "'%s'" % value
                    elif isinstance(value, datetime.timedelta):
                        return "'%s'" % duration_iso_string(value)
            Severity: Minor
            Found in django/db/backends/oracle/schema.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 _iter_column_sql has 6 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def _iter_column_sql(
            Severity: Minor
            Found in django/db/backends/base/schema.py - About 45 mins to fix

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

                  def sql_flush(self, style, tables, *, reset_sequences=False, allow_cascade=False):
              Severity: Minor
              Found in django/db/backends/oracle/operations.py - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                                        if f == "__pycache__":
                                            continue
                                        if self.match is None or self.match_re.search(f):
                Severity: Major
                Found in django/forms/fields.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, data):
                          """
                          Check that the file-upload field data contains a valid image (GIF, JPG,
                          PNG, etc. -- whatever Pillow supports).
                          """
                  Severity: Minor
                  Found in django/forms/fields.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 self.match is None or self.match_re.search(f):
                                              f = os.path.join(root, f)
                                              self.choices.append((f, f.replace(path, "", 1)))
                          else:
                  Severity: Major
                  Found in django/forms/fields.py - About 45 mins to fix

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

                        def value_from_datadict(self, data, files, name):
                            y = data.get(self.year_field % name)
                            m = data.get(self.month_field % name)
                            d = data.get(self.day_field % name)
                            if y == m == d == "":
                    Severity: Minor
                    Found in django/forms/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

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

                        def run_validators(self, value):
                            if value in self.empty_values:
                                return
                            errors = []
                            for v in self.validators:
                    Severity: Minor
                    Found in django/forms/fields.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_permissions has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

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

                      Avoid deeply nested control flow statements.
                      Open

                                          if date_range["first"].month == date_range["last"].month:
                                              month_lookup = date_range["first"].month
                      
                      
                      Severity: Major
                      Found in django/contrib/admin/templatetags/admin_list.py - About 45 mins to fix

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

                            def get_results(self, request):
                                paginator = self.model_admin.get_paginator(
                                    request, self.queryset, self.list_per_page
                                )
                                # Get the number of objects, with admin filters applied.
                        Severity: Minor
                        Found in django/contrib/admin/views/main.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 get_paginator has 6 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

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

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

                              def __init__(
                                  self,
                                  data=None,
                                  files=None,
                                  instance=None,
                          Severity: Minor
                          Found in django/forms/models.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 get_containing_app_config has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              def get_containing_app_config(self, object_name):
                                  """
                                  Look for an app config containing a given object.
                          
                                  object_name is the dotted Python path to the object.
                          Severity: Minor
                          Found in django/apps/registry.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