ileitch/rapns

View on GitHub

Showing 18 of 18 total issues

Class AppRunner has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

    class AppRunner
      extend Reflectable
      include Reflectable

      class << self
Severity: Minor
Found in lib/rapns/daemon/app_runner.rb - About 3 hrs to fix

    Method sleep has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

          def sleep(timeout)
            read_ports = [@sleep_reader]
            read_ports << @udp_wakeup if @udp_wakeup
            rs, = IO.select(read_ports, nil, nil, timeout) rescue nil
    
    
    Severity: Minor
    Found in lib/rapns/daemon/interruptible_sleep.rb - About 2 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 as_json has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
    Open

          def as_json
            json = ActiveSupport::OrderedHash.new
    
            if attributes_for_device && attributes_for_device.key?(MDM_KEY)
              json['mdm'] = attributes_for_device[MDM_KEY]
    Severity: Minor
    Found in lib/rapns/apns/notification.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 up has 34 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      def self.up
        add_column :rapns_notifications, :type, :string, :null => true
        add_column :rapns_apps, :type, :string, :null => true
    
        AddGcm::Rapns::Notification.update_all :type => 'Rapns::Apns::Notification'
    Severity: Minor
    Found in lib/generators/templates/add_gcm.rb - About 1 hr to fix

      Method process has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

              def process(failure_partitions = {})
                @successes = []
                @failures = Failures.new
                failure_partitions.each_key do |category|
                  failures[category] = []
      Severity: Minor
      Found in lib/rapns/daemon/gcm/delivery.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 write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def write(data)
              reconnect_idle if idle_period_exceeded?
      
              retry_count = 0
      
      
      Severity: Minor
      Found in lib/rapns/daemon/tcp_connection.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 create_gcm_like_notification has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def create_gcm_like_notification(notification, attrs, data, registration_ids, deliver_after, app)
      Severity: Minor
      Found in lib/rapns/daemon/store/active_record.rb - About 45 mins to fix

        Method create_adm_notification has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def create_adm_notification(attrs, data, registration_ids, deliver_after, app)
        Severity: Minor
        Found in lib/rapns/daemon/store/active_record.rb - About 35 mins to fix

          Method mark_failed has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                  def mark_failed(notification, code, description, time, opts = {})
          Severity: Minor
          Found in lib/rapns/daemon/store/active_record.rb - About 35 mins to fix

            Method create_gcm_notification has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                    def create_gcm_notification(attrs, data, registration_ids, deliver_after, app)
            Severity: Minor
            Found in lib/rapns/daemon/store/active_record.rb - About 35 mins to fix

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

                class TooManyRequestsError < StandardError
                  attr_reader :code, :description, :response
              
                  def initialize(code, notification_id, description, response)
                    @code = code
              Severity: Minor
              Found in lib/rapns/daemon/too_many_requests_error.rb and 1 other location - About 35 mins to fix
              lib/rapns/daemon/retryable_error.rb on lines 2..17

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

              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

                class RetryableError < StandardError
                  attr_reader :code, :description, :response
              
                  def initialize(code, notification_id, description, response)
                    @code = code
              Severity: Minor
              Found in lib/rapns/daemon/retryable_error.rb and 1 other location - About 35 mins to fix
              lib/rapns/daemon/too_many_requests_error.rb on lines 2..17

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

              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 alert has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                    def alert
                      string_or_json = read_attribute(:alert)
              
                      if has_attribute?(:alert_is_json)
                        if alert_is_json?
              Severity: Minor
              Found in lib/rapns/apns/notification.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 check_for_error has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                      def check_for_error
                        if @connection.select(SELECT_TIMEOUT)
                          error = nil
              
                          if tuple = @connection.read(ERROR_TUPLE_BYTES)
              Severity: Minor
              Found in lib/rapns/daemon/apns/delivery.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 perform has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                      def perform
                        begin
                          @notification.registration_ids.each do |registration_id|
                            handle_response(do_post(registration_id), registration_id)
                          end
              Severity: Minor
              Found in lib/rapns/daemon/adm/delivery.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 setup_logger has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def setup_logger(log)
                    if Rapns.config.logger
                      @logger = Rapns.config.logger
                    elsif ActiveSupport.const_defined?('BufferedLogger')
                      @logger = ActiveSupport::BufferedLogger.new(log, Rails.logger.level)
              Severity: Minor
              Found in lib/rapns/logger.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 daemonize has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def self.daemonize
                    if RUBY_VERSION < "1.9"
                      exit if fork
                      Process.setsid
                      exit if fork
              Severity: Minor
              Found in lib/rapns/daemon.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 alert= has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                    def alert=(alert)
                      if alert.is_a?(Hash)
                        write_attribute(:alert, multi_json_dump(alert))
                        self.alert_is_json = true if has_attribute?(:alert_is_json)
                      else
              Severity: Minor
              Found in lib/rapns/apns/notification.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