archSeer/ruby-mpd

View on GitHub
lib/ruby-mpd/parser.rb

Summary

Maintainability
B
5 hrs
Test Coverage

Method parse_key has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_key(key, value)
      if INT_KEYS.include? key
        value.to_i
      elsif FLOAT_KEYS.include? key
        value == 'nan' ? Float::NAN : value.to_f
Severity: Minor
Found in lib/ruby-mpd/parser.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

Method convert_command has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    def convert_command(command, *params)
      params.map! do |param|
        case param
        when true, false
          param ? '1' : '0' # convert bool to 1 or 0
Severity: Minor
Found in lib/ruby-mpd/parser.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_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def parse_response(command, string)
      if command == :listall # Explicitly handle :listall (#files) -> always return a Hash
        return build_hash(string)
      elsif command == :listallinfo
        # We do not care about directories or playlists,
Severity: Minor
Found in lib/ruby-mpd/parser.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

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

    def build_response(command, string)
      chunks = make_chunks(string)
      # if there are any new lines (more than one data piece), it's a hash, else an object.
      is_hash = chunks.any? { |chunk| chunk.include? "\n" }

Severity: Minor
Found in lib/ruby-mpd/parser.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