mongodb/mongo-ruby-driver

View on GitHub

Showing 163 of 216 total issues

Method handshake! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def handshake!(socket)
        unless socket
          raise Error::HandshakeError, "Cannot handshake because there is no usable socket"
        end

Severity: Minor
Found in lib/mongo/server/connection.rb - About 25 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 update_options_for_slave_ok has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def update_options_for_slave_ok(opts, server)
        if (server.cluster.single? && !server.mongos?) || (read && read.slave_ok?)
          opts.dup.tap do |o|
            (o[:flags] ||= []) << SLAVE_OK
          end
Severity: Minor
Found in lib/mongo/operation/shared/read_preference_supported.rb - About 25 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 stale_primary? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def stale_primary?
      if updated_desc.election_id && updated_desc.set_version
        if topology.max_set_version && topology.max_election_id &&
            (updated_desc.set_version < topology.max_set_version ||
                (updated_desc.set_version == topology.max_set_version &&
Severity: Minor
Found in lib/mongo/cluster/sdam_flow.rb - About 25 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 connect! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def connect!
        if closed?
          if Lint.enabled?
            raise Error::LintError, "Reconnecting closed connections is no longer supported"
          else
Severity: Minor
Found in lib/mongo/server/connection.rb - About 25 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 n_modified has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def n_modified
          return 0 unless acknowledged?
          @replies.reduce(0) do |n, reply|
            if n && reply.documents.first[MODIFIED]
              n += reply.documents.first[MODIFIED]
Severity: Minor
Found in lib/mongo/operation/update/bulk_result.rb - About 25 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 get_more_command has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def get_more_command
          command = { :getMore => cursor.id, :collection => collection_name }
          command[:batchSize] = batch_size.abs if batch_size && batch_size != 0
          # If the max_await_time_ms option is set, then we set maxTimeMS on
          # the get more command.
Severity: Minor
Found in lib/mongo/cursor/builder/get_more_command.rb - About 25 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 validate_underscore_read_preference_mode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_underscore_read_preference_mode(mode)
      return unless enabled?
      if mode
        unless %w(primary primary_preferred secondary secondary_preferred nearest).include?(mode.to_s)
          raise Error::LintError, "Invalid read preference mode: #{mode}"
Severity: Minor
Found in lib/mongo/lint.rb - About 25 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 validate_camel_case_read_preference_mode has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_camel_case_read_preference_mode(mode)
      return unless enabled?
      if mode
        unless %w(primary primaryPreferred secondary secondaryPreferred nearest).include?(mode.to_s)
          raise Error::LintError, "Invalid read preference mode: #{mode}"
Severity: Minor
Found in lib/mongo/lint.rb - About 25 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 hangul_comp_one has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.hangul_comp_one(string)
    length = string.length
    if length>1 and 0 <= (lead =string[0].ord-LBASE) and lead  < LCOUNT and
                    0 <= (vowel=string[1].ord-VBASE) and vowel < VCOUNT
      lead_vowel = SBASE + (lead * VCOUNT + vowel) * TCOUNT
Severity: Minor
Found in lib/mongo/auth/stringprep/unicode_normalize/normalize.rb - About 25 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 6 (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 25 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 n_matched has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def n_matched
          return 0 unless acknowledged?
          @replies.reduce(0) do |n, reply|
            if upsert?(reply)
              reply.documents.first[N] - n_upserted
Severity: Minor
Found in lib/mongo/operation/update/bulk_result.rb - About 25 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 modern_read_with_retry has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def modern_read_with_retry(session, server_selector, &block)
      attempt = 0
      server = select_server(cluster, server_selector)
      begin
        yield server
Severity: Minor
Found in lib/mongo/retryable.rb - About 25 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 validate_underscore_read_preference has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate_underscore_read_preference(read_pref)
      return unless enabled?
      return if read_pref.nil?
      unless read_pref.is_a?(Hash)
        raise Error::LintError, "Read preference is not a hash: #{read_pref}"
Severity: Minor
Found in lib/mongo/lint.rb - About 25 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 get has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def get(options)
      return options if options.is_a?(Unacknowledged) || options.is_a?(Acknowledged)
      if options
        validate!(options)
        if unacknowledged?(options)
Severity: Minor
Found in lib/mongo/write_concern.rb - About 25 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 6 (exceeds 5 allowed). Consider refactoring.
Open

        def start(connection = nil)
          if connection && connection.features.op_msg_enabled?
            selector = LOGIN.merge(payload: payload, mechanism: LDAP::MECHANISM)
            selector[Protocol::Msg::DATABASE_IDENTIFIER] = Auth::EXTERNAL
            cluster_time = connection.mongos? && connection.cluster_time
Severity: Minor
Found in lib/mongo/auth/ldap/conversation.rb - About 25 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 continue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def continue(reply, connection = nil)
          validate!(reply)
          if connection && connection.features.op_msg_enabled?
            selector = LOGIN.merge(user: user.name, nonce: nonce, key: user.auth_key(nonce))
            selector[Protocol::Msg::DATABASE_IDENTIFIER] = user.auth_source
Severity: Minor
Found in lib/mongo/auth/cr/conversation.rb - About 25 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 update_selector_for_read_pref has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def update_selector_for_read_pref(sel, server)
        if read && server.mongos? && read_pref = read.to_mongos
          Mongo::Lint.validate_camel_case_read_preference(read_pref)
          sel = sel[:$query] ? sel : {:$query => sel}
          sel = sel.merge(:$readPreference => read_pref)
Severity: Minor
Found in lib/mongo/operation/shared/read_preference_supported.rb - About 25 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 validate! has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    def validate!(options)
      if options[W]
        if options[W] == 0 && (options[J] || options[FSYNC])
          raise Mongo::Error::InvalidWriteConcern.new
        elsif options[W].is_a?(Integer) && options[W] < 0
Severity: Minor
Found in lib/mongo/write_concern.rb - About 25 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 continue has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

        def continue(reply, connection = nil)
          validate_first_message!(reply)

          # The salted password needs to be calculated now; otherwise, if the
          # client key is cached from a previous authentication, the salt in the
Severity: Minor
Found in lib/mongo/auth/scram/conversation.rb - About 25 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 written_count has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def written_count
        if acknowledged?
          multiple? ? aggregate_written_count : (first_document[N] || 0)
        else
          0
Severity: Minor
Found in lib/mongo/operation/result.rb - About 25 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