ronin-rb/ronin-support

View on GitHub

Showing 114 of 202 total issues

Class IP has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

      class IP < IPAddr

        # A regular expression for matching IP addresses.
        #
        # @since 1.1.0
Severity: Minor
Found in lib/ronin/support/network/ip.rb - About 2 hrs to fix

    Method initialize has 70 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

                def initialize(types)
                  super(types)
    
                  if types::ADDRESS_SIZE == 8
                    # NOTE: `long` and `unsigne long` are actually 4 bytes on
    Severity: Major
    Found in lib/ronin/support/binary/ctypes/os/windows.rb - About 2 hrs to fix

      Method run has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

              def run
                io_array = [@io, @stdin]
      
                loop do
                  readable, _writable, errors = IO.select(io_array,nil,io_array)
      Severity: Minor
      Found in lib/ronin/support/cli/io_shell.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

      Class Struct has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

            class Struct < Memory
      
              # The type system used by the struct.
              #
              # @return [CTypes::StructType]
      Severity: Minor
      Found in lib/ronin/support/binary/struct.rb - About 2 hrs to fix

        Method generate has a Cognitive Complexity of 16 (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 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

        Consider simplifying this complex logical expression.
        Open

                    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)
                    end
        Severity: Critical
        Found in lib/ronin/support/encoding/uri.rb - About 2 hrs to fix

          Consider simplifying this complex logical expression.
          Open

                      if (byte == 45) || (byte == 46) || ((byte >= 48) && (byte <= 57)) || ((byte >= 65) && (byte <= 90)) || (byte == 95) || ((byte >= 97) && (byte <= 122)) || (byte == 126)
                        byte.chr
                      elsif byte == 0x20
                        '+'
                      else
          Severity: Critical
          Found in lib/ronin/support/encoding/http.rb - About 2 hrs to fix

            Method build has 48 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                      def self.build(method,path, # query string keyword arguments
                                                  query:        nil,
                                                  query_params: nil,
                                                  # Basic-Auth keyword arguments
                                                  user:     nil,
            Severity: Minor
            Found in lib/ronin/support/network/http/request.rb - About 1 hr to fix

              Method build has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                        def self.build(fields, alignment: nil, padding: true)
                          members       = {}
                          max_alignment = 0
                          pack_string   = String.new(encoding: Encoding::ASCII_8BIT)
              
              
              Severity: Minor
              Found in lib/ronin/support/binary/ctypes/struct_type.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 read_string has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
              Open

                        def read_string(length=nil)
                          new_string = if (encoding = external_encoding)
                                         String.new('', encoding: encoding)
                                       else
                                         String.new('')
              Severity: Minor
              Found in lib/ronin/support/binary/stream/methods.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 parse has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                        def parse(hexdump)
                          return enum_for(__method__,hexdump) unless block_given?
              
                          previous_address = nil
                          first_address    = nil
              Severity: Minor
              Found in lib/ronin/support/binary/unhexdump/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 encode_byte has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                      def self.encode_byte(byte, format: :decimal, zero_pad: false, **kwargs)
                        case format
                        when :decimal
                          if zero_pad then "&#%.7d;" % byte
                          else             "&#%d;" % byte
              Severity: Minor
              Found in lib/ronin/support/encoding/xml.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 escape_byte has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
              Open

                      def self.escape_byte(byte,**kwargs)
                        if (byte >= 0) && (byte <= 0xff)
                          if (byte == 45) || (byte == 46) || ((byte >= 48) && (byte <= 57)) || ((byte >= 65) && (byte <= 90)) || (byte == 95) || ((byte >= 97) && (byte <= 122)) || (byte == 126)
                            byte.chr
                          elsif byte == 0x20
              Severity: Minor
              Found in lib/ronin/support/encoding/http.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 generate has 43 lines of code (exceeds 25 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 1 hr to fix

                Method escape_byte has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                Open

                        def self.escape_byte(byte,**kwargs)
                          if (byte >= 0) && (byte <= 0xff)
                            if (byte == 33) || (byte == 36) || (byte == 38) || ((byte >= 39) && (byte <= 59)) || (byte == 61) || ((byte >= 63) && (byte <= 91)) || (byte == 93) || (byte == 95) || ((byte >= 97) && (byte <= 122)) || (byte == 126)
                              byte.chr
                            else
                Severity: Minor
                Found in lib/ronin/support/encoding/uri.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 generator has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                        def self.generator(**kwargs)
                          if kwargs.empty?
                            DEFAULT
                          else
                            rules = []
                Severity: Minor
                Found in lib/ronin/support/text/typo.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 poll has 33 lines of code (exceeds 25 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 1 hr to fix

                  Method each has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                  Open

                            def each
                              return enum_for(__method__) unless block_given?
                  
                              io = IO.popen(command_argv('-v','-l',@path))
                  
                  
                  Severity: Minor
                  Found in lib/ronin/support/archive/zip/reader.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 context has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                          def self.context(version:     nil,
                                           min_version: nil,
                                           max_version: nil,
                                           verify:      :none,
                                           key:         nil,
                  Severity: Minor
                  Found in lib/ronin/support/network/ssl.rb - About 1 hr to fix

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

                              def parse(hexdump)
                                return enum_for(__method__,hexdump) unless block_given?
                    
                                previous_address = nil
                                first_address    = nil
                    Severity: Minor
                    Found in lib/ronin/support/binary/unhexdump/parser.rb - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language