archSeer/ruby-mpd

View on GitHub

Showing 8 of 8 total issues

File song.rb has 261 lines of code (exceeds 250 allowed). Consider refactoring.
Open

class MPD; end

# Object representation of a song.
#
# If the field doesn't exist or isn't set, nil will be returned
Severity: Minor
Found in lib/ruby-mpd/song.rb - About 2 hrs to fix

    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 where has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

          def where(params, options = {})
            if options[:add]
              command = options[:strict] ? :findadd : :searchadd
            else
              command = options[:strict] ? :find : :search
    Severity: Minor
    Found in lib/ruby-mpd/plugins/database.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 handle_server_response has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def handle_server_response
        msg = ''
        while true
          case line = socket.gets
          when "OK\n"
    Severity: Minor
    Found in lib/ruby-mpd.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 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

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

        def songs
          result = @mpd.send_command(:listplaylistinfo, @name)
          result.map do |hash|
            if hash[:file] && !hash[:file].match(/^(https?:\/\/)?/)[0].empty?
              Song.new(@mpd, {:file => hash[:file], :time => [0]})
    Severity: Minor
    Found in lib/ruby-mpd/playlist.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 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

    Severity
    Category
    Status
    Source
    Language