promiscuous-io/promiscuous

View on GitHub

Showing 27 of 27 total issues

Method _configure has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

  def self._configure(&block)
    block.call(self) if block

    self.app                  ||= Rails.application.class.parent_name.underscore rescue nil if defined?(Rails)
    self.backend              ||= best_amqp_backend
Severity: Minor
Found in lib/promiscuous/config.rb - About 5 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 parse_args has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_args(args)
    options = {}

    require 'optparse'
    parser = OptionParser.new do |opts|
Severity: Minor
Found in lib/promiscuous/cli.rb - About 3 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 connection has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def connection
      connection_without_promiscuous.tap do |connection|
        unless defined?(connection.promiscuous_hook)
          connection.class.class_eval do
            attr_accessor :current_transaction_id
Severity: Major
Found in lib/promiscuous/publisher/operation/active_record.rb - About 2 hrs to fix

    Method parse_args has 62 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def parse_args(args)
        options = {}
    
        require 'optparse'
        parser = OptionParser.new do |opts|
    Severity: Major
    Found in lib/promiscuous/cli.rb - About 2 hrs to fix

      Method subscribe has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
      Open

          def subscribe(options={}, &block)
            file_name, worker_index, num_workers = Promiscuous::Config.subscriber_amqp_url.split(':')
      
            worker_index = worker_index.to_i
            num_workers = num_workers.to_i
      Severity: Minor
      Found in lib/promiscuous/amqp/file.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

      Class Bunny has 21 methods (exceeds 20 allowed). Consider refactoring.
      Open

      class Promiscuous::AMQP::Bunny
        def self.hijack_bunny
          return if @bunny_hijacked
          ::Bunny::Session.class_eval do
            alias_method :handle_network_failure_without_promiscuous, :handle_network_failure
      Severity: Minor
      Found in lib/promiscuous/amqp/bunny.rb - About 2 hrs to fix

        Method _configure has 39 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def self._configure(&block)
            block.call(self) if block
        
            self.app                  ||= Rails.application.class.parent_name.underscore rescue nil if defined?(Rails)
            self.backend              ||= best_amqp_backend
        Severity: Minor
        Found in lib/promiscuous/config.rb - About 1 hr to fix

          Method __promiscuous_update has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

            def __promiscuous_update(payload, options={})
              self.class.subscribed_attrs.map(&:to_s).each do |attr|
                unless payload.attributes.has_key?(attr)
                  "Attribute '#{attr}' is missing from the payload".tap do |error_msg|
                    Promiscuous.warn "[receive] #{error_msg}"
          Severity: Minor
          Found in lib/promiscuous/subscriber/model/base.rb - About 1 hr 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 fork has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def fork(&block)
                  return fork_without_promiscuous(&block) unless Promiscuous.should_be_connected?
          
                  Promiscuous.disconnect
                  pid = if block
          Severity: Minor
          Found in lib/promiscuous/config.rb - About 1 hr 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 trap_debug_signals has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def trap_debug_signals
              Signal.trap 'SIGUSR2' do
                # Using a thread because we cannot acquire mutexes in a trap context in
                # ruby 2.0
                Thread.new do
          Severity: Minor
          Found in lib/promiscuous/cli.rb - About 1 hr 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 publish has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def publish(options={})
              raise "Exchange '#{options[:exchange]}' not one of: #{@exchanges.keys}" unless @exchanges[options[:exchange]]
          
              Promiscuous.debug "[publish] #{options[:exchange]}/#{options[:key]} #{options[:payload]}"
          
          
          Severity: Minor
          Found in lib/promiscuous/amqp/bunny.rb - About 1 hr 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 update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

            def update(change, flags=nil)
              update_op = promiscuous_write_operation(:update, :change => change)
          
              if flags && update_op.should_instrument_query?
                raise "You cannot do a multi update. Instead, update each document separately." if flags.include?(:multi)
          Severity: Minor
          Found in lib/promiscuous/publisher/operation/mongoid.rb - About 1 hr 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 set_test_mode has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.set_test_mode
              if self.test_mode.nil?
                defined?(Rails) ? Rails.env.test? ? true : false : false
              else
                self.test_mode
          Severity: Minor
          Found in lib/promiscuous/config.rb - About 55 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

          Method initialize has 7 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def initialize(arel, name, pk, id_value, sequence_name, binds, options={})
          Severity: Major
          Found in lib/promiscuous/publisher/operation/active_record.rb - About 50 mins to fix

            Method update has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def update(should_create_on_failure=true)
                model.__promiscuous_fetch_existing(id).tap do |instance|
                  if instance.__promiscuous_eventual_consistency_update(self)
                    instance.__promiscuous_update(self)
                    instance.save!
            Severity: Minor
            Found in lib/promiscuous/subscriber/operation.rb - About 45 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

            Method modify has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def modify(change, options={})
                promiscuous_write_operation(:update, :change => change).execute do |query|
                  query.non_instrumented { super }
                  query.instrumented do |op|
                    raise "You can only use find_and_modify() with :new => true" if !options[:new]
            Severity: Minor
            Found in lib/promiscuous/publisher/operation/mongoid.rb - About 45 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

            Method __promiscuous_fetch_existing has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                def __promiscuous_fetch_existing(id)
                  key = subscribe_foreign_key
                  instance = if respond_to?("find_by")
                    promiscuous_root_class.find_by(key => id)
                  else
            Severity: Minor
            Found in lib/promiscuous/subscriber/model/mongoid.rb - About 45 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

            Method on_confirm has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

              def on_confirm(tag, multiple, nack=false)
                if multiple
                  cbs = @callback_mapping.keys
                          .select { |k| k <= tag }
                          .map    { |k| @callback_mapping.delete(k) }
            Severity: Minor
            Found in lib/promiscuous/amqp/bunny.rb - About 45 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

            Method publish has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def publish
                options[:criterias].map { |criteria| eval(criteria) }.each do |criteria|
                  break if @stop
                  title = criteria.name
                  title = "#{title}#{' ' * [0, 20 - title.size].max}"
            Severity: Minor
            Found in lib/promiscuous/cli.rb - About 35 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

            Method main_loop has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

              def main_loop(options={})
                Thread.current[:promiscuous_timer_instance] = self
                options = options.dup
            
                loop do
            Severity: Minor
            Found in lib/promiscuous/timer.rb - About 35 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

            Severity
            Category
            Status
            Source
            Language