etehtsea/oxblood

View on GitHub
lib/oxblood/protocol.rb

Summary

Maintainability
A
2 hrs
Test Coverage

Method has too many lines. [28/10]
Open

      def parse(io)
        line = io.gets(TERMINATOR)

        case line[0]
        when SIMPLE_STRING
Severity: Minor
Found in lib/oxblood/protocol.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Assignment Branch Condition size for parse is too high. [24.49/15]
Open

      def parse(io)
        line = io.gets(TERMINATOR)

        case line[0]
        when SIMPLE_STRING
Severity: Minor
Found in lib/oxblood/protocol.rb by rubocop

This cop checks that the ABC size of methods is not higher than the configured maximum. The ABC size is based on assignments, branches (method calls), and conditions. See http://c2.com/cgi/wiki?AbcMetric

Cyclomatic complexity for parse is too high. [11/6]
Open

      def parse(io)
        line = io.gets(TERMINATOR)

        case line[0]
        when SIMPLE_STRING
Severity: Minor
Found in lib/oxblood/protocol.rb by rubocop

This cop checks that the cyclomatic complexity of methods is not higher than the configured maximum. The cyclomatic complexity is the number of linearly independent paths through a method. The algorithm counts decision points and adds one.

An if statement (or unless or ?:) increases the complexity by one. An else branch does not, since it doesn't add a decision point. The && operator (or keyword and) can be converted to a nested if statement, and ||/or is shorthand for a sequence of ifs, so they also add one. Loops can be said to have an exit condition, so they add one.

Method has too many lines. [15/10]
Open

      def build_command(command = nil, *args)
        return EMPTY_ARRAY_RESPONSE if command.nil?

        result = append!(command, COMMAND_HEADER.dup)
        size = 1
Severity: Minor
Found in lib/oxblood/protocol.rb by rubocop

This cop checks if the length of a method exceeds some maximum value. Comment lines can optionally be ignored. The maximum allowed length is configurable.

Method parse has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def parse(io)
        line = io.gets(TERMINATOR)

        case line[0]
        when SIMPLE_STRING
Severity: Minor
Found in lib/oxblood/protocol.rb - About 1 hr to fix

    Method parse has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def parse(io)
            line = io.gets(TERMINATOR)
    
            case line[0]
            when SIMPLE_STRING
    Severity: Minor
    Found in lib/oxblood/protocol.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 the use of the case equality operator ===.
    Open

              if Array === c
    Severity: Minor
    Found in lib/oxblood/protocol.rb by rubocop

    This cop checks for uses of the case equality operator(===).

    Example:

    # bad
    Array === something
    (1..100) === 7
    /something/ === some_string
    
    # good
    something.is_a?(Array)
    (1..100).include?(7)
    some_string =~ /something/

    Missing top-level module documentation comment.
    Open

      module Protocol
    Severity: Minor
    Found in lib/oxblood/protocol.rb by rubocop

    This cop checks for missing top-level documentation of classes and modules. Classes with no body are exempt from the check and so are namespace modules - modules that have nothing in their bodies except classes, other modules, or constant definitions.

    The documentation requirement is annulled if the class or module has a "#:nodoc:" comment next to it. Likewise, "#:nodoc: all" does the same for all its children.

    Example:

    # bad
    class Person
      # ...
    end
    
    # good
    # Description/Explanation of Person class
    class Person
      # ...
    end

    Provide an exception class and message as arguments to raise.
    Open

              raise ParserError.new('Unsupported response type')
    Severity: Minor
    Found in lib/oxblood/protocol.rb by rubocop

    This cop checks the args passed to fail and raise. For exploded style (default), it recommends passing the exception class and message to raise, rather than construct an instance of the error. It will still allow passing just a message, or the construction of an error with more than one argument.

    The exploded style works identically, but with the addition that it will also suggest constructing error objects when the exception is passed multiple arguments.

    Example: EnforcedStyle: exploded (default)

    # bad
    raise StandardError.new("message")
    
    # good
    raise StandardError, "message"
    fail "message"
    raise MyCustomError.new(arg1, arg2, arg3)
    raise MyKwArgError.new(key1: val1, key2: val2)

    Example: EnforcedStyle: compact

    # bad
    raise StandardError, "message"
    raise RuntimeError, arg1, arg2, arg3
    
    # good
    raise StandardError.new("message")
    raise MyCustomError.new(arg1, arg2, arg3)
    fail "message"

    Line is too long. [83/80]
    Open

        EMPTY_BULK_STRING_RESPONSE = "#{BULK_STRING}0#{TERMINATOR}#{TERMINATOR}".freeze
    Severity: Minor
    Found in lib/oxblood/protocol.rb by rubocop

    There are no issues that match your filters.

    Category
    Status