mongodb/mongo-ruby-driver

View on GitHub

Showing 423 of 480 total issues

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

      private def select_server_impl(cluster, ping, session, write_aggregation, deprioritized, csot_timeout)
Severity: Minor
Found in lib/mongo/server_selector/base.rb - About 45 mins to fix

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

          def add_uri_option(key, value, uri_options)
            strategy = URI_OPTION_MAP[key.downcase]
            if strategy.nil?
              log_warn("Unsupported URI option '#{key}' on URI '#{@string}'. It will be ignored.")
              return
    Severity: Minor
    Found in lib/mongo/uri/options_mapper.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_one_and_delete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def find_one_and_delete(opts = {})
              with_session(opts) do |session|
                write_concern = if opts[:write_concern]
                  WriteConcern.get(opts[:write_concern])
                else
    Severity: Minor
    Found in lib/mongo/collection/view/writable.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 delete_many has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def delete_many(opts = {})
              with_session(opts) do |session|
                write_concern = if opts[:write_concern]
                  WriteConcern.get(opts[:write_concern])
                else
    Severity: Minor
    Found in lib/mongo/collection/view/writable.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 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

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

            def delete_one(opts = {})
              with_session(opts) do |session|
                write_concern = if opts[:write_concern]
                  WriteConcern.get(opts[:write_concern])
                else
    Severity: Minor
    Found in lib/mongo/collection/view/writable.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(view, result, server, options = {})
          unless result.is_a?(Operation::Result)
            raise ArgumentError, "Second argument must be a Mongo::Operation::Result: #{result.inspect}"
          end
    
    
    Severity: Minor
    Found in lib/mongo/cursor.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 selector has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

              module_function def selector(spec, connection)
                if spec[:collation] && !connection.features.collation_enabled?
                  raise Error::UnsupportedCollation
                end
    
    
    Severity: Minor
    Found in lib/mongo/operation/find/builder/command.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 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 apply_get_more_timeouts_to has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

            def apply_get_more_timeouts_to(spec, timeout_ms)
              view = context&.view
              return spec unless view
    
              if view.cursor_type == :tailable_await
    Severity: Minor
    Found in lib/mongo/operation/get_more/op_msg.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 build_message has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

          def build_message(connection, context)
            if self.session != context.session
              if self.session
                raise Error::InternalDriverError, "Operation session #{self.session.inspect} does not match context session #{context.session.inspect}"
              else
    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 update_many has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def update_many(documents, connection, context, operation_id, session, txn_num)
    Severity: Minor
    Found in lib/mongo/bulk_write.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

      Avoid deeply nested control flow statements.
      Open

                    if key.to_s.start_with?("$")
                      if Mongo.validate_update_replace
                        raise Error::InvalidReplacementDocument.new(key: key)
                      else
                        Error::InvalidReplacementDocument.warn(Logger.logger, key)
      Severity: Major
      Found in lib/mongo/bulk_write.rb - About 45 mins to fix

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

              def modern_write_with_retry(session, server, context, &block)
                txn_num = nil
                connection_succeeded = false
        
                server.with_connection(
        Severity: Minor
        Found in lib/mongo/retryable/write_worker.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_aes has 6 arguments (exceeds 4 allowed). Consider refactoring.
        Open

              def do_aes(key_binary_p, iv_binary_p, input_binary_p, output_binary_p,
                response_length_p, status_p, decrypt: false, mode: :CBC)
        Severity: Minor
        Found in lib/mongo/crypt/handle.rb - About 45 mins to fix

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

              module_function def transform_server_api(server_api)
                {}.tap do |doc|
                  if version = server_api[:version]
                    doc['apiVersion'] = version
                  end
          Severity: Minor
          Found in lib/mongo/utils.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