edgewall/trac

View on GitHub
trac/db/api.py

Summary

Maintainability
D
2 days
Test Coverage

File api.py has 586 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# -*- coding: utf-8 -*-
#
# Copyright (C) 2005-2023 Edgewall Software
# Copyright (C) 2005 Christopher Lenz <cmlenz@gmx.de>
# All rights reserved.
Severity: Major
Found in trac/db/api.py - About 1 day to fix

    Function parse_connection_uri has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
    Open

    def parse_connection_uri(db_str):
        """Parse the database connection string.
    
        The database connection string for an environment is specified through
        the `database` option in the `[trac]` section of trac.ini.
    Severity: Minor
    Found in trac/db/api.py - About 5 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

    DatabaseManager has 28 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class DatabaseManager(Component):
        """Component used to manage the `IDatabaseConnector` implementations."""
    
        implements(IEnvironmentSetupParticipant, ISystemInfoProvider)
    
    
    Severity: Minor
    Found in trac/db/api.py - About 3 hrs to fix

      Function upgrade_tables has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

          def upgrade_tables(self, new_schema):
              """Upgrade table schema to `new_schema`, preserving data in
              columns that exist in the current schema and `new_schema`.
      
              :param new_schema: tuple or list of `Table` objects
      Severity: Minor
      Found in trac/db/api.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

      Avoid deeply nested control flow statements.
      Open

                              if col.auto_increment:
                                  db.update_sequence(cursor, new_table.name,
                                                     col.name)
                          self.drop_tables((temp_table_name,))
      Severity: Major
      Found in trac/db/api.py - About 45 mins to fix

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

            def get_connector(self):
                scheme, args = parse_connection_uri(self.connection_uri)
                candidates = [
                    (priority, connector)
                    for connector in self.connectors
        Severity: Minor
        Found in trac/db/api.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 __exit__ has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            def __exit__(self, et, ev, tb):
                if self.db:
                    self.dbmgr._transaction_local.wdb = None
                    if et is None:
                        self.db.commit()
        Severity: Minor
        Found in trac/db/api.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