Showing 16 of 28 total issues
Method produce
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def produce(message)
produce_time ||= monotonic_now
# This can happen only during flushing on closing, in case like this we don't have to
# synchronize because we already own the lock
- 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 close
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def close(force: false)
@operating_mutex.synchronize do
return unless @status.active?
@monitor.instrument(
- 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 LoggerListener
has 23 methods (exceeds 20 allowed). Consider refactoring. Open
class LoggerListener
# @param logger [Object] logger we want to use
# @param log_messages [Boolean] Should we report the messages content (payload and metadata)
# with each message operation.
#
Method transaction
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def transaction
# This will safely allow us to support one operation transactions so a transactional
# producer can work without the transactional block if needed
return yield if @transaction_mutex.owned?
- 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 produce
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
def produce(message)
produce_time ||= monotonic_now
# This can happen only during flushing on closing, in case like this we don't have to
# synchronize because we already own the lock
Method transaction
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
def transaction
# This will safely allow us to support one operation transactions so a transactional
# producer can work without the transactional block if needed
return yield if @transaction_mutex.owned?
Method with_transactional_error_handling
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def with_transactional_error_handling(action, allow_abortable: true)
attempt ||= 0
attempt += 1
yield
- 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 report_metric
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def report_metric(metric, statistics)
case metric.scope
when :root
public_send(
metric.type,
Method close
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def close(force: false)
@operating_mutex.synchronize do
return unless @status.active?
@monitor.instrument(
Method with_transactional_error_handling
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def with_transactional_error_handling(action, allow_abortable: true)
attempt ||= 0
attempt += 1
yield
Method transaction_mark_as_consumed
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def transaction_mark_as_consumed(consumer, message, offset_metadata = nil)
raise Errors::TransactionRequiredError unless @transaction_mutex.owned?
CONTRACT.validate!(
{
Method produce_many_async
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def produce_many_async(messages)
dispatched = []
messages = middleware.run_many(messages)
messages.each { |message| validate_message!(message) }
Method client
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def client
return @client if @client && @pid == Process.pid
# Don't allow to obtain a client reference for a producer that was not configured
raise Errors::ProducerNotConfiguredError, id if @status.initial?
- 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 transactional_reload_client_if_needed
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def transactional_reload_client_if_needed(error)
rd_error = error.is_a?(Rdkafka::RdkafkaError) ? error : error.cause
return unless rd_error.is_a?(Rdkafka::RdkafkaError)
return unless config.reload_on_transaction_fatal_error
- 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 call
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def call(delivery_report)
error_code = delivery_report.error.to_i
if error_code.zero?
instrument_acknowledged(delivery_report)
- 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 ensure_active!
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def ensure_active!
return if @status.active?
return if @status.closing? && @operating_mutex.owned?
raise Errors::ProducerNotConfiguredError, id if @status.initial?
- 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"