karafka/karafka

View on GitHub
lib/karafka/connection/listener.rb

Summary

Maintainability
C
7 hrs
Test Coverage

Method build_and_schedule_periodic_jobs has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

      def build_and_schedule_periodic_jobs
        # Shortcut if periodic jobs are not used at all. No need to run the complex flow when it
        # will never end up with anything. If periodics on any of the topics are not even defined,
        # we can finish fast
        @periodic_jobs ||= @subscription_group.topics.count(&:periodic_job?)
Severity: Minor
Found in lib/karafka/connection/listener.rb - About 3 hrs 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 fetch_loop has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def fetch_loop
        running!
        # Run the initial events fetch to improve chances of having metrics and initial callbacks
        # triggers on start.
        #
Severity: Minor
Found in lib/karafka/connection/listener.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 fetch_loop has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def fetch_loop
              running!
              # Run the initial events fetch to improve chances of having metrics and initial callbacks
              # triggers on start.
              #
      Severity: Minor
      Found in lib/karafka/connection/listener.rb - About 45 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 build_and_schedule_flow_jobs has a Cognitive Complexity of 8 (exceeds 5 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 45 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

      There are no issues that match your filters.

      Category
      Status