9to5/pushr-gcm

View on GitHub

Showing 3 of 3 total issues

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

        def handle_single(result, registration_id)
          if result.key?('error')
            if result['error'] == 'NotRegistered' || result['error'] == 'InvalidRegistration'
              Pushr::FeedbackGcm.create(app: message.app, failed_at: Time.now, device: registration_id, follow_up: 'delete')
            end
Severity: Minor
Found in lib/pushr/daemon/gcm_support/response_handler.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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def post(uri, data, headers)
          reconnect_idle if idle_period_exceeded?

          retry_count = 0

Severity: Minor
Found in lib/pushr/daemon/gcm_support/connection_gcm.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

Method registration_ids_array has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def registration_ids_array
      if registration_ids.class == Array
        if registration_ids.size > 1000
          errors.add(:registration_ids, 'is too big (max 1000)')
        elsif registration_ids.size == 0
Severity: Minor
Found in lib/pushr/message_gcm.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