taganaka/polipus

View on GitHub
lib/polipus.rb

Summary

Maintainability
D
3 days
Test Coverage

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?
Severity: Minor
Found in lib/polipus.rb - About 1 day to fix

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'
Severity: Minor
Found in lib/polipus.rb - About 4 hrs to fix

    Class PolipusCrawler has 33 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class PolipusCrawler
        OPTS = {
          # run 4 threads
          workers: 4,
          # identify self as Polipus/VERSION
    Severity: Minor
    Found in lib/polipus.rb - About 4 hrs to fix

      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?
      Severity: Major
      Found in lib/polipus.rb - About 3 hrs to fix

        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)
        Severity: Minor
        Found in lib/polipus.rb - About 2 hrs to fix

        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)
        Severity: Minor
        Found in lib/polipus.rb - About 1 hr to fix

          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)
          Severity: Minor
          Found in lib/polipus.rb - About 25 mins to fix

          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

          There are no issues that match your filters.

          Category
          Status