celluloid/celluloid-io

View on GitHub
lib/celluloid/io/stream.rb

Summary

Maintainability
C
1 day
Test Coverage

Class Stream has 26 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Stream < Socket
      include Enumerable

      # The "sync mode" of the stream
      #
Severity: Minor
Found in lib/celluloid/io/stream.rb - About 3 hrs to fix

    Method read has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def read(size=nil, buf=nil)
            if size == 0
              if buf
                buf.clear
                return buf
    Severity: Minor
    Found in lib/celluloid/io/stream.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

    File stream.rb has 260 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Celluloid
      module IO
        # Base class of all streams in Celluloid::IO
        class Stream < Socket
          include Enumerable
    Severity: Minor
    Found in lib/celluloid/io/stream.rb - About 2 hrs to fix

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

            def gets(eol=$/, limit=nil)
              idx = @read_buffer.index(eol)
      
              until @eof
                break if idx
      Severity: Minor
      Found in lib/celluloid/io/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 do_write has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
      Open

            def do_write(s)
              @write_buffer << s
              @write_buffer.force_encoding(Encoding::BINARY)
      
              if @sync or @write_buffer.size > BLOCK_SIZE or idx = @write_buffer.rindex($/)
      Severity: Minor
      Found in lib/celluloid/io/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 readpartial has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def readpartial(maxlen, buf=nil)
              if maxlen == 0
                if buf
                  buf.clear
                  return buf
      Severity: Minor
      Found in lib/celluloid/io/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 syswrite has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def syswrite(string)
              length = string.length
              total_written = 0
      
              remaining = string
      Severity: Minor
      Found in lib/celluloid/io/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

      There are no issues that match your filters.

      Category
      Status