karafka/karafka

View on GitHub

Showing 150 of 150 total issues

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

          def on_error_occurred(event)
            push_tags

            error = event[:error]
            client.active_span&.set_error(error)
Severity: Minor
Found in lib/karafka/instrumentation/vendors/datadog/logger_listener.rb - About 1 hr to fix

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

                def handle_after_consume
                  coordinator.on_finished do |last_group_message|
                    return if revoked?
    
                    if coordinator.success?
    Severity: Minor
    Found in lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom_vp.rb - About 1 hr 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 12 (exceeds 5 allowed). Consider refactoring.
    Open

                def handle_after_consume
                  coordinator.on_finished do
                    return if revoked?
    
                    if coordinator.success?
    Severity: Minor
    Found in lib/karafka/pro/processing/strategies/aj/dlq_ftr_mom.rb - About 1 hr 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 declaratives_routing_topics has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

            def declaratives_routing_topics
              return @declaratives_routing_topics if @declaratives_routing_topics
    
              collected_topics = {}
              default_servers = kafka_config[:'bootstrap.servers']
    Severity: Minor
    Found in lib/karafka/cli/topics/base.rb - About 1 hr 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 validate! has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

                  def validate!(builder)
                    nodes_setup = Hash.new do |h, node_id|
                      h[node_id] = { active: false, node_id: node_id }
                    end
    
    
    Severity: Minor
    Found in lib/karafka/pro/routing/features/swarm/contracts/routing.rb - About 1 hr 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 12 (exceeds 5 allowed). Consider refactoring.
    Open

                def handle_after_consume
                  coordinator.on_finished do
                    return if revoked?
    
                    if coordinator.success?
    Severity: Minor
    Found in lib/karafka/pro/processing/strategies/dlq/ftr_mom.rb - About 1 hr 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 build_resources_to_migrate has a Cognitive Complexity of 12 (exceeds 5 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
    Severity: Minor
    Found in lib/karafka/cli/topics/align.rb - About 1 hr 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

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module Pro
        module Routing
          module Features
            class Delaying < Base
              # Topic delaying API extensions
    Severity: Major
    Found in lib/karafka/pro/routing/features/delaying/topic.rb and 1 other location - About 1 hr to fix
    lib/karafka/pro/routing/features/expiring/topic.rb on lines 15..52

    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 59.

    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

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      module Pro
        module Routing
          module Features
            class Expiring < Base
              # Topic expiring API extensions
    Severity: Major
    Found in lib/karafka/pro/routing/features/expiring/topic.rb and 1 other location - About 1 hr to fix
    lib/karafka/pro/routing/features/delaying/topic.rb on lines 15..52

    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 59.

    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

    Further Reading

    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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        module Pro
          module Routing
            module Features
              class Expiring < Base
                # Namespace for expiring messages contracts
      lib/karafka/pro/routing/features/delaying/contracts/topic.rb on lines 15..33

      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 58.

      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

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

        module Pro
          module Routing
            module Features
              class Delaying < Base
                # Namespace for delaying feature contracts
      lib/karafka/pro/routing/features/expiring/contracts/topic.rb on lines 15..33

      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 58.

      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

      Further Reading

      Method stop has 33 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def stop
              # Ensure that the stopping procedure is initialized only once
              @mutex.synchronize do
                return if @stopping
      
      
      Severity: Minor
      Found in lib/karafka/swarm/supervisor.rb - About 1 hr to fix

        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
        
        
        Severity: Minor
        Found in lib/karafka/pro/processing/strategies/lrj/mom.rb - About 1 hr 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 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
        Severity: Minor
        Found in lib/karafka/pro/processing/strategies/vp/default.rb - About 1 hr 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 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
        
        
        Severity: Minor
        Found in lib/karafka/pro/processing/strategies/aj/lrj_mom_vp.rb - About 1 hr 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 shutdown has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

                def shutdown
                  active_listeners = @listeners.active
        
                  # When we are done processing immediately quiet all the listeners so they do not pick up
                  # new work to do
        Severity: Minor
        Found in lib/karafka/pro/connection/manager.rb - About 1 hr 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 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
                      mark_in_transaction(message, offset_metadata, true)
                    else
                      # seek offset can be nil only in case `#seek` was invoked with offset reset request
        Severity: Minor
        Found in lib/karafka/pro/processing/strategies/default.rb - About 1 hr 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 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
                      mark_in_transaction(message, offset_metadata, false)
                    else
                      # seek offset can be nil only in case `#seek` was invoked with offset reset request
        Severity: Minor
        Found in lib/karafka/pro/processing/strategies/default.rb - About 1 hr 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 11 (exceeds 5 allowed). Consider refactoring.
        Open

                    def handle_after_consume
                      coordinator.on_finished do
                        if coordinator.success?
                          coordinator.pause_tracker.reset
        
        
        Severity: Minor
        Found in lib/karafka/pro/processing/strategies/aj/dlq_lrj_mom.rb - About 1 hr 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