File query.rb
has 297 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'ruby_smb/server/share/provider/processor'
module RubySMB
class Server
module Share
Method transaction2_smb1_find_first2
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def transaction2_smb1_find_first2(request)
# see: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/f93455dc-2bd7-4698-b91e-8c9c7abd63cf
raise ArgumentError unless request.data_block.trans2_parameters.is_a? SMB1::Packet::Trans2::FindFirst2RequestTrans2Parameters
subdir, _, search_pattern = request.data_block.trans2_parameters.filename.encode.gsub('\\', File::SEPARATOR).rpartition(File::SEPARATOR)
- 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_query_directory_smb2
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def do_query_directory_smb2(request)
local_path = get_local_path(request.file_id)
if local_path.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"
Further reading
Method do_query_directory_smb2
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_query_directory_smb2(request)
local_path = get_local_path(request.file_id)
if local_path.nil?
response = RubySMB::SMB2::Packet::ErrorPacket.new
response.smb2_header.nt_status = WindowsError::NTStatus::STATUS_FILE_CLOSED
Method transaction2_smb1_query_information
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def transaction2_smb1_query_information(request, response, local_path)
unless local_path&.exist?
response = SMB1::Packet::EmptyPacket.new
response.smb_header.nt_status = WindowsError::NTStatus::STATUS_NO_SUCH_FILE
return response
- 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 transaction2_smb1_find_first2
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
def transaction2_smb1_find_first2(request)
# see: https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/f93455dc-2bd7-4698-b91e-8c9c7abd63cf
raise ArgumentError unless request.data_block.trans2_parameters.is_a? SMB1::Packet::Trans2::FindFirst2RequestTrans2Parameters
subdir, _, search_pattern = request.data_block.trans2_parameters.filename.encode.gsub('\\', File::SEPARATOR).rpartition(File::SEPARATOR)
Method consume_dirents
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def consume_dirents(local_path, dirents, filter_regex: nil)
until dirents.empty?
dirent = dirents.shift
next unless dirent.file? || dirent.directory? # filter out everything but files and directories
- 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_transactions2_smb1
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def do_transactions2_smb1(request)
# can't find an example where more than one setup is set, this code makes alot of assumptions that there
# are exactly 0 or 1 entries
if request.parameter_block.setup.length > 1
raise NotImplementedError, 'There are more than 1 TRANSACTION2 setup values'
Method do_transactions2_smb1
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def do_transactions2_smb1(request)
# can't find an example where more than one setup is set, this code makes alot of assumptions that there
# are exactly 0 or 1 entries
if request.parameter_block.setup.length > 1
raise NotImplementedError, 'There are more than 1 TRANSACTION2 setup values'
- 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"