Showing 152 of 152 total issues
Method mark_as_consumed!
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def mark_as_consumed!(message, offset_metadata = @_current_offset_metadata)
if @_in_transaction && !collapsed?
mark_in_transaction(message, offset_metadata, false)
elsif collapsed?
super
- 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 handle_after_consume
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def handle_after_consume
coordinator.on_finished do |last_group_message|
if coordinator.success?
coordinator.pause_tracker.reset
- 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 stop
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def stop
# Initialize the stopping process only if Karafka was running
return if Karafka::App.stopping?
return if Karafka::App.stopped?
return if Karafka::App.terminated?
Method handle_post_filtering
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
def handle_post_filtering
filter = coordinator.filter
# We pick the timeout before the action because every action takes time. This time
# may then mean we end up having throttle time equal to zero when pause is needed
Method process
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def process
job = @jobs_queue.pop
instrument_details = { caller: self, job: job, jobs_queue: @jobs_queue }
Method run
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def run
# Close producer just in case. While it should not be used, we do not want even a
# theoretical case since librdkafka is not thread-safe.
# We close it prior to forking just to make sure, there is no issue with initialized
# producer (should not be initialized but just in case)
Method stop
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def stop
# Ensure that the stopping procedure is initialized only once
@mutex.synchronize do
return if @stopping
- 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 resume
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def resume
@pauses.each do |topic, partitions|
partitions.each do |partition, pause|
next unless pause.paused?
next unless pause.expired?
- 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 pop
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def pop(timeout: 10_000_000_000)
deadline = monotonic_now + timeout * 1000
@mutex.synchronize do
loop do
- 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 handle_after_consume
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def handle_after_consume
coordinator.on_finished do |last_group_message|
if coordinator.success?
coordinator.pause_tracker.reset
- 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 prepended_module
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def prepended_module
scope = @scope
Module.new do
# Runs validations related to this feature on a routing resources
- 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 resolve_partitions_with_exact_offsets
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def resolve_partitions_with_exact_offsets
@expanded_topics.each do |name, partitions|
next unless partitions.is_a?(Hash)
partitions.each do |partition, offset|
- 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 build_resources_to_migrate
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_resources_to_migrate
# We build non-fetched topics resources representations for further altering
resources = candidate_topics.map do |topic|
Admin::Configs::Resource.new(type: :topic, name: topic.name)
end
Method build_and_schedule_flow_jobs
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
def build_and_schedule_flow_jobs
return if @messages_buffer.empty?
consume_jobs = []
idle_jobs = []
Method handle_after_consume
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def handle_after_consume
coordinator.on_finished do
return if revoked?
if coordinator.success?
- 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 process
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def process
job = @jobs_queue.pop
instrument_details = { caller: self, job: job, jobs_queue: @jobs_queue }
- 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 handle_after_consume
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def handle_after_consume
coordinator.on_finished do
return if revoked?
if coordinator.success?
- 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 resolve_partitions_with_cg_expectations
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def resolve_partitions_with_cg_expectations
tpl = Rdkafka::Consumer::TopicPartitionList.new
# First iterate over all topics that we want to expand
@expanded_topics.each do |name, partitions|
- 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 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
Identical blocks of code found in 2 locations. Consider refactoring. Open
virtual do |data, errors|
next unless errors.empty?
value = data.fetch(:"#{action}_subscription_groups")
- Read upRead up
Duplicated Code
Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:
Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.
When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).
Tuning
This issue has a mass of 44.
We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.
The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.
If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.
See codeclimate-duplication
's documentation for more information about tuning the mass threshold in your .codeclimate.yml
.
Refactorings
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76