Showing 47 of 49 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
- Read upRead up
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
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
- Read upRead up
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 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?
- Read upRead up
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
- Read upRead up
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
Method type
has a Cognitive Complexity of 17 (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]
- Read upRead up
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 client.rb
has 253 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
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
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
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
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
- Read upRead up
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
- Read upRead up
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
- Read upRead up
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
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
Method data
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def data
# default to pbkdf2
kdfparams = if kdf == "scrypt"
{
dklen: 32,
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
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
- Read upRead up
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?
- Read upRead up
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"