karafka/karafka

View on GitHub

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
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/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 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?
Severity: Minor
Found in lib/karafka/server.rb - About 1 hr to fix

    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
    Severity: Minor
    Found in lib/karafka/pro/processing/strategies/ftr/default.rb - About 1 hr to fix

      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 }
      
      
      Severity: Minor
      Found in lib/karafka/processing/worker.rb - About 1 hr to fix

        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)
        Severity: Minor
        Found in lib/karafka/swarm/supervisor.rb - About 1 hr to fix

          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
          
          
          Severity: Minor
          Found in lib/karafka/swarm/supervisor.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 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?
          Severity: Minor
          Found in lib/karafka/connection/pauses_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 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
          Severity: Minor
          Found in lib/karafka/processing/timed_queue.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 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
          
          
          Severity: Minor
          Found in lib/karafka/pro/processing/strategies/aj/dlq_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 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
          Severity: Minor
          Found in lib/karafka/routing/features/base/expander.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 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|
          Severity: Minor
          Found in lib/karafka/pro/iterator/tpl_builder.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 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
          Severity: Minor
          Found in lib/karafka/cli/topics/align.rb - About 1 hr to fix

            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 = []
            Severity: Minor
            Found in lib/karafka/connection/listener.rb - About 1 hr to fix

              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?
              Severity: Minor
              Found in lib/karafka/pro/processing/strategies/aj/dlq_mom.rb - About 55 mins 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 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 }
              
              
              Severity: Minor
              Found in lib/karafka/processing/worker.rb - About 55 mins 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 9 (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/mom.rb - About 55 mins 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 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|
              Severity: Minor
              Found in lib/karafka/pro/iterator/tpl_builder.rb - About 55 mins 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 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
              Severity: Minor
              Found in lib/karafka/connection/client.rb - About 55 mins 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

              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")
              
              
              Severity: Minor
              Found in lib/karafka/contracts/server_cli_options.rb and 1 other location - About 55 mins to fix
              lib/karafka/pro/contracts/server_cli_options.rb on lines 50..68

              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

              Further Reading

              Severity
              Category
              Status
              Source
              Language