zeiv/SSD1306-ruby

View on GitHub
lib/SSD1306/display.rb

Summary

Maintainability
C
1 day
Test Coverage

Method initialize has 73 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def initialize(opts = {})
      default_options = {
        protocol: :i2c,
        path:     '/dev/i2c-1',
        address:  0x3C,
Severity: Major
Found in lib/SSD1306/display.rb - About 2 hrs to fix

    Method print_char has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        def print_char(b)
          if b == 10
            @cursor.newline
          elsif b > 31
            for i in 0...5
    Severity: Minor
    Found in lib/SSD1306/display.rb - 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

    Method initialize has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        def initialize(opts = {})
          default_options = {
            protocol: :i2c,
            path:     '/dev/i2c-1',
            address:  0x3C,
    Severity: Minor
    Found in lib/SSD1306/display.rb - 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

    Method image has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def image(image)
          image.image_type = BilevelType
          pix = image.export_pixels(0, 0, @width, @height, 'I')
          index = 0
          for page in 0...@pages
    Severity: Minor
    Found in lib/SSD1306/display.rb - 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

    Avoid deeply nested control flow statements.
    Open

                  for x_interval in 0...@cursor.size
                    @buffer[@cursor.buffer_index(page) + i*@cursor.size + x_interval] = bytes[page]
                  end
    Severity: Major
    Found in lib/SSD1306/display.rb - About 45 mins to fix

      There are no issues that match your filters.

      Category
      Status