fossasia/AYABInterface

View on GitHub

Showing 84 of 84 total issues

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 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_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 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_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_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

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

                        if right_end_needle < 1 or right_end_needle > 199:
                            raise ValueError(_right_end_needle_error_message(right_end_needle))
                Severity: Minor
                Found in AYABInterface/communication/host_messages.py and 1 other location - About 30 mins to fix
                AYABInterface/communication/host_messages.py on lines 93..94

                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

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

                        if left_end_needle < 0 or left_end_needle > 198:
                            raise ValueError(_left_end_needle_error_message(left_end_needle))
                Severity: Minor
                Found in AYABInterface/communication/host_messages.py and 1 other location - About 30 mins to fix
                AYABInterface/communication/host_messages.py on lines 97..98

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

                Expected 2 blank lines after class or function definition, found 1
                Open

                __all__ = ["Machine", "KH9XXSeries", "CK35", "KH900", "KH910", "KH930",
                Severity: Minor
                Found in AYABInterface/machines.py by pep8

                Separate top-level function and class definitions with two blank lines.

                Method definitions inside a class are separated by a single blank
                line.
                
                Extra blank lines may be used (sparingly) to separate groups of
                related functions.  Blank lines may be omitted between a bunch of
                related one-liners (e.g. a set of dummy implementations).
                
                Use blank lines in functions, sparingly, to indicate logical
                sections.
                
                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                Okay: default = 1\nfoo = 1
                Okay: classify = 1\nfoo = 1
                
                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                E302: def a():\n    pass\n\ndef b(n):\n    pass
                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                E303: def a():\n\n\n\n    pass
                E304: @decorator\n\ndef a():\n    pass
                E305: def a():\n    pass\na()
                E306: def a():\n    def b():\n        pass\n    def c():\n        pass

                Do not use bare 'except'
                Open

                except:
                Severity: Minor
                Found in AYABInterface/serial.py by pep8

                When catching exceptions, mention specific exceptions when possible.

                Okay: except Exception:
                Okay: except BaseException:
                E722: except:

                Expected 2 blank lines after class or function definition, found 1
                Open

                __all__ = ["Communication"]

                Separate top-level function and class definitions with two blank lines.

                Method definitions inside a class are separated by a single blank
                line.
                
                Extra blank lines may be used (sparingly) to separate groups of
                related functions.  Blank lines may be omitted between a bunch of
                related one-liners (e.g. a set of dummy implementations).
                
                Use blank lines in functions, sparingly, to indicate logical
                sections.
                
                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                Okay: default = 1\nfoo = 1
                Okay: classify = 1\nfoo = 1
                
                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                E302: def a():\n    pass\n\ndef b(n):\n    pass
                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                E303: def a():\n\n\n\n    pass
                E304: @decorator\n\ndef a():\n    pass
                E305: def a():\n    pass\na()
                E306: def a():\n    def b():\n        pass\n    def c():\n        pass

                Expected 2 blank lines after class or function definition, found 1
                Open

                __all__ = ["ActionMetaClass", "Action", "SwitchCarriageToModeKc",
                Severity: Minor
                Found in AYABInterface/actions.py by pep8

                Separate top-level function and class definitions with two blank lines.

                Method definitions inside a class are separated by a single blank
                line.
                
                Extra blank lines may be used (sparingly) to separate groups of
                related functions.  Blank lines may be omitted between a bunch of
                related one-liners (e.g. a set of dummy implementations).
                
                Use blank lines in functions, sparingly, to indicate logical
                sections.
                
                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                Okay: default = 1\nfoo = 1
                Okay: classify = 1\nfoo = 1
                
                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                E302: def a():\n    pass\n\ndef b(n):\n    pass
                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                E303: def a():\n\n\n\n    pass
                E304: @decorator\n\ndef a():\n    pass
                E305: def a():\n    pass\na()
                E306: def a():\n    def b():\n        pass\n    def c():\n        pass

                Expected 2 blank lines after class or function definition, found 1
                Open

                __all__ = ["Carriage", "KnitCarriage"]
                Severity: Minor
                Found in AYABInterface/carriages.py by pep8

                Separate top-level function and class definitions with two blank lines.

                Method definitions inside a class are separated by a single blank
                line.
                
                Extra blank lines may be used (sparingly) to separate groups of
                related functions.  Blank lines may be omitted between a bunch of
                related one-liners (e.g. a set of dummy implementations).
                
                Use blank lines in functions, sparingly, to indicate logical
                sections.
                
                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                Okay: default = 1\nfoo = 1
                Okay: classify = 1\nfoo = 1
                
                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                E302: def a():\n    pass\n\ndef b(n):\n    pass
                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                E303: def a():\n\n\n\n    pass
                E304: @decorator\n\ndef a():\n    pass
                E305: def a():\n    pass\na()
                E306: def a():\n    def b():\n        pass\n    def c():\n        pass

                Expected 2 blank lines after class or function definition, found 1
                Open

                __all__ = ["list_serial_port_strings", "list_serial_ports", "SerialPort"]
                Severity: Minor
                Found in AYABInterface/serial.py by pep8

                Separate top-level function and class definitions with two blank lines.

                Method definitions inside a class are separated by a single blank
                line.
                
                Extra blank lines may be used (sparingly) to separate groups of
                related functions.  Blank lines may be omitted between a bunch of
                related one-liners (e.g. a set of dummy implementations).
                
                Use blank lines in functions, sparingly, to indicate logical
                sections.
                
                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                Okay: default = 1\nfoo = 1
                Okay: classify = 1\nfoo = 1
                
                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                E302: def a():\n    pass\n\ndef b(n):\n    pass
                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                E303: def a():\n\n\n\n    pass
                E304: @decorator\n\ndef a():\n    pass
                E305: def a():\n    pass\na()
                E306: def a():\n    def b():\n        pass\n    def c():\n        pass

                Expected 2 blank lines after class or function definition, found 1
                Open

                __all__ = ["colors_to_needle_positions", "NeedlePositions"]
                Severity: Minor
                Found in AYABInterface/convert/__init__.py by pep8

                Separate top-level function and class definitions with two blank lines.

                Method definitions inside a class are separated by a single blank
                line.
                
                Extra blank lines may be used (sparingly) to separate groups of
                related functions.  Blank lines may be omitted between a bunch of
                related one-liners (e.g. a set of dummy implementations).
                
                Use blank lines in functions, sparingly, to indicate logical
                sections.
                
                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                Okay: default = 1\nfoo = 1
                Okay: classify = 1\nfoo = 1
                
                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                E302: def a():\n    pass\n\ndef b(n):\n    pass
                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                E303: def a():\n\n\n\n    pass
                E304: @decorator\n\ndef a():\n    pass
                E305: def a():\n    pass\na()
                E306: def a():\n    def b():\n        pass\n    def c():\n        pass

                Expected 2 blank lines after class or function definition, found 1
                Open

                PATCH_RECEIVED = "AYABInterface.communication.hardware_messages."\

                Separate top-level function and class definitions with two blank lines.

                Method definitions inside a class are separated by a single blank
                line.
                
                Extra blank lines may be used (sparingly) to separate groups of
                related functions.  Blank lines may be omitted between a bunch of
                related one-liners (e.g. a set of dummy implementations).
                
                Use blank lines in functions, sparingly, to indicate logical
                sections.
                
                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                Okay: default = 1\nfoo = 1
                Okay: classify = 1\nfoo = 1
                
                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                E302: def a():\n    pass\n\ndef b(n):\n    pass
                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                E303: def a():\n\n\n\n    pass
                E304: @decorator\n\ndef a():\n    pass
                E305: def a():\n    pass\na()
                E306: def a():\n    def b():\n        pass\n    def c():\n        pass

                Expected 2 blank lines after class or function definition, found 1
                Open

                _id_to_carriage = {0: NullCarriage, 1: KnitCarriage, 2: HoleCarriage}

                Separate top-level function and class definitions with two blank lines.

                Method definitions inside a class are separated by a single blank
                line.
                
                Extra blank lines may be used (sparingly) to separate groups of
                related functions.  Blank lines may be omitted between a bunch of
                related one-liners (e.g. a set of dummy implementations).
                
                Use blank lines in functions, sparingly, to indicate logical
                sections.
                
                Okay: def a():\n    pass\n\n\ndef b():\n    pass
                Okay: def a():\n    pass\n\n\nasync def b():\n    pass
                Okay: def a():\n    pass\n\n\n# Foo\n# Bar\n\ndef b():\n    pass
                Okay: default = 1\nfoo = 1
                Okay: classify = 1\nfoo = 1
                
                E301: class Foo:\n    b = 0\n    def bar():\n        pass
                E302: def a():\n    pass\n\ndef b(n):\n    pass
                E302: def a():\n    pass\n\nasync def b(n):\n    pass
                E303: def a():\n    pass\n\n\n\ndef b(n):\n    pass
                E303: def a():\n\n\n\n    pass
                E304: @decorator\n\ndef a():\n    pass
                E305: def a():\n    pass\na()
                E306: def a():\n    def b():\n        pass\n    def c():\n        pass
                Severity
                Category
                Status
                Source
                Language