motom001/DoorPi

View on GitHub

Showing 4,610 of 4,610 total issues

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

    def status_input(self, input_pin):
        logger.debug("status_input for tag %s", tag)
        if input_pin == self.last_key:
            return True
        else:
Severity: Major
Found in doorpi/keyboard/from_usb_plain.py and 2 other locations - About 50 mins to fix
doorpi/keyboard/from_pn532.py on lines 167..172
doorpi/keyboard/from_rdm6300.py on lines 192..197

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 36.

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 3 locations. Consider refactoring.
Open

    def status_input(self, tag):
        logger.debug("status_input for tag %s", tag)
        if tag == self.last_key:
            return True
        else:
Severity: Major
Found in doorpi/keyboard/from_pn532.py and 2 other locations - About 50 mins to fix
doorpi/keyboard/from_rdm6300.py on lines 192..197
doorpi/keyboard/from_usb_plain.py on lines 110..115

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 36.

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

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

    def unregister_source(self, event_source, force_unregister = False):
        try:
            logger.trace("unregister Eventsource %s and force_unregister is %s", event_source, force_unregister)
            if event_source not in self.__Sources: return "event_source %s unknown" % (event_source)
            for event_name in self.__Events.keys():
Severity: Minor
Found in doorpi/action/handler.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 self_check has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def self_check(self, *args, **kwargs):
        if not self.core: return

        self.core.iterate()

