kotti/resources.py

Summary

Maintainability
D
2 days
Test Coverage

File resources.py has 695 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
The :mod:`~kotti.resources` module contains all the classes for Kotti's
persistence layer, which is based on SQLAlchemy.

Inheritance Diagram
Severity: Major
Found in kotti/resources.py - About 1 day to fix

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

        def __init__(
    Severity: Major
    Found in kotti/resources.py - About 1 hr to fix

      Function __getitem__ has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          def __getitem__(self, path: Union[str, Iterable[str]]) -> "Node":
              db_session = DBSession()
              db_session._autoflush()
      
              # if not hasattr(path, '__iter__'):
      Severity: Minor
      Found in kotti/resources.py - About 1 hr 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 kotti/resources.py - About 45 mins to fix

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

            def __init__(
        Severity: Minor
        Found in kotti/resources.py - About 35 mins to fix

          Function initialize_sql has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

          def initialize_sql(engine: Engine, drop_all: bool = False) -> scoped_session:
              DBSession.registry.clear()
              DBSession.configure(bind=engine)
              metadata.bind = engine
          
          
          Severity: Minor
          Found in kotti/resources.py - About 35 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 copy has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def copy(self, **kwargs) -> "Node":
                  """
                  :result: A copy of the current instance
                  :rtype: :class:`~kotti.resources.Node`
                  """
          Severity: Minor
          Found in kotti/resources.py - About 35 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 a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              def __init__(self, **kwargs) -> None:
                  if "action_links" in kwargs:
                      msg = (
                          "'action_links' is deprecated as of Kotti 1.0.0.  "
                          "'edit_links' includes 'action_links' and should "
          Severity: Minor
          Found in kotti/resources.py - About 35 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