guard/rb-fsevent

View on GitHub

Showing 7 of 7 total issues

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

    def parse(io, encoding = 'internal', fallback_encoding = nil)
      fallback_encoding = io.encoding if io.respond_to? :encoding
      io = StringIO.new(io) if io.respond_to? :to_str
      length, byte = String.new, nil

Severity: Minor
Found in lib/otnetstring.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 run has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
Open

  def run
    @pipe    = open_pipe
    @running = true

    # please note the use of IO::select() here, as it is used specifically to
Severity: Minor
Found in lib/rb-fsevent/fsevent.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 run has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def run
    @pipe    = open_pipe
    @running = true

    # please note the use of IO::select() here, as it is used specifically to
Severity: Minor
Found in lib/rb-fsevent/fsevent.rb - About 1 hr to fix

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

        def parse(io, encoding = 'internal', fallback_encoding = nil)
          fallback_encoding = io.encoding if io.respond_to? :encoding
          io = StringIO.new(io) if io.respond_to? :to_str
          length, byte = String.new, nil
    
    
    Severity: Minor
    Found in lib/otnetstring.rb - About 1 hr to fix

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

          def with_encoding(str, encoding, fallback = nil)
            return str unless str.respond_to? :encode
            encoding = Encoding.find encoding if encoding.respond_to? :to_str
            encoding ||= fallback
            encoding ? str.encode(encoding) : str
      Severity: Minor
      Found in lib/otnetstring.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 encode has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def encode(obj, string_sep = ',')
            case obj
            when String   then with_encoding "#{obj.bytesize}#{string_sep}#{obj}", "binary"
            when Integer  then encode(obj.inspect, '#')
            when NilClass then "0~"
      Severity: Minor
      Found in lib/otnetstring.rb - About 45 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 stop has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

        def stop
          unless @pipe.nil?
            Process.kill('KILL', @pipe.pid) if process_running?(@pipe.pid)
            @pipe.close
          end
      Severity: Minor
      Found in lib/rb-fsevent/fsevent.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

      Severity
      Category
      Status
      Source
      Language