karafka/karafka

View on GitHub
lib/karafka/connection/client.rb

Summary

Maintainability
D
2 days
Test Coverage

Method poll has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

      def poll(timeout)
        time_poll ||= TimeTrackers::Poll.new(timeout)

        return nil if time_poll.exceeded?

Severity: Minor
Found in lib/karafka/connection/client.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

Class Client has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Client
      attr_reader :rebalance_manager

      # @return [Karafka::Routing::SubscriptionGroup] subscription group to which this client
      #   belongs to
Severity: Minor
Found in lib/karafka/connection/client.rb - About 3 hrs to fix

    File client.rb has 306 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    module Karafka
      # Namespace for Kafka connection related logic
      module Connection
        # An abstraction layer on top of the rdkafka consumer.
        #
    Severity: Minor
    Found in lib/karafka/connection/client.rb - About 3 hrs to fix

      Method batch_poll has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

            def batch_poll
              time_poll = TimeTrackers::Poll.new(@subscription_group.max_wait_time)
      
              @buffer.clear
              @rebalance_manager.clear
      Severity: Minor
      Found in lib/karafka/connection/client.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 poll has 46 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def poll(timeout)
              time_poll ||= TimeTrackers::Poll.new(timeout)
      
              return nil if time_poll.exceeded?
      
      
      Severity: Minor
      Found in lib/karafka/connection/client.rb - About 1 hr to fix

        Method build_consumer has 34 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def build_consumer
                ::Rdkafka::Config.logger = ::Karafka::App.config.logger
        
                # We need to refresh the setup of this subscription group in case we started running in a
                # swarm. The initial configuration for validation comes from the parent node, but it needs
        Severity: Minor
        Found in lib/karafka/connection/client.rb - About 1 hr to fix

          Method resume has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

                def resume(topic, partition)
                  @mutex.synchronize do
                    return if @closed
          
                    # We now commit offsets on rebalances, thus we can do it async just to make sure
          Severity: Minor
          Found in lib/karafka/connection/client.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 pause has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def pause(topic, partition, offset = nil)
                  @mutex.synchronize do
                    # Do not pause if the client got closed, would not change anything
                    return if @closed
          
          
          Severity: Minor
          Found in lib/karafka/connection/client.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

          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

            There are no issues that match your filters.

            Category
            Status