snowplow/snowplow-ruby-tracker

View on GitHub

Showing 5 of 5 total issues

Method send_requests_with_get has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

    def send_requests_with_get(events)
      success_count = 0
      unsent_requests = []

      events.each do |event|
Severity: Minor
Found in lib/snowplow-tracker/emitters.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 finalise_payload has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def finalise_payload(payload, context, tstamp, event_subject, page)
Severity: Minor
Found in lib/snowplow-tracker/tracker.rb - About 35 mins to fix

    Method send_requests_with_post has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def send_requests_with_post(events)
          post_succeeded = false
          begin
            request = http_post(SelfDescribingJson.new(
              'iglu:com.snowplowanalytics.snowplow/payload_data/jsonschema/1-0-4',
    Severity: Minor
    Found in lib/snowplow-tracker/emitters.rb - About 35 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 finalise_payload has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

        def finalise_payload(payload, context, tstamp, event_subject, page)
          payload.add_json(build_context(context), @encode_base64, 'cx', 'co') unless context.nil? || context.empty?
          payload.add_hash(page.details) unless page.nil?
    
          if event_subject.nil?
    Severity: Minor
    Found in lib/snowplow-tracker/tracker.rb - About 35 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 flush has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Open

        def flush(async = true)
          loop do
            @lock.synchronize do
              @queue.synchronize { @results_unprocessed += 1 }
              @queue << @buffer
    Severity: Minor
    Found in lib/snowplow-tracker/emitters.rb - About 25 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

    Severity
    Category
    Status
    Source
    Language