mongodb/mongo-ruby-driver

View on GitHub

Showing 169 of 222 total issues

Method convert_limit_and_batch_size has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

          def convert_limit_and_batch_size(command)
            if command[:limit] && command[:limit] < 0 &&
                command[:batchSize] && command[:batchSize] < 0

              command[:limit] = command[:limit].abs
Severity: Minor
Found in lib/mongo/collection/view/builder/find_command.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 suppress_read_write_concern! has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    def suppress_read_write_concern!(command)
      command.tap do |c|
        next unless in_transaction?

        c.delete(:readConcern) unless starting_transaction?
Severity: Minor
Found in lib/mongo/session.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 parallel_scan has 31 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        def parallel_scan(cursor_count, options = {})
          if options[:session]
            session = client.send(:get_session, @options)
          else
            session = nil
Severity: Minor
Found in lib/mongo/collection/view/readable.rb - About 1 hr to fix

    Method initialize has 31 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def initialize(addresses_or_uri, options = nil)
          if options
            options = options.dup
          else
            options = {}
    Severity: Minor
    Found in lib/mongo/client.rb - About 1 hr to fix

      Method execute has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def execute
            operation_id = Monitoring.next_operation_id
            result_combiner = ResultCombiner.new
            operations = op_combiner.combine
      
      
      Severity: Minor
      Found in lib/mongo/bulk_write.rb - About 1 hr to fix

        Method update_rs_with_primary_from_member has 30 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def update_rs_with_primary_from_member
              if topology.replica_set_name != updated_desc.replica_set_name
                log_warn(
                  "Removing server #{updated_desc.address.to_s} because it has an " +
                  "incorrect replica set name (#{updated_desc.replica_set_name}); " +
        Severity: Minor
        Found in lib/mongo/cluster/sdam_flow.rb - About 1 hr to fix

          Method ismaster has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def ismaster
                  @mutex.synchronize do
                    if monitoring.monitoring?
                      monitoring.started(
                        Monitoring::SERVER_HEARTBEAT,
          Severity: Minor
          Found in lib/mongo/server/monitor.rb - About 1 hr to fix

            Method summary has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def summary
                  status = case
                  when primary?
                    'PRIMARY'
                  when secondary?
            Severity: Minor
            Found in lib/mongo/server.rb - About 1 hr to fix

              Method create_context has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def create_context(options)
                      OpenSSL::SSL::SSLContext.new.tap do |context|
                        if OpenSSL::SSL.const_defined?(:OP_NO_RENEGOTIATION)
                          context.options = context.options | OpenSSL::SSL::OP_NO_RENEGOTIATION
                        end
              Severity: Minor
              Found in lib/mongo/socket/ssl.rb - About 1 hr to fix

                Method normalized? has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  def self.normalized?(string, form = :nfc)
                    encoding = string.encoding
                    case encoding
                    when Encoding::UTF_8
                      case form
                Severity: Minor
                Found in lib/mongo/auth/stringprep/unicode_normalize/normalize.rb - About 1 hr to fix

                  Method update_rs_without_primary has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      def update_rs_without_primary
                        if topology.replica_set_name.nil?
                          @topology = Topology::ReplicaSetNoPrimary.new(
                            topology.options.merge(replica_set_name: updated_desc.replica_set_name),
                            topology.monitoring, self)
                  Severity: Minor
                  Found in lib/mongo/cluster/sdam_flow.rb - About 1 hr to fix

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

                        def try_next
                          if @documents.nil?
                            @documents = process(@initial_result)
                            # the documents here can be an empty array, hence
                            # we may end up issuing a getMore in the first try_next call
                    Severity: Minor
                    Found in lib/mongo/cursor.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 find_one_and_update has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                            def find_one_and_update(document, opts = {})
                              cmd = { :findAndModify => collection.name, :query => filter }
                              cmd[:update] = document
                              cmd[:fields] = projection if projection
                              cmd[:sort] = sort if sort
                    Severity: Minor
                    Found in lib/mongo/collection/view/writable.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 parse! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def parse!(remaining)
                          hosts_and_db, options = remaining.split('?', 2)
                          if options && options.index('?')
                            raise_invalid_error!("Options contain an unescaped question mark (?), or the database name contains a question mark and was not escaped")
                          end
                    Severity: Minor
                    Found in lib/mongo/uri.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 update_rs_from_primary has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def update_rs_from_primary
                          if topology.replica_set_name.nil?
                            @topology = Topology::ReplicaSetWithPrimary.new(
                              topology.options.merge(replica_set_name: updated_desc.replica_set_name),
                              topology.monitoring, self)
                    Severity: Minor
                    Found in lib/mongo/cluster/sdam_flow.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 initialize has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def initialize(addresses_or_uri, options = nil)
                          if options
                            options = options.dup
                          else
                            options = {}
                    Severity: Minor
                    Found in lib/mongo/client.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 parse_user! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def parse_user!(string)
                          if (string && user = string.partition(AUTH_USER_PWD_DELIM)[0])
                            if user.length > 0
                              raise_invalid_error!(UNESCAPED_USER_PWD) if user =~ UNSAFE
                              user_decoded = decode(user)
                    Severity: Minor
                    Found in lib/mongo/uri.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 parse_password! has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def parse_password!(string)
                          if (string && pwd = string.partition(AUTH_USER_PWD_DELIM)[2])
                            if pwd.length > 0
                              raise_invalid_error!(UNESCAPED_USER_PWD) if pwd =~ UNSAFE
                              pwd_decoded = decode(pwd)
                    Severity: Minor
                    Found in lib/mongo/uri.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 parse! has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        def parse!(remaining)
                          hosts_and_db, options = remaining.split('?', 2)
                          if options && options.index('?')
                            raise_invalid_error!("Options contain an unescaped question mark (?), or the database name contains a question mark and was not escaped")
                          end
                    Severity: Minor
                    Found in lib/mongo/uri.rb - About 1 hr to fix

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

                              def initialize(command_name, database_name, address, request_id, operation_id, message, failure, duration)
                      Severity: Major
                      Found in lib/mongo/monitoring/event/command_failed.rb - About 1 hr to fix
                        Severity
                        Category
                        Status
                        Source
                        Language