adhearsion/ruby_ami

View on GitHub

Showing 6 of 6 total issues

Method parse_message has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_message(raw)
      return if raw.length == 0

      # Mark this message as processed, including the 4 stripped cr/lf bytes
      @processed += raw.length
Severity: Minor
Found in lib/ruby_ami/lexer.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 parse_message has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def parse_message(raw)
      return if raw.length == 0

      # Mark this message as processed, including the 4 stripped cr/lf bytes
      @processed += raw.length
Severity: Minor
Found in lib/ruby_ami/lexer.rb - About 1 hr to fix

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

        def message_received(message)
          logger.trace "[RECV] #{message.inspect}"
          case message
          when Event
            action = causal_action_for_event message
    Severity: Minor
    Found in lib/ruby_ami/stream.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 parse_buffer has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def parse_buffer
          # Special case for the protocol header
          if @buffer =~ PROMPT
            @ami_version = $1
            @buffer.slice! HEADER_SLICE
    Severity: Minor
    Found in lib/ruby_ami/lexer.rb - About 55 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 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def <<(message)
          case message
          when Error
            self.response = message
            complete!
    Severity: Minor
    Found in lib/ruby_ami/action.rb - About 55 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 initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def initialize(host, port, username, password, event_callback, logger = Logger, timeout = 0)
    Severity: Major
    Found in lib/ruby_ami/stream.rb - About 50 mins to fix
      Severity
      Category
      Status
      Source
      Language