motom001/DoorPi

View on GitHub

Showing 201 of 201 total issues

Avoid too many return statements within this function.
Open

        else: return self.real_resource(parsed_path.path)
Severity: Major
Found in doorpi/status/webserver_lib/request_handler.py - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

                return self.return_message(str(prepared_object))
    Severity: Major
    Found in doorpi/status/webserver_lib/request_handler.py - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

                      return
      Severity: Major
      Found in doorpi/sipphone/linphone_lib/CallBacks.py - About 30 mins to fix

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

        def get(parameters):
            parsed_parameters = doorpi.DoorPi().parse_string(parameters)
            return UrlCallAction(fire_command, url=parsed_parameters)
        Severity: Minor
        Found in doorpi/action/SingleActions/url_call.py and 1 other location - About 30 mins to fix
        doorpi/action/SingleActions/os_execute.py on lines 19..21

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

        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

        Avoid too many return statements within this function.
        Open

                return True
        Severity: Major
        Found in doorpi/status/webserver_lib/request_handler.py - About 30 mins to fix

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

              files = sorted(glob.glob(os.path.join(snapshot_path, "*.*")), key=os.path.getctime)
          Severity: Minor
          Found in doorpi/action/SingleActions/take_snapshot.py and 1 other location - About 30 mins to fix
          doorpi/action/SingleActions/take_snapshot.py on lines 33..33

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

          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

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

              files = sorted(glob.glob(os.path.join(snapshot_path, "*.*")), key=os.path.getctime)
          Severity: Minor
          Found in doorpi/action/SingleActions/take_snapshot.py and 1 other location - About 30 mins to fix
          doorpi/action/SingleActions/take_snapshot.py on lines 22..22

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

          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

          Avoid too many return statements within this function.
          Open

                  return False
          Severity: Major
          Found in doorpi/sipphone/from_pjsua.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                        return self.return_message(repr(prepared_object))
            Severity: Major
            Found in doorpi/status/webserver_lib/request_handler.py - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                              return False
              Severity: Major
              Found in doorpi/status/webserver_lib/request_handler.py - About 30 mins to fix

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

                def get(parameters):
                    parsed_parameters = doorpi.DoorPi().parse_string(parameters)
                    return OsExecuteAction(fire_command, command = parsed_parameters)
                Severity: Minor
                Found in doorpi/action/SingleActions/os_execute.py and 1 other location - About 30 mins to fix
                doorpi/action/SingleActions/url_call.py on lines 46..48

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

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

                    def list_directory(self, path):
                        dirs = []
                        files = []
                        for item in os.listdir(path):
                            if os.path.isfile(item): files.append(item)
                Severity: Minor
                Found in doorpi/status/webserver_lib/request_handler.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

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

                    def set_output(self, pin, value, log_output = True):
                        if self._ser and self._ser.isOpen():
                            if log_output: logger.debug('try to write %s to serial usb plain', pin)
                            self._ser.flushOutput()
                            self._ser.write(pin + self._output_stop_flag)
                Severity: Minor
                Found in doorpi/keyboard/from_usb_plain.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

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

                    def event_detect(self, pin):
                        if self.status_input(pin):
                            self._fire_OnKeyDown(pin, __name__)
                            if self._pressed_on_key_down:  # issue 134
                                self._fire_OnKeyPressed(pin, __name__)
                Severity: Minor
                Found in doorpi/keyboard/from_gpio.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

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

                    def __init__(self, input_pins, output_pins, conf_pre, conf_post, keyboard_name, polarity = 0, *args, **kwargs):
                        logger.debug("FileSystem.__init__(input_pins = %s, output_pins = %s, polarity = %s)",
                                     input_pins, output_pins, polarity)
                        self.keyboard_name = keyboard_name
                        self._polarity = polarity
                Severity: Minor
                Found in doorpi/keyboard/from_filesystem.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

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

                    def event_detect(self, event):
                        if self.status_input(event.pin_num):
                            self._fire_OnKeyDown(event.pin_num, __name__)
                            if self._pressed_on_key_down:  # issue 134
                                self._fire_OnKeyPressed(event.pin_num, __name__)
                Severity: Minor
                Found in doorpi/keyboard/from_piface.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

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

                    def sound_devices(self):
                        try:
                            all_devices = []
                            for sound_device in self.lib.enum_snd_dev():
                                all_devices.append({
                Severity: Minor
                Found in doorpi/sipphone/from_pjsua.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

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

                def get(*args, **kwargs):
                    files = dict()
                    try:
                        if len(kwargs['name']) == 0: kwargs['name'] = ['']
                        if len(kwargs['value']) == 0: kwargs['value'] = ['']
                Severity: Minor
                Found in doorpi/status/status_lib/history_snapshot.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

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

                    def on_state(self):
                        logger.debug("on_state (%s)", self.call.info().state_text)
                        DoorPi().event_handler('OnCallStateChange', __name__, {
                            'remote_uri': self.call.info().remote_uri,
                            'state': self.call.info().state_text
                Severity: Minor
                Found in doorpi/sipphone/pjsua_lib/SipPhoneCallCallBack.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

                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

                Severity
                Category
                Status
                Source
                Language