Showing 174 of 307 total issues
Method read_and_return_value
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def read_and_return_value(io)
max_length = eval_parameter(:max_length)
if max_length && max_length % 2 != 0
raise ArgumentError, "[Stringz16] #max_length should be a multiple of "\
"two, since it is Unicode (got #{max_length})"
- 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 bytes_to_align
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def bytes_to_align(obj, rel_offset)
if obj.is_a?(PointerPlugin)
# Pointers are always 4-bytes aligned
return (4 - (rel_offset % 4)) % 4
end
- 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 method_missing
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def method_missing(symbol, *args)
# should we forward to one of the stat methods
if STAT_METHODS.include?(symbol)
# if we have a stat object then forward it
return stat.send(symbol, *args) if exist?
- 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 enum_registry_values
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def enum_registry_values(key, bind: true)
bind(endpoint: RubySMB::Dcerpc::Winreg) if bind
root_key, sub_key = key.gsub(/\//, '\\').split('\\', 2)
root_key_handle = open_root_key(root_key)
- 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 decrypt
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def decrypt(key, algorithm: 'AES-128-GCM')
auth_data = self.to_binary_s[20...52]
encrypted_data = self.encrypted_data.to_ary.pack('C*')
case algorithm
- 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 open_directory_packet
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def open_directory_packet(directory: nil, disposition: RubySMB::Dispositions::FILE_OPEN,
impersonation: RubySMB::ImpersonationLevels::SEC_IMPERSONATE,
read: true, write: false, delete: false, desired_delete: false)
create_request = RubySMB::SMB2::Packet::CreateRequest.new
create_request = set_header_fields(create_request)
- 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
Avoid too many return
statements within this method. Open
return WindowsError::NTStatus::STATUS_LOGON_FAILURE
Method sum_num_bytes_below_index
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def sum_num_bytes_below_index(index)
(0...index).inject(0) do |sum, i|
nbytes = 0
if elements[i].has_parameter?(:byte_align) && elements[i].respond_to?(:bytes_to_align)
nbytes = elements[i].bytes_to_align(elements[i], sum.ceil)
- 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 build
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.build(options)
ntlm_provider = RubySMB::Gss::Provider::NTLM.new(
allow_anonymous: options[:allow_anonymous],
allow_guests: options[:allow_guests]
)
- 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 children
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def children(with_directory=true)
raise Errno::ENOTDIR.new("Not a directory @ dir_initialize - #{to_s}") unless directory?
@virtual_disk.each_value.select { |dent| dent.dirname == self && dent != self }.map { |dent| with_directory ? dent : dent.basename }
end
- 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 trim_to!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def trim_to!(str, max_length = nil)
if max_length
max_length = 2 if max_length < 2
str.slice!(max_length..-1)
if str.length == max_length && str[-2, 2] != "\0\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
Method method_missing
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.method_missing(symbol, *args, &block)
field = super
if field.is_a?(::Array) && field.last.is_a?(BinData::SanitizedField)
unless field.last.has_parameter?(:byte_align) || field.last.instantiate.bit_aligned?
raise ArgumentError.new(
- 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 query_value
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def query_value(handle, value_name)
query_value_request_packet = RubySMB::Dcerpc::Winreg::QueryValueRequest.new(hkey: handle, lp_value_name: value_name)
query_value_request_packet.lp_type = 0
query_value_request_packet.lpcb_data = 0
query_value_request_packet.lpcb_len = 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
Method add_dynamic_file
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def add_dynamic_file(path, stat: nil, &block)
raise ArgumentError.new('a block must be specified for dynamic files') unless block_given?
path = VirtualPathname.cleanpath(path)
path = File::SEPARATOR + path unless path.start_with?(File::SEPARATOR)
raise ArgumentError.new('must be a file') if stat && !stat.file?
- 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 smb3_decrypt
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def smb3_decrypt(th)
unless @server_encryption_key
raise RubySMB::Error::EncryptionError.new('The encryption algorithm has not been set') if @encryption_algorithm.nil?
key_bit_len = OpenSSL::Cipher.new(@encryption_algorithm).key_len * 8
- 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 read
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def self.read(val)
begin
super(val)
rescue IOError => e
# $stderr.puts "#{e.class}: #{e.message}"
- 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 bind
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def bind(options={})
@call_id ||= 1
bind_req = Bind.new(options)
bind_req.pdu_header.call_id = @call_id
auth_type = options.fetch(:auth_type) { RPC_C_AUTHN_WINNT }
- 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 authenticate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def authenticate
if smb1
if username.empty? && password.empty?
smb1_anonymous_auth
else
- 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 handle_smb1
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def handle_smb1(raw_request, header)
session = @session_table[header.uid]
if session.nil? && !(header.command == SMB1::Commands::SMB_COM_SESSION_SETUP_ANDX && header.uid == 0)
response = SMB1::Packet::EmptyPacket.new
- 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 do_read_smb2
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def do_read_smb2(request)
handle = @handles[request.file_id.to_binary_s]
if handle.nil?
response = RubySMB::SMB2::Packet::ErrorPacket.new
response.smb2_header.nt_status = WindowsError::NTStatus::STATUS_FILE_CLOSED
- 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"