Showing 612 of 612 total issues
Method restat
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def restat
trace :info, "Recalculating stats for #{self._kind} #{self.name}"
t = Time.now
case self._kind
when 'operation'
Method run
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def self.run(options)
begin
c = CoreDeveloper.new
c.name = options[: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 create
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def create
require_auth_level :view
require_auth_level :view_profiles
return conflict('LICENSE_LIMIT_REACHED') unless LicenseManager.instance.check :intelligence
- 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 act!
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def act!
# check we have a valid action
return bad_request if @request[:action].nil?
# make a copy of the params, handy for access and mongoid queries
- 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 process
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def process
self[:wav] = []
return if self[:data][:grid_content].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 upgrade!
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def upgrade!(params)
raise "Cannot determine agent version" if self.version.nil?
# delete any pending upgrade if requested multiple time
self.upgrade_requests.destroy_all if self.upgradable
- 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 a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def run
raise MissingAgentError.new("Unable to run instance worker #{@agent_uid}, agent is missing or closed") unless agent?
trace(:info, "[#{@agent_uid}] Evidence processing started for agent #{agent.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 generate
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def generate(params)
trace :debug, "Build: generate: #{params}"
# force demo if the RMI is in demo
params['binary']['demo'] = true if LicenseManager.instance.limits[:rmi][1]
Method run!
has 38 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 filter_for_partial_backup
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.filter_for_partial_backup(params)
# extract the id from the string
id = Moped::BSON::ObjectId.from_string(params[:what][-24..-1])
Similar blocks of code found in 2 locations. Consider refactoring. Open
def update
require_auth_level :sys
require_auth_level :sys_injectors
mongoid_query do
- 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 63.
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 update
require_auth_level :sys
require_auth_level :sys_frontend
mongoid_query do
- 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 63.
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 burn_one_license
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def burn_one_license(type, platform)
# check if the platform can be used
unless @limits[:agents][platform][0]
trace :warn, "You don't have a license for #{platform.to_s}. Queuing agent..."
Method offload_move_evidence
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.offload_move_evidence(params)
old_target = ::Item.find(params[:old_target_id])
target = ::Item.find(params[:target_id])
agent = ::Item.find(params[:agent_id])
Method most_contacted
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
def self.most_contacted(target_id, params)
start = Time.now
most_contacted_types = [:chat, :mail, :sms, :mms, :facebook,
:gmail, :skype, :bbm, :whatsapp, :msn, :adium,
:viber, :outlook, :wechat, :line, :phone]
Method melt
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def melt(params)
trace :debug, "Build: melting: #{params}"
# open the install.sh dropper and patch the value of the files to be installed
file = File.open(path('install.sh'), 'rb+')
Method setup
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def setup(port = 443)
# main EventMachine loop
begin
Method add_limits
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def add_limits(limit)
@limits[:magic] = limit[:check]
@limits[:type] = limit[:type]
Method destroy_callback
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
def destroy_callback
# remove the item form any dashboard or recent
::User.all.each {|u| u.delete_item(self._id)}
# remove the item form the alerts
::Alert.all.each {|a| a.delete_if_item(self._id)}
Method extract_call
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def self.extract_call(ev)
data = []
versus = ev.data['incoming'] == 1 ? :in : :out
hash = {:time => ev.da, :versus => versus, :type => ev.data['program'].downcase.to_sym, :size => ev.data['duration'].to_i}
bidirectional = hash[:type] == :skype
- 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"