fossasia/AYABInterface

View on GitHub

Showing 20 of 84 total issues

File states.py has 402 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""This module contains the state machine for the communication class.

Click on this image to go to the states from the diagram:

.. image:: ../../../_static/CommunicationStateDiagram.svg
Severity: Minor
Found in AYABInterface/communication/states.py - About 5 hrs to fix

    File hardware_messages.py has 355 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """This modue contains all the messages taht are received."""
    from ..utils import next_line
    from collections import namedtuple
    from .carriages import id_to_carriage_type
    import struct
    Severity: Minor
    Found in AYABInterface/communication/hardware_messages.py - About 4 hrs to fix

      State has 27 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class State(object):
      
          """The base class for states."""
      
          def __init__(self, communication):
      Severity: Minor
      Found in AYABInterface/communication/states.py - About 3 hrs to fix

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

        def colors_to_needle_positions(rows):
            """Convert rows to needle positions.
        
            :return:
            :rtype: list
        Severity: Minor
        Found in AYABInterface/convert/__init__.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

        Communication has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class Communication(object):
        
            """This class comunicates with the AYAB shield."""
        
            def __init__(self, file, get_needle_positions, machine,
        Severity: Minor
        Found in AYABInterface/communication/__init__.py - About 2 hrs to fix

          File test_hardware_messages.py has 253 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          """Test the received messages."""
          from AYABInterface.communication.host_messages import LineConfirmation
          from AYABInterface.communication.hardware_messages import read_message_type, \
              UnknownMessage, SuccessConfirmation, StartConfirmation, LineRequest, \
              InformationConfirmation, TestConfirmation, StateIndication, Debug, \
          Severity: Minor
          Found in AYABInterface/communication/test/test_hardware_messages.py - About 2 hrs to fix

            Function assert_identify has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
            Open

            def assert_identify(message, expected_true=[]):
                """Make sure the messages "is_*" are True or False."""
                true = set()
                false = set()
                expected_false = set()
            Severity: Minor
            Found in AYABInterface/communication/test/test_assertions.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 test_versions has 10 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def test_versions(self, ready, valid, left_hall, left_bytes, right_hall,
            Severity: Major
            Found in AYABInterface/communication/test/test_hardware_messages.py - About 1 hr to fix

              Function needle_positions_to_bytes has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  def needle_positions_to_bytes(self, needle_positions):
                      """Convert the needle positions to the wire format.
              
                      This conversion is used for :ref:`cnfline`.
              
              
              Severity: Minor
              Found in AYABInterface/machines.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 test_get_normal_line has 6 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def test_get_normal_line(self, cache, machine, machine_bytes, last_line,
              Severity: Minor
              Found in AYABInterface/communication/test/test_needle_position_cache.py - About 45 mins to fix

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

                def list_serial_port_strings():
                    """Lists serial port names.
                
                    :raises EnvironmentError:
                        On unsupported or unknown platforms
                Severity: Minor
                Found in AYABInterface/serial.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, file, get_needle_positions, machine,
                Severity: Minor
                Found in AYABInterface/communication/__init__.py - About 45 mins to fix

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

                      def test_line_number(self, last_line, next_line, byte, monkeypatch, file,
                  Severity: Minor
                  Found in AYABInterface/communication/test/test_hardware_messages.py - About 45 mins to fix

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

                    def communication(file, on_message_received, monkeypatch, create_message,
                    Severity: Minor
                    Found in AYABInterface/communication/test/test_communication_mocked.py - About 45 mins to fix

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

                          def check(self):
                              """Check for validity.
                      
                              :raises ValueError:
                      
                      
                      Severity: Minor
                      Found in AYABInterface/needle_positions.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 test_communication_creation has 5 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def test_communication_creation(self, interaction, communication, machine,
                      Severity: Minor
                      Found in AYABInterface/test/test_interaction.py - About 35 mins to fix

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

                            def test_bytes(self, line_number, communication, file, line_bytes,
                        Severity: Minor
                        Found in AYABInterface/communication/test/test_host_messages.py - About 35 mins to fix

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

                              def test_cache_works_only_for_specific_line(
                          Severity: Minor
                          Found in AYABInterface/communication/test/test_needle_position_cache.py - About 35 mins to fix

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

                                def test_last(self, get_line, cache, number, line, truth):
                            Severity: Minor
                            Found in AYABInterface/communication/test/test_needle_position_cache.py - About 35 mins to fix

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

                              def sum_all(iterable, start):
                                  """Sum up an iterable starting with a start value.
                              
                                  In contrast to :func:`sum`, this also works on other types like
                                  :class:`lists <list>` and :class:`sets <set>`.
                              Severity: Minor
                              Found in AYABInterface/utils.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