Showing 50 of 54 total issues

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

      def decode(hex)
        bin = Util.hex_to_bin hex
        tx = Rlp.decode bin

        # decoded transactions always have 9 fields, even if they are empty or zero
Severity: Minor
Found in lib/eth/tx/legacy.rb - About 1 hr to fix

    Method decode_log has a Cognitive Complexity of 10 (exceeds 5 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

    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 primitive_type has a Cognitive Complexity of 10 (exceeds 5 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

    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 new has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        def new(params, chain_id = Chain::ETHEREUM)
    
          # if we deal with max gas fee parameter, attempt EIP-1559
          unless params[:max_gas_fee].nil?
            params[:chain_id] = chain_id if params[:chain_id].nil?
    Severity: Minor
    Found in lib/eth/tx.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 validate_base_type has 27 lines of code (exceeds 25 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 1 hr to fix

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

          def enforce_typed_data(data)
            data = JSON.parse data if Util.hex? data
            raise TypedDataError, "Data is missing, try again with data." if data.nil? or data.empty?
            raise TypedDataError, "Data types are missing." if data[:types].nil? or data[:types].empty?
            raise TypedDataError, "Data primaryType is missing." if data[:primaryType].nil? or data[:primaryType].empty?
      Severity: Minor
      Found in lib/eth/eip712.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 serialize has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

              def serialize(obj)
                raise SerializationError, "Can only serialize integers" unless obj.is_a?(Integer)
                raise SerializationError, "Cannot serialize negative integers" if obj < 0
                raise SerializationError, "Integer too large (does not fit in #{@size} bytes)" if @size && obj >= 256 ** @size
                s = obj == 0 ? Constant::BYTE_EMPTY : Util.int_to_big_endian(obj)
      Severity: Minor
      Found in lib/eth/rlp/sedes/big_endian_int.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 validate_params has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
      Open

          def validate_params(fields)
            if fields[:nonce].nil? or fields[:nonce] < 0
              raise ParameterError, "Invalid signer nonce #{fields[:nonce]}!"
            end
            if fields[:gas_limit].nil? or
      Severity: Minor
      Found in lib/eth/tx.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 encode_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def encode_data(primary_type, data, types)
      
            # first data field is the type hash
            encoded_types = ["bytes32"]
            encoded_values = [hash_type(primary_type, types)]
      Severity: Minor
      Found in lib/eth/eip712.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 send_transaction has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def send_transaction(params, legacy, key, nonce)
            if legacy
              params.merge!({ gas_price: max_fee_per_gas })
            else
              params.merge!({
      Severity: Minor
      Found in lib/eth/client.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 marshal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def marshal(params)
            params = params.dup
            if params.is_a? Array
              params.map! { |param| marshal(param) }
            elsif params.is_a? Hash
      Severity: Minor
      Found in lib/eth/client.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 initialize has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(base_type, sub_type, dimensions, components = nil, component_name = nil)
      Severity: Minor
      Found in lib/eth/abi/type.rb - About 35 mins to fix

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

              def bytes(arg, type)
                raise EncodingError, "Expecting String: #{arg}" unless arg.instance_of? String
                arg = handle_hex_string arg, type
        
                if type.sub_type.empty?
        Severity: Minor
        Found in lib/eth/abi/encoder.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 encode has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def encode(types, args)
        
              # parse all types
              parsed_types = types.map { |t| Type === t ? t : Type.parse(t) }
        
        
        Severity: Minor
        Found in lib/eth/abi.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 uint has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def uint(arg, type)
                raise ArgumentError, "Don't know how to handle this input." unless arg.is_a? Numeric
                raise ValueOutOfBounds, "Number out of range: #{arg}" if arg > Constant::UINT_MAX or arg < Constant::UINT_MIN
                real_size = type.sub_type.to_i
                i = arg.to_i
        Severity: Minor
        Found in lib/eth/abi/encoder.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 size has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def size
                s = nil
                if dimensions.empty?
                  if !(["string", "bytes", "tuple"].include?(base_type) and sub_type.empty?)
                    s = 32
        Severity: Minor
        Found in lib/eth/abi/type.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 sign has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def sign(key)
                if Tx.signed? self
                  raise Signature::SignatureError, "Transaction is already signed!"
                end
        
        
        Severity: Minor
        Found in lib/eth/tx/eip2930.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 estimate_intrinsic_gas has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def estimate_intrinsic_gas(data = "", list = [])
              gas = DEFAULT_GAS_LIMIT
              unless data.nil? or data.empty?
                data = Util.hex_to_bin data if Util.hex? data
        
        
        Severity: Minor
        Found in lib/eth/tx.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 sign has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def sign(key)
                if Tx.signed? self
                  raise Signature::SignatureError, "Transaction is already signed!"
                end
        
        
        Severity: Minor
        Found in lib/eth/tx/legacy.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 sign has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            def sign(blob, chain_id = nil)
              context = Secp256k1::Context.new
              compact, recovery_id = context.sign_recoverable(@private_key, blob).compact
              signature = compact.bytes
              v = Chain.to_v recovery_id, chain_id
        Severity: Minor
        Found in lib/eth/key.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

        Severity
        Category
        Status
        Source
        Language