edgewall/trac

View on GitHub
trac/env.py

Summary

Maintainability
F
4 days
Test Coverage

File env.py has 949 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# Copyright (C) 2003-2023 Edgewall Software
# Copyright (C) 2003-2007 Jonas Borgström <jonas@edgewall.com>
# All rights reserved.
Severity: Major
Found in trac/env.py - About 2 days to fix

    Environment has 44 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Environment(Component, ComponentManager):
        """Trac environment manager.
    
        Trac stores project information in a Trac environment. It consists
        of a directory structure containing among other things:
    Severity: Minor
    Found in trac/env.py - About 6 hrs to fix

      Function _do_deploy has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

          def _do_deploy(self, dest):
              target = os.path.normpath(dest)
              chrome_target = os.path.join(target, 'htdocs')
              script_target = os.path.join(target, 'cgi-bin')
              chrome = Chrome(self.env)
      Severity: Minor
      Found in trac/env.py - About 4 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 open_environment has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
      Open

      def open_environment(env_path=None, use_cache=False):
          """Open an existing environment object, and verify that the database is up
          to date.
      
          :param env_path: absolute path to the environment directory; if
      Severity: Minor
      Found in trac/env.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 _do_hotcopy has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def _do_hotcopy(self, dest, no_db=None):
              if no_db not in (None, '--no-database'):
                  raise AdminCommandError(_("Invalid argument '%(arg)s'", arg=no_db),
                                          show_usage=True)
      
      
      Severity: Minor
      Found in trac/env.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 upgrade has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def upgrade(self, backup=False, backup_dest=None):
              """Upgrade database.
      
              :param backup: whether or not to backup before upgrading
              :param backup_dest: name of the backup file
      Severity: Minor
      Found in trac/env.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 _copy_tables has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def _copy_tables(self, dst_env, src_db, dst_db, src_dburi, dst_dburi):
      Severity: Minor
      Found in trac/env.py - About 45 mins to fix

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

            def is_component_enabled(self, cls):
                """Implemented to only allow activation of components that are
                not disabled in the configuration.
        
                This is called by the `ComponentManager` base class when a
        Severity: Minor
        Found in trac/env.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 create has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def create(self, options=[], default_data=True):
                """Create the basic directory structure of the environment,
                initialize the database and populate the configuration file
                with default values.
        
        
        Severity: Minor
        Found in trac/env.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 component_guard has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def component_guard(self, component, reraise=False):
                """Traps any runtime exception raised when working with a component
                and logs the error.
        
                :param component: the component responsible for any error that
        Severity: Minor
        Found in trac/env.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