Severity: Minor
Found in doorpi/sipphone/from_linphone.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_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

    Avoid deeply nested control flow statements.
    Open

                            if value_requested in input_pin:
                                status['input'][input_pin] = keyboard.status_input(input_pin)
    
    
    Severity: Major
    Found in doorpi/status/status_lib/keyboard.py - About 45 mins to fix

      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 collect_status has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def collect_status(self, DoorPiObject, modules = MODULES, value = list(), name = list()):
                if len(modules) == 0: modules = MODULES
        
                for module in modules:
                    if module not in MODULES:
        Severity: Minor
        Found in doorpi/status/status_class.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 __init__ has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def __init__(self, input_pins, keyboard_name, conf_pre, conf_post, *args, **kwargs):
        Severity: Minor
        Found in doorpi/keyboard/from_rdm6300.py - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

                                      if now - self.last_key_time > self.__dismisstime:
                                          doorpi.DoorPi().event_handler('OnFoundTag', __name__)
                                          self.last_key = int(chars[5:-3], 16)
                                          self.last_key_time = now
                                          logger.debug("key is %s", self.last_key)
          Severity: Major
          Found in doorpi/keyboard/from_rdm6300.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

            Avoid deeply nested control flow statements.
            Open

                                    if value_requested not in output_pin:
                                        del status['output'][output_pin]
                    return status
            Severity: Major
            Found in doorpi/status/status_lib/keyboard.py - About 45 mins to fix

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

                  libraries = dict(
                      importlib = dict(
                          text_warning =          '',
                          text_description =      'Das Python-Modul importlib wird zum dynamischen Laden von Dateien genutzt. So sind z.B. alle Actions jeweils als eigene Datei abgelegt die anhand des Dateinamens (= Name der Action) geladen werden, wenn diese auch wirklich benötigt werden. So muss am restlichen Quellcode keine Anpassung gemacht werden und es reicht eine neue Aktion bereit zu stellen.',
                          text_installation =     'Eine Installation ist nicht nötig, da es sich hierbei um eine Python-Standard-Modul handelt.',
              Severity: Major
              Found in doorpi/status/requirements_lib/req_system.py and 22 other locations - About 40 mins to fix
              doorpi/status/requirements_lib/req_config.py on lines 19..43
              doorpi/status/requirements_lib/req_event_handler.py on lines 24..33
              doorpi/status/requirements_lib/req_event_handler.py on lines 24..45
              doorpi/status/requirements_lib/req_system.py on lines 16..41
              doorpi/status/requirements_lib/req_system.py on lines 16..61
              doorpi/status/requirements_lib/req_system.py on lines 16..75
              doorpi/status/requirements_lib/req_system.py on lines 16..89
              doorpi/status/requirements_lib/req_system.py on lines 16..103
              doorpi/status/requirements_lib/req_system.py on lines 16..117
              doorpi/status/requirements_lib/req_system.py on lines 16..131
              doorpi/status/requirements_lib/req_system.py on lines 16..145
              doorpi/status/requirements_lib/req_system.py on lines 16..159
              doorpi/status/requirements_lib/req_system.py on lines 16..173
              doorpi/status/requirements_lib/req_system.py on lines 16..187
              doorpi/status/requirements_lib/req_system.py on lines 16..201
              doorpi/status/requirements_lib/req_system.py on lines 16..215
              doorpi/status/requirements_lib/req_system.py on lines 16..229
              doorpi/status/requirements_lib/req_system.py on lines 16..243
              doorpi/status/requirements_lib/req_webserver.py on lines 99..110
              doorpi/status/requirements_lib/req_webserver.py on lines 99..124
              doorpi/status/requirements_lib/req_webserver.py on lines 99..138
              doorpi/status/requirements_lib/req_webserver.py on lines 99..152

              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 34.

              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 23 locations. Consider refactoring.
              Open

                  libraries = dict(
                      BaseHTTPServer = dict(
                          text_warning =          '',
                          text_description =      'Das Python-Modul BaseHTTPServer ist mit der Klasse HTTPServer die Grundlage für jeden Webserver.',
                          text_installation =     'Eine Installation ist nicht nötig, da es sich hierbei um eine Python-Standard-Modul handelt.',
              Severity: Major
              Found in doorpi/status/requirements_lib/req_webserver.py and 22 other locations - About 40 mins to fix
              doorpi/status/requirements_lib/req_config.py on lines 19..43
              doorpi/status/requirements_lib/req_event_handler.py on lines 24..33
              doorpi/status/requirements_lib/req_event_handler.py on lines 24..45
              doorpi/status/requirements_lib/req_system.py on lines 16..27
              doorpi/status/requirements_lib/req_system.py on lines 16..41
              doorpi/status/requirements_lib/req_system.py on lines 16..61
              doorpi/status/requirements_lib/req_system.py on lines 16..75
              doorpi/status/requirements_lib/req_system.py on lines 16..89
              doorpi/status/requirements_lib/req_system.py on lines 16..103
              doorpi/status/requirements_lib/req_system.py on lines 16..117
              doorpi/status/requirements_lib/req_system.py on lines 16..131
              doorpi/status/requirements_lib/req_system.py on lines 16..145
              doorpi/status/requirements_lib/req_system.py on lines 16..159
              doorpi/status/requirements_lib/req_system.py on lines 16..173
              doorpi/status/requirements_lib/req_system.py on lines 16..187
              doorpi/status/requirements_lib/req_system.py on lines 16..201
              doorpi/status/requirements_lib/req_system.py on lines 16..215
              doorpi/status/requirements_lib/req_system.py on lines 16..229
              doorpi/status/requirements_lib/req_system.py on lines 16..243
              doorpi/status/requirements_lib/req_webserver.py on lines 99..124
              doorpi/status/requirements_lib/req_webserver.py on lines 99..138
              doorpi/status/requirements_lib/req_webserver.py on lines 99..152

              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 34.

              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 23 locations. Consider refactoring.
              Open

                  libraries = dict(
                      ConfigParser = dict(
                          text_warning =          '',
                          text_description =      'Das Config-Modul wird benötigt um alle Einstellungen in einer Datei abspeichern und später wieder laden zu können.',
                          text_installation =     'Eine Installation ist nicht nötig, da es sich hierbei um eine Python-Standard-Modul handelt.',
              Severity: Major
              Found in doorpi/status/requirements_lib/req_config.py and 22 other locations - About 40 mins to fix
              doorpi/status/requirements_lib/req_event_handler.py on lines 24..33
              doorpi/status/requirements_lib/req_event_handler.py on lines 24..45
              doorpi/status/requirements_lib/req_system.py on lines 16..27
              doorpi/status/requirements_lib/req_system.py on lines 16..41
              doorpi/status/requirements_lib/req_system.py on lines 16..61
              doorpi/status/requirements_lib/req_system.py on lines 16..75
              doorpi/status/requirements_lib/req_system.py on lines 16..89
              doorpi/status/requirements_lib/req_system.py on lines 16..103
              doorpi/status/requirements_lib/req_system.py on lines 16..117
              doorpi/status/requirements_lib/req_system.py on lines 16..131
              doorpi/status/requirements_lib/req_system.py on lines 16..145
              doorpi/status/requirements_lib/req_system.py on lines 16..159
              doorpi/status/requirements_lib/req_system.py on lines 16..173
              doorpi/status/requirements_lib/req_system.py on lines 16..187
              doorpi/status/requirements_lib/req_system.py on lines 16..201
              doorpi/status/requirements_lib/req_system.py on lines 16..215
              doorpi/status/requirements_lib/req_system.py on lines 16..229
              doorpi/status/requirements_lib/req_system.py on lines 16..243
              doorpi/status/requirements_lib/req_webserver.py on lines 99..110
              doorpi/status/requirements_lib/req_webserver.py on lines 99..124
              doorpi/status/requirements_lib/req_webserver.py on lines 99..138
              doorpi/status/requirements_lib/req_webserver.py on lines 99..152

              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 34.

              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 23 locations. Consider refactoring.
              Open

                  libraries = dict(
                      threading = dict(
                          text_warning =          '',
                          text_description =      'Grundmodul für das Theardering, also die parallele Ausführung von Events.',
                          text_installation =     'Eine Installation ist nicht nötig, da es sich hierbei um eine Python-Standard-Modul handelt.',
              Severity: Major
              Found in doorpi/status/requirements_lib/req_event_handler.py and 22 other locations - About 40 mins to fix
              doorpi/status/requirements_lib/req_config.py on lines 19..43
              doorpi/status/requirements_lib/req_event_handler.py on lines 24..45
              doorpi/status/requirements_lib/req_system.py on lines 16..27
              doorpi/status/requirements_lib/req_system.py on lines 16..41
              doorpi/status/requirements_lib/req_system.py on lines 16..61
              doorpi/status/requirements_lib/req_system.py on lines 16..75
              doorpi/status/requirements_lib/req_system.py on lines 16..89
              doorpi/status/requirements_lib/req_system.py on lines 16..103
              doorpi/status/requirements_lib/req_system.py on lines 16..117
              doorpi/status/requirements_lib/req_system.py on lines 16..131
              doorpi/status/requirements_lib/req_system.py on lines 16..145
              doorpi/status/requirements_lib/req_system.py on lines 16..159
              doorpi/status/requirements_lib/req_system.py on lines 16..173
              doorpi/status/requirements_lib/req_system.py on lines 16..187
              doorpi/status/requirements_lib/req_system.py on lines 16..201
              doorpi/status/requirements_lib/req_system.py on lines 16..215
              doorpi/status/requirements_lib/req_system.py on lines 16..229
              doorpi/status/requirements_lib/req_system.py on lines 16..243
              doorpi/status/requirements_lib/req_webserver.py on lines 99..110
              doorpi/status/requirements_lib/req_webserver.py on lines 99..124
              doorpi/status/requirements_lib/req_webserver.py on lines 99..138
              doorpi/status/requirements_lib/req_webserver.py on lines 99..152

              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 34.

              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 self.current_call.info().call_time == 0 \
                              and self.current_call.info().total_time > self.call_timeout:
                                  logger.info("call timeout - hangup current call after %s seconds", self.call_timeout)
                                  self.current_call.hangup()
                                  DoorPi().event_handler('OnSipPhoneCallTimeoutNoResponse', __name__)
              Severity: Minor
              Found in doorpi/sipphone/from_pjsua.py and 1 other location - About 40 mins to fix
              doorpi/sipphone/from_pjsua.py on lines 199..202

              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 34.

              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 self.current_call.info().call_time > self.max_call_time:
                                  logger.info("max call time reached - hangup current call after %s seconds", self.max_call_time)
                                  self.current_call.hangup()
                                  DoorPi().event_handler('OnSipPhoneCallTimeoutMaxCalltime', __name__)
              Severity: Minor
              Found in doorpi/sipphone/from_pjsua.py and 1 other location - About 40 mins to fix
              doorpi/sipphone/from_pjsua.py on lines 193..197

              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 34.

              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

              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
                Severity
                Category
                Status
                Source
                Language