Showing 45 of 81 total issues

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

    class AppRunner
      extend Reflectable
      include Reflectable
      include Loggable
      extend Loggable
Severity: Minor
Found in lib/rpush/daemon/app_runner.rb - About 3 hrs to fix

    Method as_json has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

              def as_json(options = nil) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
                json = ActiveSupport::OrderedHash.new
    
                if data && data.key?(MDM_KEY)
                  json['mdm'] = data[MDM_KEY]
    Severity: Minor
    Found in lib/rpush/client/active_model/apns/notification.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

    Class ActiveRecord has 24 methods (exceeds 20 allowed). Consider refactoring.
    Open

          class ActiveRecord
            include Reconnectable
    
            DEFAULT_MARK_OPTIONS = { persist: true }
    
    
    Severity: Minor
    Found in lib/rpush/daemon/store/active_record.rb - About 2 hrs to fix

      Class Redis has 24 methods (exceeds 20 allowed). Consider refactoring.
      Open

            class Redis
              DEFAULT_MARK_OPTIONS = { persist: true }
      
              def app(app_id)
                Rpush::Client::Redis::App.find(app_id)
      Severity: Minor
      Found in lib/rpush/daemon/store/redis.rb - About 2 hrs to fix

        File add_rpush.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        class AddRpush < ActiveRecord::Migration[5.0]
          def self.migrations
            [CreateRapnsNotifications, CreateRapnsFeedback,
             AddAlertIsJsonToRapnsNotifications, AddAppToRapns,
             CreateRapnsApps, AddGcm, AddWpns, AddAdm, RenameRapnsToRpush,
        Severity: Minor
        Found in lib/generators/templates/add_rpush.rb - About 2 hrs to fix

          Method humanize_json has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              def humanize_json(node, str = '', depth = 0) # rubocop:disable Metrics/PerceivedComplexity
                if node.is_a?(Hash)
                  node = node.sort_by { |_, v| [Array, Hash].include?(v.class) ? 1 : 0 }
                  node.each do |k, v|
                    if [Array, Hash].include?(v.class)
          Severity: Minor
          Found in lib/rpush/cli.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 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_rpush.rb - About 1 hr to fix

            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 copy_migration has 28 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                def copy_migration
                  if has_migration?('create_rapns_notifications')
                    add_rpush_migration('create_rapns_feedback')
                    add_rpush_migration('add_alert_is_json_to_rapns_notifications')
                    add_rpush_migration('add_app_to_rapns')
              Severity: Minor
              Found in lib/generators/rpush_migration_generator.rb - About 1 hr to fix

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

                        def process(failure_partitions = {}) # rubocop:disable Metrics/AbcSize
                          @successes = []
                          @failures = Failures.new
                          failure_partitions.each_key do |category|
                            failures[category] = []
                Severity: Minor
                Found in lib/rpush/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 start_handler has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def self.start_handler(read_io)
                        @thread = Thread.new do
                          while readable_io = IO.select([read_io]) # rubocop:disable Lint/AssignmentInCondition
                            signal = readable_io.first[0].gets.strip
                
                
                Severity: Minor
                Found in lib/rpush/daemon/signal_handler.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 10 (exceeds 5 allowed). Consider refactoring.
                Open

                      def write(data)
                        connect unless @connected
                        reconnect_idle if idle_period_exceeded?
                
                        retry_count = 0
                Severity: Minor
                Found in lib/rpush/daemon/tcp_connection.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 check_for_error has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                Open

                        def check_for_error
                          begin
                            # On Linux, select returns nil from a dropped connection.
                            # On OS X, Errno::EBADF is raised following a Errno::EADDRNOTAVAIL from the write call.
                            return unless @connection.select(SELECT_TIMEOUT)
                Severity: Minor
                Found in lib/rpush/daemon/dispatcher/apns_tcp.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 down has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.down
                    AddGcm::Rapns::Notification.where(type: 'Rapns::Gcm::Notification').delete_all
                
                    remove_column :rapns_notifications, :type
                    remove_column :rapns_apps, :type
                Severity: Minor
                Found in lib/generators/templates/add_gcm.rb - About 1 hr to fix

                  Method down has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def self.down
                        AddGcm::Rapns::Notification.where(type: 'Rapns::Gcm::Notification').delete_all
                  
                        remove_column :rapns_notifications, :type
                        remove_column :rapns_apps, :type
                  Severity: Minor
                  Found in lib/generators/templates/add_rpush.rb - About 1 hr to fix

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

                            def start
                              return if Rpush.config.push
                              return unless @app.feedback_enabled
                              Rpush.logger.info("[#{@app.name}] Starting feedback receiver... ", true)
                    
                    
                    Severity: Minor
                    Found in lib/rpush/daemon/apns/feedback_receiver.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 start has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def start
                            @started_at = Time.now
                    
                            @thread = Thread.new do
                              loop do
                    Severity: Minor
                    Found in lib/rpush/daemon/dispatcher_loop.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 loop_instances has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                          def loop_instances(app)
                            (@loops || []).map do |cls, options|
                              next unless options.key?(:if) ? options[:if].call : true
                              cls.new(app)
                            end.compact
                    Severity: Minor
                    Found in lib/rpush/daemon/service_config_methods.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 included has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                    Open

                              def self.included(base)
                                base.extend ClassMethods
                                base.instance_eval do
                                  validates :device_token, presence: true
                                  validates :badge, numericality: true, allow_nil: true
                    Severity: Minor
                    Found in lib/rpush/client/active_model/apns/notification.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 perform has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def perform
                              @notification.registration_ids.each do |registration_id|
                                handle_response(do_post(registration_id), registration_id)
                              end
                              if @sent_registration_ids.empty?
                    Severity: Minor
                    Found in lib/rpush/daemon/adm/delivery.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

                    Severity
                    Category
                    Status
                    Source
                    Language