rapid7/ruby_smb

View on GitHub
lib/ruby_smb/compression/lznt1.rb

Summary

Maintainability
C
1 day
Test Coverage

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

      def self.decompress_chunk(chunk)
        out = ''
        until chunk.empty?
          flags = chunk[0].unpack1('C')
          chunk = chunk[1..-1]
Severity: Minor
Found in lib/ruby_smb/compression/lznt1.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 compress_chunk has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

      def self.compress_chunk(chunk)
        blob = chunk
        out = ''
        pow2 = 0x10
        l_mask3 = 0x1002
Severity: Minor
Found in lib/ruby_smb/compression/lznt1.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 find has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

        def find(src, target, max_len)
          result_offset = 0
          result_length = 0
          1.upto(max_len - 1) do |i|
            offset = src.rindex(target[0...i])
Severity: Minor
Found in lib/ruby_smb/compression/lznt1.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 compress_chunk has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def self.compress_chunk(chunk)
        blob = chunk
        out = ''
        pow2 = 0x10
        l_mask3 = 0x1002
Severity: Minor
Found in lib/ruby_smb/compression/lznt1.rb - About 1 hr to fix

    Method decompress_chunk has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def self.decompress_chunk(chunk)
            out = ''
            until chunk.empty?
              flags = chunk[0].unpack1('C')
              chunk = chunk[1..-1]
    Severity: Minor
    Found in lib/ruby_smb/compression/lznt1.rb - About 1 hr to fix

      Method compress has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.compress(buf, chunk_size: 0x1000)
              out = ''
              until buf.empty?
                chunk = buf[0...chunk_size]
                compressed = compress_chunk(chunk)
      Severity: Minor
      Found in lib/ruby_smb/compression/lznt1.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 decompress has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.decompress(buf, length_check: true)
              out = ''
              until buf.empty?
                header = buf.unpack1('v')
                length = (header & 0xfff) + 1
      Severity: Minor
      Found in lib/ruby_smb/compression/lznt1.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

      There are no issues that match your filters.

      Category
      Status