edgewall/trac

View on GitHub
trac/config.py

Summary

Maintainability
F
5 days
Test Coverage

File config.py has 802 lines of code (exceeds 250 allowed). Consider refactoring.
Open

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

    Function save has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
    Open

        def save(self):
            """Write the configuration options to the primary file."""
    
            all_options = {}
            for (section, name), option in Option.get_registry().items():
    Severity: Minor
    Found in trac/config.py - About 3 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 set_defaults has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_defaults(self, compmgr=None, component=None):
            """Retrieve all default values and store them explicitly in the
            configuration, so that they can be saved to file.
    
            Values already set in the configuration are not overwritten.
    Severity: Minor
    Found in trac/config.py - About 3 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

    Configuration has 24 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Configuration(object):
        """Thin layer over `ConfigParser` from the Python standard library.
    
        In addition to providing some convenience methods, the class remembers
        the last modification time of the configuration file, and reparses it
    Severity: Minor
    Found in trac/config.py - About 2 hrs to fix

      Function get has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def get(self, key, default=''):
              """Return the value of the specified option.
      
              Valid default input is a string. Returns a string.
              """
      Severity: Minor
      Found in trac/config.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 iterate has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
      Open

          def iterate(self, compmgr=None, defaults=True):
              """Iterate over the options in this section.
      
              If `compmgr` is specified, only return default option values for
              components that are enabled in the given `ComponentManager`.
      Severity: Minor
      Found in trac/config.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 parse_if_needed has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

          def parse_if_needed(self, force=False):
              if not self.filename or not self.exists:
                  return False
      
              changed = False
      Severity: Minor
      Found in trac/config.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 __get__ has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def __get__(self, instance, owner):
              if instance is None:
                  return self
              order = ListOption.__get__(self, instance, owner)
              components = []
      Severity: Minor
      Found in trac/config.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 8 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def __init__(self, section, name, default=None, sep=',', keep_empty=False,
      Severity: Major
      Found in trac/config.py - About 1 hr to fix

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

            def __init__(self, section, name, interface, default=None,
        Severity: Major
        Found in trac/config.py - About 1 hr to fix

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

              def __init__(self, section, name, choices, doc='', doc_domain='tracini',
          Severity: Major
          Found in trac/config.py - About 50 mins to fix

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

                def __init__(self, section, name, interface, default=None, doc='',
            Severity: Major
            Found in trac/config.py - About 50 mins to fix

              Function get_configinfo has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

              def get_configinfo(env):
                  """Returns a list of dictionaries containing the `name` and `options`
                  of each configuration section. The value of `options` is a list of
                  dictionaries containing the `name`, `value` and `modified` state of
                  each configuration option. The `modified` value is True if the value
              Severity: Minor
              Found in trac/config.py - About 45 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

              Avoid deeply nested control flow statements.
              Open

                                      if isinstance(option, Option):
                                          set_option_default(option)
                      else:
              Severity: Major
              Found in trac/config.py - About 45 mins to fix

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

                    def __init__(self, section, name, default=None, doc='',
                Severity: Minor
                Found in trac/config.py - About 45 mins to fix

                  Function _get_registry has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  def _get_registry(cls, compmgr=None):
                      """Return the descriptor registry.
                  
                      If `compmgr` is specified, only return descriptors for components that
                      are enabled in the given `ComponentManager`.
                  Severity: Minor
                  Found in trac/config.py - About 45 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 getlist has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def getlist(self, section, key, default='', sep=',', keep_empty=False):
                  Severity: Minor
                  Found in trac/config.py - About 35 mins to fix

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

                        def get(self, section, option, raw=False, vars=None,
                    Severity: Minor
                    Found in trac/config.py - About 35 mins to fix

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

                      def _getlist(value, sep, keep_empty):
                          if not value:
                              return []
                          if isinstance(value, str):
                              if isinstance(sep, (list, tuple)):
                      Severity: Minor
                      Found in trac/config.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

                      Avoid too many return statements within this function.
                      Open

                              return to_unicode(value)
                      Severity: Major
                      Found in trac/config.py - About 30 mins to fix

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

                            def _get_parents(self):
                                _parents = []
                                if self.parser.has_option('inherit', 'file'):
                                    for filename in self.parser.get('inherit', 'file').split(','):
                                        filename = filename.strip()
                        Severity: Minor
                        Found in trac/config.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