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?
- Read upRead up
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
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.
#
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
- Read upRead up
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?
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
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
- Read upRead up
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
- Read upRead up
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