Showing 209 of 209 total issues
File db_rest.rb
has 539 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'rcs-common/trace'
require 'rcs-common/cgi'
# system
require 'net/http'
File db_cache.rb
has 507 lines of code (exceeds 250 allowed). Consider refactoring. Open
require_relative 'sqlite'
# from RCS::Common
require 'rcs-common/trace'
Class DB
has 49 methods (exceeds 20 allowed). Consider refactoring. Open
class DB
include Singleton
include RCS::Tracer
ACTIVE_AGENT = 0
Class DB_rest
has 48 methods (exceeds 20 allowed). Consider refactoring. Open
class DB_rest
include RCS::Tracer
def initialize(host)
@host, @port = host.split(':')
Method cache_init
has a Cognitive Complexity of 38 (exceeds 5 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
- 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 DBCache
has 41 methods (exceeds 20 allowed). Consider refactoring. Open
class DBCache
extend RCS::Tracer
CACHE_FILE = Dir.pwd + '/config/cache.db'
File evidence_manager.rb
has 382 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'fileutils'
require_relative 'sqlite'
# from RCS::Common
require 'rcs-common/trace'
File db.rb
has 381 lines of code (exceeds 250 allowed). Consider refactoring. Open
require_relative 'config.rb'
require_relative 'db_rest.rb'
require_relative 'db_cache.rb'
require_relative 'my_ip.rb'
Method process_http_request
has a Cognitive Complexity of 30 (exceeds 5 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)
- 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 stream_one_chunk
has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring. Open
def stream_one_chunk
loop do
break if @connection.closed?
if @file_io.pos < @size
if @connection.get_outbound_data_size > BACKPRESSURE_LEVEL
- 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_scout
has 91 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.authenticate_scout(peer, uri, content, anon_version)
trace :info, "[#{peer}] Authentication scout required for (#{content.length.to_s} bytes)..."
begin
# remove the base64 container
Method http_get_os
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def http_get_os(headers)
# extract the user-agent
user_agent = headers[:user_agent]
return 'unknown', '' if user_agent.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"
Further reading
Method authenticate_elite
has 77 lines of code (exceeds 25 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
Similar blocks of code found in 2 locations. Consider refactoring. Open
def command_exec(peer, session, message)
trace :info, "[#{peer}][#{session[:cookie]}] Exec request"
# the exec list was already retrieved (if any) during the ident phase
# here we get just the content (locally) without asking again to the db
- 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 106.
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 command_download(peer, session, message)
trace :info, "[#{peer}][#{session[:cookie]}] Download request"
# the download list was already retrieved (if any) during the ident phase
# here we get just the content (locally) without asking again to the db
- 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 106.
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
File http_controller.rb
has 285 lines of code (exceeds 250 allowed). Consider refactoring. Open
require_relative 'sync_protocol'
require 'rcs-common/mime'
require 'rcs-common/crypt'
Identical blocks of code found in 2 locations. 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
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 101.
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
Identical blocks of code found in 2 locations. 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
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 101.
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 run!
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.run!(*argv)
# reopen the class and declare any empty trace method
# if called from command line, we don't have the trace facility
self.class_eval do
def trace(level, message)
Method run
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def run(options)
if options[:alt_log]
logfilepath = File.expand_path("../../../log/rcs-collector-config.log", __FILE__)
@logger = Log4r::Logger.new("migration").tap do |logger|
- 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"