Method takeover
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
def takeover
@urls.each do |u|
add_url(u) { |page| page.user_data.p_seeded = true }
end
return if internal_queue.empty?
- 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
File polipus.rb
has 341 lines of code (exceeds 250 allowed). Consider refactoring. Open
require 'redis'
require 'redis/connection/hiredis'
require 'redis-queue'
require 'polipus/version'
require 'polipus/http'
Class PolipusCrawler
has 33 methods (exceeds 20 allowed). Consider refactoring. Open
class PolipusCrawler
OPTS = {
# run 4 threads
workers: 4,
# identify self as Polipus/VERSION
Method takeover
has 77 lines of code (exceeds 25 allowed). Consider refactoring. Open
def takeover
@urls.each do |u|
add_url(u) { |page| page.user_data.p_seeded = true }
end
return if internal_queue.empty?
Method initialize
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def initialize(job_name = 'polipus', urls = [], options = {})
@job_name = job_name
@options = OPTS.merge(options)
@options[:queue_timeout] = 1 if @options[:queue_timeout] <= 0
@logger = @options[:logger] ||= Logger.new(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 initialize
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(job_name = 'polipus', urls = [], options = {})
@job_name = job_name
@options = OPTS.merge(options)
@options[:queue_timeout] = 1 if @options[:queue_timeout] <= 0
@logger = @options[:logger] ||= Logger.new(nil)
Method execute_plugin
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def execute_plugin(method)
Polipus::Plugin.plugins.each do |k, p|
next unless p.respond_to?(method)
@logger.info { "Running plugin method #{method} on #{k}" }
ret_val = p.send(method, self)
- 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"