mongodb/mongo-ruby-driver

View on GitHub

Showing 447 of 447 total issues

Method setopt_crypto_hooks has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

      def self.setopt_crypto_hooks(handle,
        aes_encrypt_cb, aes_decrypt_cb, random_cb,
        hmac_sha_512_cb, hmac_sha_256_cb, hmac_hash_cb
Severity: Major
Found in lib/mongo/crypt/binding.rb - About 50 mins to fix

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

      class Monitoring
        module Event
          module Cmap
    
            # Event published when a connection is returned to a connection pool.
    Severity: Minor
    Found in lib/mongo/monitoring/event/cmap/connection_checked_in.rb and 1 other location - About 50 mins to fix
    lib/mongo/monitoring/event/cmap/connection_checked_out.rb on lines 19..69

    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

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

      class Monitoring
        module Event
          module Cmap
    
            # Event published when a connection is successfully checked out out of a pool.
    Severity: Minor
    Found in lib/mongo/monitoring/event/cmap/connection_checked_out.rb and 1 other location - About 50 mins to fix
    lib/mongo/monitoring/event/cmap/connection_checked_in.rb on lines 19..68

    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

              d['upsert'] = true if doc[:upsert]
              d[Operation::COLLATION] = doc[:collation] if doc[:collation]
              d[Operation::ARRAY_FILTERS] = doc[:array_filters] if doc[:array_filters]
              d['hint'] = doc[:hint] if doc[:hint]
    Severity: Minor
    Found in lib/mongo/bulk_write/transformable.rb and 1 other location - About 45 mins to fix
    lib/mongo/bulk_write/transformable.rb on lines 129..132

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

    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

              d['upsert'] = true if doc[:upsert]
              d[Operation::COLLATION] = doc[:collation] if doc[:collation]
              d[Operation::ARRAY_FILTERS] = doc[:array_filters] if doc[:array_filters]
              d['hint'] = doc[:hint] if doc[:hint]
    Severity: Minor
    Found in lib/mongo/bulk_write/transformable.rb and 1 other location - About 45 mins to fix
    lib/mongo/bulk_write/transformable.rb on lines 114..117

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

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

          def summarize_perf_data(data)
            puts '===== Performance Results ====='
            data.each do |item|
              puts format('%s : %4.4g', item['info']['test_name'], item['metrics'][0]['value'])
              next unless item['metrics'].length > 1
    Severity: Minor
    Found in profile/driver_bench/suite.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 command_failed has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

          def command_failed(failure, address, operation_id, payload, message, duration,
            started_event:, server_connection_id: nil, service_id: nil
    Severity: Minor
    Found in lib/mongo/monitoring/publishable.rb - About 45 mins to fix

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

            def check_invariants
              return unless Lint.enabled?
      
              # Server summary calls pool summary which requires pool lock -> deadlock.
              # Obtain the server summary ahead of time.
      Severity: Minor
      Found in lib/mongo/server/connection_pool.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 server_type has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def server_type
              return :load_balancer if load_balancer?
              return :arbiter if arbiter?
              return :ghost if ghost?
              return :sharded if mongos?
      Severity: Minor
      Found in lib/mongo/server/description.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 set_server_list has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

          def set_server_list(server_address_strs)
            @sdam_flow_lock.synchronize do
              # If one of the new addresses is not in the current servers list,
              # add it to the servers list.
              server_address_strs.each do |address_str|
      Severity: Minor
      Found in lib/mongo/cluster.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 stop! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def stop!
              @lock.synchronize do
                @stop_requested = true
                if @connection
                  # Interrupt any in-progress exhausted hello reads by
      Severity: Minor
      Found in lib/mongo/server/push_monitor.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 check_bidi! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def check_bidi!(out)
              if out.each_char.any? { |c| table_contains?(Tables::C8, c) }
                raise Mongo::Error::FailedStringPrepValidation.new(Error::FailedStringPrepValidation::INVALID_BIDIRECTIONAL)
              end
      
      
      Severity: Minor
      Found in lib/mongo/auth/stringprep.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 do_work has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def do_work
              @lock.synchronize do
                return if @stop_requested
              end
      
      
      Severity: Minor
      Found in lib/mongo/server/push_monitor.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 set_compressor! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_compressor!(reply)
              server_compressors = reply['compression']
      
              if options[:compressors]
                if intersection = (server_compressors & options[:compressors])
      Severity: Minor
      Found in lib/mongo/server/connection_common.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 generate has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

              def self.generate(address, operation_id, payload, message,
                failure, duration, started_event:, server_connection_id: nil,
                service_id: nil
      Severity: Minor
      Found in lib/mongo/monitoring/event/command_failed.rb - About 45 mins to fix

        Method initialize has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

                def initialize(command_name, database_name, address, request_id,
                  operation_id, command, socket_object_id: nil, connection_id: nil,
                  connection_generation: nil, server_connection_id: nil,
                  service_id: nil
        Severity: Minor
        Found in lib/mongo/monitoring/event/command_started.rb - About 45 mins to fix

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

                  def aggregate_write_errors(count)
                    return unless @replies
                    @replies.reduce(nil) do |errors, reply|
                      if write_errors = reply.documents.first['writeErrors']
                        wes = write_errors.collect do |we|
          Severity: Minor
          Found in lib/mongo/operation/shared/result/aggregatable.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 has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def initialize(user, used_mechanism: nil, message: nil,
                  server: nil, code: nil
                )
                  @code = code
          
          
          Severity: Minor
          Found in lib/mongo/auth.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 reject! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

                def reject!
                  if block_given?
                    n_keys = keys.size
                    keys.each do |key|
                      delete(key) if yield(key, self[key])
          Severity: Minor
          Found in lib/mongo/options/redacted.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 commit_changes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              def commit_changes
                # The application-visible sequence of events should be as follows:
                #
                # 1. Description change for the server which we are processing;
                # 2. Topology change, if any;
          Severity: Minor
          Found in lib/mongo/cluster/sdam_flow.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