karafka/karafka

View on GitHub

Showing 112 of 152 total issues

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

        def supported?
          # If we were not even able to load the FFI C lib, it won't be supported
          return false unless API_SUPPORTED
          # Won't work on macOS because it does not support pidfd
          return false if RUBY_DESCRIPTION.include?('darwin')
Severity: Minor
Found in lib/karafka/swarm/pidfd.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 build_and_schedule_flow_jobs has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

      def build_and_schedule_flow_jobs
        return if @messages_buffer.empty?

        consume_jobs = []
        idle_jobs = []
Severity: Minor
Found in lib/karafka/connection/listener.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 expand has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

            def expand(sg_topics, new_topic)
              MUTEX.synchronize do
                sg_topics
                  .map(&:patterns)
                  .select(&:active?)
Severity: Minor
Found in lib/karafka/pro/routing/features/patterns/detector.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 handle_after_consume has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

            def handle_after_consume
              coordinator.on_finished do |last_group_message|
                return if revoked?

                if coordinator.success?
Severity: Minor
Found in lib/karafka/pro/processing/strategies/ftr/default.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 handle_after_consume has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

          def handle_after_consume
            coordinator.on_finished do |last_group_message|
              return if revoked?

              if coordinator.success?
Severity: Minor
Found in lib/karafka/pro/processing/strategies/default.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 handle_after_consume has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

        def handle_after_consume
          return if revoked?

          if coordinator.success?
            coordinator.pause_tracker.reset
Severity: Minor
Found in lib/karafka/processing/strategies/dlq.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 handle_after_consume has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

            def handle_after_consume
              coordinator.on_finished do
                return if revoked?

                if coordinator.success?
Severity: Minor
Found in lib/karafka/pro/processing/strategies/mom/ftr.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 handle_after_consume has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

            def handle_after_consume
              coordinator.on_finished do |last_group_message|
                return if revoked?

                if coordinator.success?
Severity: Minor
Found in lib/karafka/pro/processing/strategies/dlq/default.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_cooperative_rebalance has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

          def on_cooperative_rebalance(client_ptr, code, partitions_ptr, tpl, opaque)
Severity: Minor
Found in lib/karafka/patches/rdkafka/bindings.rb - About 35 mins to fix

    Method on_eager_rebalance has 5 arguments (exceeds 4 allowed). Consider refactoring.
    Open

              def on_eager_rebalance(client_ptr, code, partitions_ptr, tpl, opaque)
    Severity: Minor
    Found in lib/karafka/patches/rdkafka/bindings.rb - About 35 mins to fix

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

              def generate
                # Not used anywhere else, hence required here
                require 'open-uri'
      
                attributes = { consumer: Set.new, producer: Set.new }
      Severity: Minor
      Found in lib/karafka/setup/attributes_map.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 call has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

                def call(message)
                  headers = message.headers
                  encryption = headers['encryption']
                  fingerprint = headers['encryption_fingerprint']
      
      
      Severity: Minor
      Found in lib/karafka/pro/encryption/messages/parser.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 persist has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def persist(*klasses)
              # Support for providing multiple classes
              klasses = Array(klasses).flatten
      
              [Dispatcher, Consumer]
      Severity: Minor
      Found in lib/karafka/active_job/current_attributes.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 consume has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

              def consume
                messages.each(clean: true) do |message|
                  # If for any reason we've lost this partition, not worth iterating over new messages
                  # as they are no longer ours
                  break if revoked?
      Severity: Minor
      Found in lib/karafka/pro/active_job/consumer.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 signal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def signal(sig_name)
              @mutex.synchronize do
                return false if @cleaned
                # Never signal processes that are dead
                return false unless alive?
      Severity: Minor
      Found in lib/karafka/swarm/pidfd.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 start has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
      Open

            def start
              # Command we want to run, like install, server, etc
              command_name = ARGV[0]
              # Action for action-based commands like topics migrate
              action = ARGV[1].to_s.start_with?('-') ? false : ARGV[1]
      Severity: Minor
      Found in lib/karafka/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

      Avoid too many return statements within this method.
      Open

              return unless process.supervised?
      Severity: Major
      Found in lib/karafka/server.rb - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                  return nil
        Severity: Major
        Found in lib/karafka/connection/client.rb - About 30 mins to fix

          Method apply! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                    def apply!(messages)
                      @applied = false
                      @cursor = nil
                      @time = monotonic_now
                      @requests.delete_if { |timestamp, _| timestamp < (@time - @interval) }
          Severity: Minor
          Found in lib/karafka/pro/processing/filters/throttler.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

          Method mark_as_consumed has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

                  def mark_as_consumed(message)
                    # If we are not retrying pause count is already 0, no need to try to reset the state
                    return super unless retrying?
                    # If we do not use independent marking on DLQ, we just mark as consumed
                    return super unless topic.dead_letter_queue.independent?
          Severity: Minor
          Found in lib/karafka/processing/strategies/dlq.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

          Severity
          Category
          Status
          Source
          Language