Showing 209 of 209 total issues
Method authenticate_elite
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def self.authenticate_elite(peer, uri, content, anon_version)
trace :info, "[#{peer}] Authentication required for (#{content.length.to_s} bytes)..."
# integrity check (104 byte of data, 112 padded)
# consider random extra data to disguise the protocol
- 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 perform
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def perform
# if the database connection has gone
# try to re-login to the database again
unless DB.instance.connected?
trace :debug, "heartbeat: try to reconnect to rcs-db"
- 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 protocol_send_command
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
def protocol_send_command(command)
# retrieve the receiver anon
receiver = @anonymizers.select{|x| x['_id'].eql? command['anon']}.first
raise "Cannot send to unknown anon [#{command['anon']}]" unless receiver
Method command_id
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def command_id(peer, session, message)
# agent version
version = message.slice!(0..3).unpack('I').first
Method run
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def run
# infinite loop for working
loop do
# pass the control to other threads
sleep 1
- 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 run
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
# infinite loop for working
loop do
# pass the control to other threads
sleep 1
Method cache_init
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
def cache_init
# if the db is available, clear the cache and populate it again
if @available
# get the global signature (per customer) for all the agents
bck_sig = db_rest_call :agent_signature
Method prepare_response
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def prepare_response(connection, request)
@request = request
@connection = connection
@response = EM::DelegatedHttpResponse.new @connection
Method load_from_file
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def load_from_file
trace :info, "Loading configuration file..."
conf_file = File.join Dir.pwd, CONF_DIR, CONF_FILE
# load the config in the @global hash
- 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 create_repository
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def create_repository(session)
# ensure the repository directory is present
Dir::mkdir(REPO_DIR) if not File.directory?(REPO_DIR)
trace :info, "Creating repository for [#{session[:ident]}_#{session[:instance]}]"
Method commands
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.commands(peer, cookie, content)
# retrieve the session
session = SessionManager.instance.get cookie
# invalid session
Method process_http_request
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process_http_request
# get the peer of the communication
# if direct or thru an anonymizer
peer = http_get_forwarded_peer(@http)
Method http_get_os
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def http_get_os(headers)
# extract the user-agent
user_agent = headers[:user_agent]
return 'unknown', '' if user_agent.nil?
Method print_total
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def print_total
puts "Total Statistics from: #{@stats[:total][:start]}"
table_width = 0
@stats[:total].each_key do |k|
- 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 print_total
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def print_total
puts "Total Statistics from: #{@stats[:total][:start]}"
table_width = 0
@stats[:total].each_key do |k|
- 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 http_put_file
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
def http_put_file(uri, content)
begin
path = Dir.pwd + PUBLIC_DIR
# split the path in all the subdir and the filename
Similar blocks of code found in 2 locations. Consider refactoring. Open
EvidenceManager.instance.store_evidence session, size, message
# remember the statistics for input evidence
StatsManager.instance.add ev_input: 1, ev_input_size: size
- 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 57.
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
EvidenceManager.instance.store_evidence session, size, evidence
# remember the statistics for input evidence
StatsManager.instance.add ev_input: 1, ev_input_size: size
- 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 57.
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
if user_agent['BlackBerry']
major = 4
minor = 5
ver_tuple = user_agent.scan(/\/(\d+)\.(\d+)\.\d+/).flatten
major, minor = ver_tuple unless ver_tuple.empty?
- 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 56.
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
if user_agent['Android']
major = 4
minor = 0
ver_tuple = user_agent.scan(/Android (\d+)\.(\d+)/).flatten
major, minor = ver_tuple unless ver_tuple.empty?
- 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 56.
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