Showing 52 of 54 total issues

Method validate_base_type has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

      def validate_base_type(base_type, sub_type)
        case base_type
        when "string"

          # string can not have any suffix
Severity: Minor
Found in lib/eth/abi/type.rb - About 5 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 type has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

      def type(type, arg)
        if %w(string bytes).include?(type.base_type) and type.sub_type.empty?
          # Case: decoding a string/bytes
          if type.dimensions.empty?
            l = Util.deserialize_big_endian_to_int arg[0, 32]
Severity: Minor
Found in lib/eth/abi/decoder.rb - About 3 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 Client has 30 methods (exceeds 20 allowed). Consider refactoring.
Open

  class Client

    # The client's RPC-request ID starting at 0.
    attr_reader :id

Severity: Minor
Found in lib/eth/client.rb - About 3 hrs to fix

    Method type has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
    Open

          def type(type, arg)
            if %w(string bytes).include? type.base_type and type.sub_type.empty? and type.dimensions.empty?
              raise EncodingError, "Argument must be a String" unless arg.instance_of? String
    
              # encodes strings and bytes
    Severity: Minor
    Found in lib/eth/abi/encoder.rb - About 3 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 api.rb has 292 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Eth
    
      # Provides the `Eth::Api` module grouping known RPC commands.
      module Api
    
    
    Severity: Minor
    Found in lib/eth/api.rb - About 3 hrs to fix

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

            def to_s
              if base_type == "tuple"
                "(" + components.map(&:to_s).join(",") + ")" + (dimensions.size > 0 ? dimensions.map { |x| "[#{x == 0 ? "" : x}]" }.join : "")
              elsif dimensions.empty?
                if %w[string bytes].include?(base_type) && sub_type.empty?
      Severity: Minor
      Found in lib/eth/abi/type.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 tuple has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

            def tuple(arg, type)
              raise EncodingError, "Expecting Hash: #{arg}" unless arg.instance_of? Hash
              raise EncodingError, "Expecting #{type.components.size} elements: #{arg}" unless arg.size == type.components.size
      
              static_size = 0
      Severity: Minor
      Found in lib/eth/abi/encoder.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 Encrypter has 22 methods (exceeds 20 allowed). Consider refactoring.
      Open

        class Key::Encrypter
      
          # Provides a specific encrypter error if decryption fails.
          class EncrypterError < StandardError; end
      
      
      Severity: Minor
      Found in lib/eth/key/encrypter.rb - About 2 hrs to fix

        File client.rb has 255 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        module Eth
        
          # Provides the {Eth::Client} super-class to connect to Ethereum
          # network's RPC-API endpoints (IPC or HTTP).
          class Client
        Severity: Minor
        Found in lib/eth/client.rb - About 2 hrs to fix

          Method type has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def type(type, arg)
                  if %w(string bytes).include?(type.base_type) and type.sub_type.empty?
                    # Case: decoding a string/bytes
                    if type.dimensions.empty?
                      l = Util.deserialize_big_endian_to_int arg[0, 32]
          Severity: Minor
          Found in lib/eth/abi/decoder.rb - About 1 hr to fix

            Method decode has 43 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def decode(hex)
                    hex = Util.remove_hex_prefix hex
                    type = hex[0, 2]
                    raise TransactionTypeError, "Invalid transaction type #{type}!" if type.to_i(16) != TYPE_1559
            
            
            Severity: Minor
            Found in lib/eth/tx/eip1559.rb - About 1 hr to fix

              Method decode has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def decode(hex)
                      hex = Util.remove_hex_prefix hex
                      type = hex[0, 2]
                      raise TransactionTypeError, "Invalid transaction type #{type}!" if type.to_i(16) != TYPE_2930
              
              
              Severity: Minor
              Found in lib/eth/tx/eip2930.rb - About 1 hr to fix

                Method type has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def type(type, arg)
                        if %w(string bytes).include? type.base_type and type.sub_type.empty? and type.dimensions.empty?
                          raise EncodingError, "Argument must be a String" unless arg.instance_of? String
                
                          # encodes strings and bytes
                Severity: Minor
                Found in lib/eth/abi/encoder.rb - About 1 hr to fix

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

                      def decode(types, data)
                  
                        # accept hex abi but decode it first
                        data = Util.hex_to_bin data if Util.hex? data
                  
                  
                  Severity: Minor
                  Found in lib/eth/abi.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 verify has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def verify(blob, signature, public_key, chain_id = Chain::ETHEREUM)
                        recovered_key = nil
                        if blob.instance_of? Array or blob.instance_of? Hash
                  
                          # recover Array from sign_typed_data
                  Severity: Minor
                  Found in lib/eth/signature.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 consume_length_prefix has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def consume_length_prefix(rlp, start)
                          b0 = rlp[start].ord
                          if b0 < Constant::PRIMITIVE_PREFIX_OFFSET
                  
                            # single byte
                  Severity: Minor
                  Found in lib/eth/rlp/decoder.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 decode has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def decode(types, data)
                  
                        # accept hex abi but decode it first
                        data = Util.hex_to_bin data if Util.hex? data
                  
                  
                  Severity: Minor
                  Found in lib/eth/abi.rb - About 1 hr to fix

                    Method decode_log has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                          def decode_log(inputs, data, topics, anonymous = false)
                            topic_inputs, data_inputs = inputs.partition { |i| i["indexed"] }
                    
                            topic_types = topic_inputs.map do |i|
                              if i["type"] == "tuple"
                    Severity: Minor
                    Found in lib/eth/abi/event.rb - About 1 hr to fix

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

                            def primitive_type(type, data)
                              case type.base_type
                              when "address"
                      
                                # decoded address with 0x-prefix
                      Severity: Minor
                      Found in lib/eth/abi/decoder.rb - About 1 hr to fix

                        Method data has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            def data
                              # default to pbkdf2
                              kdfparams = if kdf == "scrypt"
                                  {
                                    dklen: 32,
                        Severity: Minor
                        Found in lib/eth/key/encrypter.rb - About 1 hr to fix
                          Severity
                          Category
                          Status
                          Source
                          Language