piotrmurach/tty-reader

View on GitHub
lib/tty/reader/line.rb

Summary

Maintainability
B
4 hrs
Test Coverage

Class Line has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Line
      ANSI_MATCHER = /(\[)?\033(\[)?[;?\d]*[\dA-Za-z](\])?/

      # The word break characters list used by shell
      DEFAULT_WORD_BREAK_CHARACTERS = " \t\n\"\\'`@$><=|&{("
Severity: Minor
Found in lib/tty/reader/line.rb - About 3 hrs to fix

    Method word_start_pos has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

          def word_start_pos(from: @cursor, before: true)
            # move back or forward by one character when at a word boundary
            if word_boundary?
              from = before ? from - 1 : from + 1
            end
    Severity: Minor
    Found in lib/tty/reader/line.rb - About 35 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

    Method []= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

          def []=(i, chars)
            edit_mode
    
            if i.is_a?(Range)
              @text[i] = chars
    Severity: Minor
    Found in lib/tty/reader/line.rb - 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

    There are no issues that match your filters.

    Category
    Status