Showing 81 of 81 total issues

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

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

              def access_token
                if @notification.app.access_token.nil? || @notification.app.access_token_expired?
                  post = Net::HTTP::Post.new(WPN_TOKEN_URI.path, 'Content-Type' => 'application/x-www-form-urlencoded')
                  post.set_form_data(ACCESS_TOKEN_REQUEST_DATA.merge('client_id' => @notification.app.client_id, 'client_secret' => @notification.app.client_secret))
      
      
      Severity: Minor
      Found in lib/rpush/daemon/wns/delivery.rb and 1 other location - About 50 mins to fix
      lib/rpush/daemon/adm/delivery.rb on lines 198..206

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

      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

              def access_token
                if @notification.app.access_token.nil? || @notification.app.access_token_expired?
                  post = Net::HTTP::Post.new(AMAZON_TOKEN_URI.path, 'Content-Type' => 'application/x-www-form-urlencoded')
                  post.set_form_data(ACCESS_TOKEN_REQUEST_DATA.merge('client_id' => @notification.app.client_id, 'client_secret' => @notification.app.client_secret))
      
      
      Severity: Minor
      Found in lib/rpush/daemon/adm/delivery.rb and 1 other location - About 50 mins to fix
      lib/rpush/daemon/wns/delivery.rb on lines 150..158

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

      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_apps do |t|
            t.string    :key,             null: false
            t.string    :environment,     null: false
            t.text      :certificate,     null: false
      Severity: Minor
      Found in lib/generators/templates/create_rapns_apps.rb and 1 other location - About 50 mins to fix
      lib/generators/templates/add_rpush.rb on lines 118..125

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

      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 handle_response(notification, response)
                code = response[:code]
                case code
                when 200
                  ok(notification)
      Severity: Minor
      Found in lib/rpush/daemon/apns2/delivery.rb and 1 other location - About 50 mins to fix
      lib/rpush/daemon/apnsp8/delivery.rb on lines 99..112

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

      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 handle_response(notification, response)
                code = response[:code]
                case code
                when 200
                  ok(notification)
      Severity: Minor
      Found in lib/rpush/daemon/apnsp8/delivery.rb and 1 other location - About 50 mins to fix
      lib/rpush/daemon/apns2/delivery.rb on lines 66..79

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

      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_apps do |t|
              t.string    :key,             null: false
              t.string    :environment,     null: false
              t.text      :certificate,     null: false
      Severity: Minor
      Found in lib/generators/templates/add_rpush.rb and 1 other location - About 50 mins to fix
      lib/generators/templates/create_rapns_apps.rb on lines 2..9

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

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

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

              def start
                @stop = false
      
                @thread = Thread.new(UNIXServer.open(Rpc.socket_path)) do |server|
                  begin
      Severity: Minor
      Found in lib/rpush/daemon/rpc/server.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 initialize_client has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def initialize_client
            return if @client_initialized
            raise ConfigurationError, 'Rpush.config.client is not set.' unless client
            require "rpush/client/#{client}"
      
      
      Severity: Minor
      Found in lib/rpush/configuration.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 adapter_name has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

              def adapter_name
                env = (defined?(Rails) && Rails.env) ? Rails.env : 'development'
                if ::ActiveRecord::VERSION::MAJOR > 6
                  ::ActiveRecord::Base.configurations.configs_for(env_name: env).first.configuration_hash[:adapter]
                else
      Severity: Minor
      Found in lib/rpush/daemon/store/active_record.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) # rubocop:disable Metrics/ParameterLists
      Severity: Minor
      Found in lib/rpush/daemon/store/redis.rb - About 45 mins to fix

        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) # rubocop:disable Metrics/ParameterLists
        Severity: Minor
        Found in lib/rpush/daemon/store/active_record.rb - About 45 mins to fix

          Method apns_feedback has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

            def self.apns_feedback
              require 'rpush/daemon'
              Rpush::Daemon.common_init
          
              Rpush::Apns::App.all.each do |app|
          Severity: Minor
          Found in lib/rpush/apns_feedback.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