mongodb/mongo-ruby-driver

View on GitHub

Showing 181 of 235 total issues

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

        def try_next
          raise StopIteration.new if closed?
          retried = false

          begin
Severity: Minor
Found in lib/mongo/collection/view/change_stream.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 process has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    def process(result)
      unless implicit?
        set_operation_time(result)
        if cluster_time_doc = result.cluster_time
          advance_cluster_time(cluster_time_doc)
Severity: Minor
Found in lib/mongo/session.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 generate has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

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

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

          def initialize(options)
            options = Options::Mapper.transform_keys_to_symbols(options)
            options = Options::Mapper.transform_values_to_strings(options).freeze
    
            if options[:w]
    Severity: Minor
    Found in lib/mongo/write_concern/base.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 validate_host! has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def validate_host!(host)
          case host
          when /\A\[[\d:]+\](?::(\d+))?\z/
            # ipv6 with optional port
            if port_str = $1
    Severity: Minor
    Found in lib/mongo/uri.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 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 command_failed has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

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

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

            def command(server)
              sel = selector(server).dup
              add_write_concern!(sel)
              sel[Protocol::Msg::DATABASE_IDENTIFIER] = db_name
              unless server.standalone?
      Severity: Minor
      Found in lib/mongo/operation/shared/sessions_supported.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 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

            def initialize(host, port, host_name, timeout, family, options = {})
      Severity: Minor
      Found in lib/mongo/socket/ssl.rb - About 45 mins to fix

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

              def set_cert(context, options)
                # Since we clear cert_text during processing, we need to examine
                # ssl_cert_object here to avoid considering it if we have also
                # processed the text.
                if options[:ssl_cert]
        Severity: Minor
        Found in lib/mongo/socket/ssl.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 find_command has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

                def find_command
                  document = BSON::Document.new
                  document.store(FIND, collection)
                  document.store(FILTER, query_filter)
                  OPTION_MAPPINGS.each do |legacy, option|
        Severity: Minor
        Found in lib/mongo/protocol/query.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 retry_write has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def retry_write(original_error, session, txn_num, &block)
              # We do not request a scan of the cluster here, because error handling
              # for the error which triggered the retry should have updated the
              # server description and/or topology as necessary (specifically,
              # a socket error or a not master error should have marked the respective
        Severity: Minor
        Found in lib/mongo/retryable.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 retry_write_allowed? has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def retry_write_allowed?(session, write_concern)
              unless session && session.retry_writes?
                return false
              end
        
        
        Severity: Minor
        Found in lib/mongo/retryable.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 finalize has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def self.finalize(cursor_id, cluster, op_spec, server, session)
        Severity: Minor
        Found in lib/mongo/cursor.rb - About 35 mins to fix

          Method command_succeeded has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

                def command_succeeded(result, address, operation_id, payload, duration)
          Severity: Minor
          Found in lib/mongo/monitoring/publishable.rb - About 35 mins to fix

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

                def initialize(address, cluster, monitoring, event_listeners, options = {})
            Severity: Minor
            Found in lib/mongo/server.rb - About 35 mins to fix

              Method command_completed has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                    def command_completed(result, address, operation_id, payload, duration)
              Severity: Minor
              Found in lib/mongo/monitoring/publishable.rb - About 35 mins to fix
                Severity
                Category
                Status
                Source
                Language