motom001/DoorPi

View on GitHub
doorpi/conf/config_object.py

Summary

Maintainability
D
3 days
Test Coverage

ConfigObject has 21 functions (exceeds 20 allowed). Consider refactoring.
Open

class ConfigObject():

    __sections = {}
    _config_file = None

Severity: Minor
Found in doorpi/conf/config_object.py - About 2 hrs to fix

    Function get_string has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_string(self, section, key, default = '', log = True, password = False, store_if_not_exists = True):
            value = None
            try:
                old_section, old_key = BACKWARD_COMPATIBILITY_KEYS[section][key]
                value = self.__sections[old_section][old_key]
    Severity: Minor
    Found in doorpi/conf/config_object.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 set_value has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def set_value(self, section, key, value, log = True, password = False):
            if section not in self.__sections.keys():
                self.__sections[section] = {}
    
            password_friendly_value = "*******" if key is 'password' or password else value
    Severity: Minor
    Found in doorpi/conf/config_object.py - About 55 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 get_string has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def get_string(self, section, key, default = '', log = True, password = False, store_if_not_exists = True):
    Severity: Minor
    Found in doorpi/conf/config_object.py - About 45 mins to fix

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

          def get_keys(self, section, filter = '', log = True):
              return_list = []
              if section not in self.__sections:
                  logging.warning("section %s not found in configfile", section)
              else:
      Severity: Minor
      Found in doorpi/conf/config_object.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 save_config has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def save_config(self, configfile = ''):
              if not configfile: configfile = self.config_file
              if not configfile: configfile = self.find_config(configfile)
              if not configfile: configfile = doorpi.DoorPi().parse_string(os.path.join('!BASEPATH!', 'conf', 'doorpi.ini'))
      
      
      Severity: Minor
      Found in doorpi/conf/config_object.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 get_list has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def get_list(self, section, key, default = [], separator = ',', log = True, store_if_not_exists = True):
      Severity: Minor
      Found in doorpi/conf/config_object.py - About 45 mins to fix

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

            def rename_key(self, section, old_key, new_key, default = '', log = True):
        Severity: Minor
        Found in doorpi/conf/config_object.py - About 35 mins to fix

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

              def get_integer(self, section, key, default = -1, log = True, store_if_not_exists = True):
          Severity: Minor
          Found in doorpi/conf/config_object.py - About 35 mins to fix

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

                def get_boolean(self, section, key, default = False, log = True, store_if_not_exists = True):
            Severity: Minor
            Found in doorpi/conf/config_object.py - About 35 mins to fix

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

                  def get_float(self, section, key, default = -1, log = True, store_if_not_exists = True):
              Severity: Minor
              Found in doorpi/conf/config_object.py - About 35 mins to fix

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

                    def set_value(self, section, key, value, log = True, password = False):
                Severity: Minor
                Found in doorpi/conf/config_object.py - About 35 mins to fix

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

                      def get_from_config(self, config, log = True):
                          if log: logger.trace("get_from_config")
                          for section in config.sections():
                              self.__sections[section] = {}
                              for key, value in config.items(section):
                  Severity: Minor
                  Found in doorpi/conf/config_object.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 delete_section has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def delete_section(self, section, delete_empty_only = True, log = True):
                          if section in self.__sections and len(self.__sections[section]) > 0 and delete_empty_only:
                              logger.warning("could not delete section %s, because it's not empty.", section)
                              return False
                  
                  
                  Severity: Minor
                  Found in doorpi/conf/config_object.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

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      def get_float(self, section, key, default = -1, log = True, store_if_not_exists = True):
                          value = self.get_string(section, key, str(default), log = False, store_if_not_exists = store_if_not_exists)
                          if value is not '': value = float(value)
                          else: value = default
                          if log: logger.trace("get_integer for key %s in section %s (default: %s) returns %s", key, section, default, value)
                  Severity: Major
                  Found in doorpi/conf/config_object.py and 1 other location - About 4 hrs to fix
                  doorpi/conf/config_object.py on lines 194..199

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 84.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                      def get_integer(self, section, key, default = -1, log = True, store_if_not_exists = True):
                          value = self.get(section, key, str(default), log = False, store_if_not_exists = store_if_not_exists)
                          if value is not '': value = int(value)
                          else: value = default
                          if log: logger.trace("get_integer for key %s in section %s (default: %s) returns %s", key, section, default, value)
                  Severity: Major
                  Found in doorpi/conf/config_object.py and 1 other location - About 4 hrs to fix
                  doorpi/conf/config_object.py on lines 187..192

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 84.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  Similar blocks of code found in 2 locations. Consider refactoring.
                  Open

                              if not os.path.exists(os.path.dirname(configfile)):
                                  logger.info('Path %s does not exist - creating it now', os.path.dirname(configfile))
                                  os.makedirs(os.path.dirname(configfile))
                  Severity: Major
                  Found in doorpi/conf/config_object.py and 1 other location - About 2 hrs to fix
                  doorpi/action/handler.py on lines 45..47

                  Duplicated Code

                  Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                  Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                  When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                  Tuning

                  This issue has a mass of 59.

                  We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                  The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                  If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                  See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                  Refactorings

                  Further Reading

                  There are no issues that match your filters.

                  Category
                  Status