ronin-rb/ronin-support

View on GitHub

Showing 197 of 197 total issues

Method stream has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def stream(io, block_size: 16384, output: nil)
          unless block_given?
            output ||= String.new(encoding: Encoding::ASCII_8BIT)
          end

Severity: Minor
Found in lib/ronin/support/crypto/cipher.rb - About 55 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 each_unique_substring has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

  def each_unique_substring(min=1,&block)
    return enum_for(__method__,min) unless block

    unique_strings = {}

Severity: Minor
Found in lib/ronin/support/core_ext/string.rb - About 55 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 padding has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

        def self.padding(new_padding=nil)
          unless new_padding.nil?
            @padding = new_padding
          else
            if @padding.nil?
Severity: Minor
Found in lib/ronin/support/binary/struct.rb - About 55 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 poll has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

          def poll
            sockets = [@socket] + client_connections + server_connections

            readable, _writtable, errors = IO.select(sockets,nil,sockets)

Severity: Minor
Found in lib/ronin/support/network/tcp/proxy.rb - About 55 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

Similar blocks of code found in 3 locations. Consider refactoring.
Open

class String

  #
  # Escapes a String for C.
  #
Severity: Major
Found in lib/ronin/support/encoding/c/core_ext/string.rb and 2 other locations - About 55 mins to fix
lib/ronin/support/encoding/js/core_ext/string.rb on lines 21..122
lib/ronin/support/encoding/shell/core_ext/string.rb on lines 23..131

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 44.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

class String

  #
  # Escapes a String for JavaScript.
  #
Severity: Major
Found in lib/ronin/support/encoding/js/core_ext/string.rb and 2 other locations - About 55 mins to fix
lib/ronin/support/encoding/c/core_ext/string.rb on lines 21..122
lib/ronin/support/encoding/shell/core_ext/string.rb on lines 23..131

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 44.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

class String

  #
  # Shell escapes the characters in the String.
  #
Severity: Major
Found in lib/ronin/support/encoding/shell/core_ext/string.rb and 2 other locations - About 55 mins to fix
lib/ronin/support/encoding/c/core_ext/string.rb on lines 21..122
lib/ronin/support/encoding/js/core_ext/string.rb on lines 21..122

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 44.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Method initialize has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def initialize(string, offset: , length: )
          if length == Float::INFINITY
            length = string.bytesize - offset
          end

Severity: Minor
Found in lib/ronin/support/binary/byte_slice.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 tld_regexp has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def tld_regexp(tld,subtree)
            if subtree
              subtree_regexp = if subtree.length == 1
                                 tld_regexp(subtree.keys[0],subtree.values[0])
                               else
Severity: Minor
Found in lib/ronin/support/network/public_suffix/list.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 generate has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def self.generate(version:    2,
                          serial:     0,
                          not_before: Time.now,
                          not_after:  not_before + ONE_YEAR,
                          subject:    nil,
Severity: Minor
Found in lib/ronin/support/crypto/cert.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 escape_byte has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def self.escape_byte(byte,**kwargs)
            if (byte == 42) || (byte == 45) || (byte == 46) || ((byte >= 48) && (byte <= 57)) || ((byte >= 65) && (byte <= 90)) || (byte == 95) || ((byte >= 97) && (byte <= 122))
              byte.chr
            else
              encode_byte(byte,**kwargs)
Severity: Minor
Found in lib/ronin/support/encoding/uri.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 build has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def self.build(common_name: nil, organizational_unit: nil, organization: nil, locality: nil, state: nil, province: nil, country: nil)
            name = new
            name.add_entry("CN",common_name)         if common_name
            name.add_entry("OU",organizational_unit) if organizational_unit
            name.add_entry("O",organization)         if organization
Severity: Minor
Found in lib/ronin/support/crypto/cert.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 parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def self.parse(path=PATH)
            return enum_for(__method__,path) unless block_given?

            type = nil

Severity: Minor
Found in lib/ronin/support/network/public_suffix/list.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 parse has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def self.parse(path=PATH)
            return enum_for(__method__,path) unless block_given?

            io = if File.extname(path) == '.gz' then Zlib::GzipReader.open(path)
                 else                                File.new(path)
Severity: Minor
Found in lib/ronin/support/network/asn/list.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 escape_byte has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def self.escape_byte(byte)
          if byte >= 0x00 && byte <= 0xff
            ESCAPE_BYTES.fetch(byte) do
              if byte >= 0x20 && byte <= 0x7e
                byte.chr
Severity: Minor
Found in lib/ronin/support/encoding/js.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 telnet_connect has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def telnet_connect(host, # connection options
                                   proxy:     Telnet.proxy,
                                   port:      Telnet::DEFAULT_PORT,
                                   binmode:   false,
                                   wait_time: 0,
Severity: Minor
Found in lib/ronin/support/network/telnet/mixin.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 encode_chars has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def encode_chars(include: nil, exclude: nil)
    included  = (Chars::CharSet.new(*include) if include)
    excluded  = (Chars::CharSet.new(*exclude) if exclude)
    formatted = String.new(encoding: ::Encoding::UTF_8)

Severity: Minor
Found in lib/ronin/support/encoding/core_ext/string.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 unescape has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def self.unescape(data)
          buffer  = String.new(encoding: Encoding::UTF_8)
          scanner = StringScanner.new(data)

          until scanner.eos?
Severity: Minor
Found in lib/ronin/support/encoding/hex.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 join has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def join(*names)
        joined_path = if root? then String.new(encoding: Encoding::UTF_8)
                      else          self.to_s
                      end

Severity: Minor
Found in lib/ronin/support/path.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 encode_bytes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

  def encode_bytes(include: nil, exclude: nil)
    included  = (Chars::CharSet.new(*include) if include)
    excluded  = (Chars::CharSet.new(*exclude) if exclude)
    formatted = String.new(encoding: ::Encoding::UTF_8)

Severity: Minor
Found in lib/ronin/support/encoding/core_ext/string.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

Severity
Category
Status
Source
Language