django/django

View on GitHub
django/contrib/auth/hashers.py

Summary

Maintainability
C
1 day
Test Coverage

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

    Function encode has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def encode(self, password, salt, n=None, r=None, p=None):
    Severity: Minor
    Found in django/contrib/auth/hashers.py - About 35 mins to fix

      Function _load_library has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def _load_library(self):
              if self.library is not None:
                  if isinstance(self.library, (tuple, list)):
                      name, mod_path = self.library
                  else:
      Severity: Minor
      Found in django/contrib/auth/hashers.py - About 25 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 identify_hasher has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      def identify_hasher(encoded):
          """
          Return an instance of a loaded password hasher.
      
          Identify hasher algorithm by examining encoded hash, and call
      Severity: Minor
      Found in django/contrib/auth/hashers.py - About 25 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

      There are no issues that match your filters.

      Category
      Status