Showing 81 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

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

        def self.up
          create_table :rapns_notifications do |t|
            t.integer   :badge,                 null: true
            t.string    :device_token,          null: false, limit: 64
            t.string    :sound,                 null: true,  default: "1.aiff"
    Severity: Major
    Found in lib/generators/templates/add_rpush.rb and 1 other location - About 3 hrs to fix
    lib/generators/templates/create_rapns_notifications.rb on lines 2..21

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

    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

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

      def self.up
        create_table :rapns_notifications do |t|
          t.integer   :badge,                 null: true
          t.string    :device_token,          null: false, limit: 64
          t.string    :sound,                 null: true,  default: "1.aiff"
    Severity: Major
    Found in lib/generators/templates/create_rapns_notifications.rb and 1 other location - About 3 hrs to fix
    lib/generators/templates/add_rpush.rb on lines 45..64

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

    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

    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

      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

        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

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

              def self.down
                update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Apns::Notification', 'Rapns::Apns::Notification')
                update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Gcm::Notification', 'Rapns::Gcm::Notification')
                update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Adm::Notification', 'Rapns::Adm::Notification')
                update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Wpns::Notification', 'Rapns::Wpns::Notification')
          Severity: Major
          Found in lib/generators/templates/add_rpush.rb and 1 other location - About 1 hr to fix
          lib/generators/templates/rename_rapns_to_rpush.rb on lines 40..62

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

          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

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

            def self.up
              rename_table :rapns_notifications, :rpush_notifications
              rename_table :rapns_apps, :rpush_apps
              rename_table :rapns_feedback, :rpush_feedback
          
          
          Severity: Major
          Found in lib/generators/templates/rename_rapns_to_rpush.rb and 1 other location - About 1 hr to fix
          lib/generators/templates/add_rpush.rb on lines 294..315

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

          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

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

              def self.up
                rename_table :rapns_notifications, :rpush_notifications
                rename_table :rapns_apps, :rpush_apps
                rename_table :rapns_feedback, :rpush_feedback
          
          
          Severity: Major
          Found in lib/generators/templates/add_rpush.rb and 1 other location - About 1 hr to fix
          lib/generators/templates/rename_rapns_to_rpush.rb on lines 16..37

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

          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

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

            def self.down
              update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Apns::Notification', 'Rapns::Apns::Notification')
              update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Gcm::Notification', 'Rapns::Gcm::Notification')
              update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Adm::Notification', 'Rapns::Adm::Notification')
              update_type(RenameRapnsToRpush::Rpush::Notification, 'Rpush::Wpns::Notification', 'Rapns::Wpns::Notification')
          Severity: Major
          Found in lib/generators/templates/rename_rapns_to_rpush.rb and 1 other location - About 1 hr to fix
          lib/generators/templates/add_rpush.rb on lines 318..340

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

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

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

                      class BadgeRequest
                        def self.create(notification, access_token)
                          body = BadgeRequestPayload.new(notification).to_xml
                          uri = URI.parse(notification.uri)
                          headers = {
                Severity: Major
                Found in lib/rpush/daemon/wns/badge_request.rb and 1 other location - About 1 hr to fix
                lib/rpush/daemon/wns/toast_request.rb on lines 4..21

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

                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 ToastRequest
                        def self.create(notification, access_token)
                          body = ToastRequestPayload.new(notification).to_xml
                          uri  = URI.parse(notification.uri)
                          headers = {
                Severity: Major
                Found in lib/rpush/daemon/wns/toast_request.rb and 1 other location - About 1 hr to fix
                lib/rpush/daemon/wns/badge_request.rb on lines 4..22

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

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

                Severity
                Category
                Status
                Source
                Language