nstrct/nstrct-ruby

View on GitHub

Showing 12 of 12 total issues

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

    def self.available?(buffer)
      if buffer.size >= 1
        raise StartOfFrameInvalid unless buffer.slice(0).unpack('C')[0] == FRAME_START
        if buffer.size >= 3
          payload_length = buffer.slice(1..2).unpack('S>')[0]
Severity: Minor
Found in lib/nstrct/frame.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 pack_value has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def pack_value(datatype, value, data)
      case datatype
      when :boolean
        data += [to_boolean(value) ? 1 : 0].pack('C')
      when :int8
Severity: Minor
Found in lib/nstrct/argument.rb - About 1 hr to fix

    Method parse_value has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def self.parse_value(datatype, data)
          case datatype
          when :boolean
            return data.slice!(0).unpack('C')[0] == 1
          when :int8
    Severity: Minor
    Found in lib/nstrct/argument.rb - About 1 hr to fix

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

          def array_elements
            @arguments.inject(0) { |sum, a| sum + (a.array ? a.value.is_a?(Array) ? a.value.size : 0 : 0) }
          end
      Severity: Minor
      Found in lib/nstrct/instruction.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

      Avoid too many return statements within this method.
      Open

              return data.slice!(0..7).unpack('q>')[0]
      Severity: Major
      Found in lib/nstrct/argument.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                return length > 0 ? data.slice!(0..length - 1) : ''
        Severity: Major
        Found in lib/nstrct/argument.rb - About 30 mins to fix

          Avoid too many return statements within this method.
          Open

                  return data.slice!(0..1).unpack('S>')[0]
          Severity: Major
          Found in lib/nstrct/argument.rb - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return data.slice!(0).unpack('C')[0]
            Severity: Major
            Found in lib/nstrct/argument.rb - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                      return data.slice!(0..7).unpack('Q>')[0]
              Severity: Major
              Found in lib/nstrct/argument.rb - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                        return data.slice!(0..7).unpack('G')[0]
                Severity: Major
                Found in lib/nstrct/argument.rb - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                          return data.slice!(0..3).unpack('L>')[0]
                  Severity: Major
                  Found in lib/nstrct/argument.rb - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                            return data.slice!(0..3).unpack('g')[0]
                    Severity: Major
                    Found in lib/nstrct/argument.rb - About 30 mins to fix
                      Severity
                      Category
                      Status
                      Source
                      Language