karafka/karafka

View on GitHub

Showing 112 of 150 total issues

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

Method report_metric has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

          def report_metric(metric, statistics, base_tags)
            case metric.scope
            when :root
              public_send(
                metric.type,
Severity: Minor
Found in lib/karafka/instrumentation/vendors/datadog/metrics_listener.rb - About 4 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 report_metric has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
Open

          def report_metric(metric, statistics, consumer_group_id)
            case metric.scope
            when :root
              # Do nothing on the root metrics as the same metrics are reported in a granular
              # way from other places
Severity: Minor
Found in lib/karafka/instrumentation/vendors/appsignal/metrics_listener.rb - About 4 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 control has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
Open

      def control
        monitor.instrument('swarm.manager.control', caller: self) do
          @nodes.each do |node|
            statuses = @statuses[node]

Severity: Minor
Found in lib/karafka/swarm/manager.rb - About 4 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 scale_up has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring.
Open

        def scale_up
          multi_part_sgs_families = Karafka::App
                                    .assignments
                                    .select { |_, partitions| partitions.size > 1 }
                                    .keys
Severity: Minor
Found in lib/karafka/pro/connection/manager.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 scale_down has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
Open

        def scale_down
          sgs_in_use = Karafka::App.assignments.keys.map(&:subscription_group).uniq

          # Select connections for scaling down
          in_sg_families do |first_subscription_group, sg_listeners|
Severity: Minor
Found in lib/karafka/pro/connection/manager.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

File attributes_map.rb has 314 lines of code (exceeds 250 allowed). Consider refactoring.
Open

module Karafka
  module Setup
    # To simplify the overall design, in Karafka we define all the rdkafka settings in one scope
    # under `kafka`. rdkafka though does not like when producer options are passed to the
    # consumer configuration and issues warnings. This target map is used as a filtering layer, so
Severity: Minor
Found in lib/karafka/setup/attributes_map.rb - About 3 hrs to fix

    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

      Method build_and_schedule_periodic_jobs has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

            def build_and_schedule_periodic_jobs
              # Shortcut if periodic jobs are not used at all. No need to run the complex flow when it
              # will never end up with anything. If periodics on any of the topics are not even defined,
              # we can finish fast
              @periodic_jobs ||= @subscription_group.topics.count(&:periodic_job?)
      Severity: Minor
      Found in lib/karafka/connection/listener.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

      File client.rb has 300 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 handle_after_consume has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
        Open

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

                    def handle_after_consume
                      coordinator.on_finished do |last_group_message|
                        if coordinator.success?
                          coordinator.pause_tracker.reset
        
        
        Severity: Minor
        Found in lib/karafka/pro/processing/strategies/dlq/ftr_lrj.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 LoggerListener has 24 methods (exceeds 20 allowed). Consider refactoring.
        Open

            class LoggerListener
              # Log levels that we use in this particular listener
              USED_LOG_LEVELS = %i[
                debug
                info
        Severity: Minor
        Found in lib/karafka/instrumentation/logger_listener.rb - About 2 hrs to fix

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

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

                      def handle_after_consume
                        coordinator.on_finished do |last_group_message|
                          if coordinator.success?
                            coordinator.pause_tracker.reset
          
          
          Severity: Minor
          Found in lib/karafka/pro/processing/strategies/dlq/lrj_mom.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 BaseConsumer has 22 methods (exceeds 20 allowed). Consider refactoring.
          Open

            class BaseConsumer
              # Allow for consumer instance tagging for instrumentation
              include ::Karafka::Core::Taggable
          
              extend Forwardable
          Severity: Minor
          Found in lib/karafka/base_consumer.rb - About 2 hrs to fix

            Method on_error_occurred has 58 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def on_error_occurred(event)
                    type = event[:type]
                    error = event[:error]
                    details = (error.backtrace || []).join("\n")
            
            
            Severity: Major
            Found in lib/karafka/instrumentation/logger_listener.rb - About 2 hrs to fix

              Method handle_after_consume has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                          def handle_after_consume
                            coordinator.on_finished do |last_group_message|
                              if coordinator.success?
                                coordinator.pause_tracker.reset
              
              
              Severity: Minor
              Found in lib/karafka/pro/processing/strategies/aj/dlq_ftr_lrj_mom_vp.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 topics_to_alter has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                      def topics_to_alter
                        return @topics_to_alter if @topics_to_alter
              
                        topics_to_check = []
              
              
              Severity: Minor
              Found in lib/karafka/cli/topics/plan.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

              Severity
              Category
              Status
              Source
              Language