edgewall/trac

View on GitHub
trac/resource.py

Summary

Maintainability
C
1 day
Test Coverage

File resource.py has 339 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# Copyright (C) 2006-2023 Edgewall Software
# Copyright (C) 2006-2007 Alec Thomas <alec@swapoff.org>
# Copyright (C) 2007 Christian Boos <cboos@edgewall.org>
Severity: Minor
Found in trac/resource.py - About 4 hrs to fix

    Function __new__ has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
    Open

        def __new__(cls, resource_or_realm=None, id=False, version=False,
                    parent=False):
            """Create a new Resource object from a specification.
    
            :param resource_or_realm: this can be either:
    Severity: Minor
    Found in trac/resource.py - About 2 hrs 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_relative_resource has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
    Open

    def get_relative_resource(resource, path=''):
        """Build a Resource relative to a reference resource.
    
        :param path: path leading to another resource within the same realm.
        """
    Severity: Minor
    Found in trac/resource.py - About 2 hrs 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_relative_url has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

    def get_relative_url(env, resource, href, path='', **kwargs):
    Severity: Minor
    Found in trac/resource.py - About 35 mins to fix

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

          def get_resource_manager(self, realm):
              """Return the component responsible for resources in the given `realm`
      
              :param realm: the realm name
              :return: a `Component` implementing `IResourceManager` or `None`
      Severity: Minor
      Found in trac/resource.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 __repr__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

          def __repr__(self):
              path = []
              r = self
              while r:
                  name = r.realm
      Severity: Minor
      Found in trac/resource.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