Showing 18 of 18 total issues
Class Session
has 28 methods (exceeds 20 allowed). Consider refactoring. Open
class Session
include Error
include ListPath
Method read_and_execute_commands
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def read_and_execute_commands
catch :done do
begin
reply "220 #{server_name_and_version}"
loop do
- 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 option_parser
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
def option_parser
OptionParser.new do |op|
op.on('-p', '--port N', Integer, 'Bind to a specific port') do |t|
@port = t
end
Method make_server_thread
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def make_server_thread
Thread.new do
Thread.abort_on_exception = true
loop do
begin
- 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 standard_command_handlers
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.standard_command_handlers
[
CmdAbor,
CmdAllo,
CmdAppe,
Method cmd_port
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def cmd_port(argument)
ensure_logged_in
ensure_not_epsv_all
pieces = argument.split(/,/)
syntax_error unless pieces.size == 6
- 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 triad
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def triad(read_bit, write_bit, execute_bit, special_bit, special_letters)
Method initialize
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def initialize(user, password, account, data_dir, read_only)
Similar blocks of code found in 2 locations. Consider refactoring. Open
def cmd_stru(argument)
syntax_error unless argument
ensure_logged_in
name, implemented = FILE_STRUCTURES[argument]
error "Invalid structure code", 504 unless name
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 31.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
def cmd_mode(argument)
syntax_error unless argument
ensure_logged_in
name, implemented = TRANSMISSION_MODES[argument]
error "Invalid mode code", 504 unless name
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 31.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method cmd_mode
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cmd_mode(argument)
syntax_error unless argument
ensure_logged_in
name, implemented = TRANSMISSION_MODES[argument]
error "Invalid mode code", 504 unless name
- 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 cmd_epsv
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cmd_epsv(argument)
ensure_logged_in
if data_server
reply "200 Already in passive mode"
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 open_data_connection
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def open_data_connection(path_to_advertise = nil, &block)
send_start_of_data_connection_reply(path_to_advertise)
if data_server
if encrypt_data?
open_passive_tls_data_connection(&block)
- 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 cmd_prot
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cmd_prot(level_arg)
level_code = level_arg.upcase
unless protection_buffer_size_set
error "PROT must be preceded by PBSZ", 503
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 cmd_stru
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cmd_stru(argument)
syntax_error unless argument
ensure_logged_in
name, implemented = FILE_STRUCTURES[argument]
error "Invalid structure code", 504 unless name
- 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 stop_track
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def stop_track(socket)
@mutex.synchronize do
ip = @socket_ips.delete(socket.object_id)
break unless ip
if (@connections[ip] -= 1) == 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 cmd_pbsz
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def cmd_pbsz(buffer_size)
ensure_tls_supported
syntax_error unless buffer_size =~ /^\d+$/
buffer_size = buffer_size.to_i
unless socket.encrypted?
- 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 converted_chunk
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def converted_chunk(io)
chunk = io.read(CHUNK_SIZE)
return unless chunk
if data_type == 'A'
next_char = io.getc
- 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"