zeiv/SSD1306-ruby

View on GitHub

Showing 6 of 6 total issues

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

    File font.rb has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module SSD1306
      FONT = [
        0x00, 0x00, 0x00, 0x00, 0x00,
        0x3E, 0x5B, 0x4F, 0x5B, 0x3E,
        0x3E, 0x6B, 0x4F, 0x6B, 0x3E,
    Severity: Minor
    Found in lib/SSD1306/font.rb - About 2 hrs to fix

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