diff --git a/.rubocop.yml b/.rubocop.yml index c21c088e8c..b0a7c7b953 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -51,6 +51,10 @@ Layout/SpaceInsideArrayLiteralBrackets: Layout/SpaceInsidePercentLiteralDelimiters: Enabled: false +Lint/Debugger: + DebuggerMethods: + - p + Metrics/ModuleLength: Enabled: false diff --git a/lib/mongo/collection/view.rb b/lib/mongo/collection/view.rb index dcc0f89752..279b1c02bc 100644 --- a/lib/mongo/collection/view.rb +++ b/lib/mongo/collection/view.rb @@ -1,5 +1,4 @@ # frozen_string_literal: true -# rubocop:todo all # Copyright (C) 2014-2020 MongoDB Inc. # @@ -27,7 +26,6 @@ module Mongo class Collection - # Representation of a query and options producing a result set of documents. # # A +View+ can be modified using helpers. Helpers can be chained, @@ -72,7 +70,7 @@ class View # Delegate to the cluster for the next primary. def_delegators :cluster, :next_primary - alias :selector :filter + alias selector filter # Compare two +View+ objects. # @@ -85,11 +83,12 @@ class View # @since 2.0.0 def ==(other) return false unless other.is_a?(View) + collection == other.collection && - filter == other.filter && - options == other.options + filter == other.filter && + options == other.options end - alias_method :eql?, :== + alias eql? == # A hash value for the +View+ composed of the collection namespace, # hash of the options and hash of the filter. @@ -101,7 +100,7 @@ def ==(other) # # @since 2.0.0 def hash - [ collection.namespace, options.hash, filter.hash ].hash + [ collection.namespace, options, filter ].hash end # Creates a new +View+. @@ -180,8 +179,8 @@ def initialize(collection, filter = {}, options = {}) # # @since 2.0.0 def inspect - "#" + "#" end # Get the write concern on this +View+. @@ -208,7 +207,9 @@ def new(options) View.new(collection, filter, options) end - def view; self; end + def view + self + end def with_session(opts = {}, &block) client.send(:with_session, @options.merge(opts), &block) diff --git a/spec/mongo/client_construction_spec.rb b/spec/mongo/client_construction_spec.rb index 442c0480b3..de4b9d6792 100644 --- a/spec/mongo/client_construction_spec.rb +++ b/spec/mongo/client_construction_spec.rb @@ -2659,11 +2659,9 @@ new_client.cluster.next_primary # Diagnostics - # rubocop:disable Style/IfUnlessModifier, Lint/Debugger - unless subscriber.started_events.empty? - p subscriber.started_events - end - # rubocop:enable Style/IfUnlessModifier, Lint/Debugger + # rubocop:disable Lint/Debugger + p subscriber.started_events unless subscriber.started_events.empty? + # rubocop:enable Lint/Debugger expect(subscriber.started_events.length).to eq 0 expect(new_client.cluster.topology.class).not_to be Mongo::Cluster::Topology::Unknown