diff options
author | Daniel Moody <daniel.moody@mongodb.com> | 2022-04-11 11:20:13 -0500 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-04-29 06:50:37 +0000 |
commit | 3e63636e66ced4aed6d1aaaafcdca7ae19cf96f2 (patch) | |
tree | 930ff9b35605d23d578933a45220f0fde6eff3be /src/mongo | |
parent | f9e7b6d7de6270a5ed7bf79da40d31a78633ca2a (diff) | |
download | mongo-3e63636e66ced4aed6d1aaaafcdca7ae19cf96f2.tar.gz |
SERVER-65278 added clang-tidy v4 builder and fixed clang-tidy v4 issues.
Diffstat (limited to 'src/mongo')
120 files changed, 188 insertions, 190 deletions
diff --git a/src/mongo/bson/bson_validate.cpp b/src/mongo/bson/bson_validate.cpp index 08659efecd1..2a342321d40 100644 --- a/src/mongo/bson/bson_validate.cpp +++ b/src/mongo/bson/bson_validate.cpp @@ -134,7 +134,7 @@ private: } template <typename T> - const T read() { + T read() { auto val = ptr; skip(sizeof(T)); return ConstDataView(val).read<LittleEndian<T>>(); diff --git a/src/mongo/bson/bsonelement.h b/src/mongo/bson/bsonelement.h index 237be73a14b..e0b3b8e4414 100644 --- a/src/mongo/bson/bsonelement.h +++ b/src/mongo/bson/bsonelement.h @@ -115,7 +115,7 @@ public: std::string String() const { return chk(mongo::String).str(); } - const StringData checkAndGetStringData() const { + StringData checkAndGetStringData() const { return chk(mongo::String).valueStringData(); } Date_t Date() const { @@ -318,7 +318,7 @@ public: return fieldNameSize_; } - const StringData fieldNameStringData() const { + StringData fieldNameStringData() const { return StringData(fieldName(), eoo() ? 0 : fieldNameSize() - 1); } @@ -569,7 +569,7 @@ public: * Returns a StringData pointing into this element's data. Does not validate that the * element is actually of type String. */ - const StringData valueStringData() const { + StringData valueStringData() const { return StringData(valuestr(), valuestrsize() - 1); } @@ -778,7 +778,7 @@ public: return (type() == BinData) && (binDataType() == bdt); } - const std::array<unsigned char, 16> uuid() const { + std::array<unsigned char, 16> uuid() const { int len = 0; const char* data = nullptr; if (isBinData(BinDataType::newUUID)) { @@ -792,7 +792,7 @@ public: return result; } - const std::array<unsigned char, 16> md5() const { + std::array<unsigned char, 16> md5() const { int len = 0; const char* data = nullptr; if (isBinData(BinDataType::MD5Type)) { @@ -822,7 +822,7 @@ public: return value() + 4; } - const mongo::OID dbrefOID() const { + mongo::OID dbrefOID() const { uassert(10064, "not a dbref", type() == DBRef); const char* start = value(); start += 4 + ConstDataView(start).read<LittleEndian<int>>(); diff --git a/src/mongo/bson/mutable/const_element.h b/src/mongo/bson/mutable/const_element.h index 5707b462668..3620d7c100f 100644 --- a/src/mongo/bson/mutable/const_element.h +++ b/src/mongo/bson/mutable/const_element.h @@ -71,7 +71,7 @@ public: inline size_t countChildren() const; inline bool hasValue() const; - inline const BSONElement getValue() const; + inline BSONElement getValue() const; inline double getValueDouble() const; inline StringData getValueString() const; @@ -198,7 +198,7 @@ inline bool ConstElement::hasValue() const { return _basis.hasValue(); } -inline const BSONElement ConstElement::getValue() const { +inline BSONElement ConstElement::getValue() const { return _basis.getValue(); } diff --git a/src/mongo/bson/mutable/document.cpp b/src/mongo/bson/mutable/document.cpp index db1dabe62b4..8a5ae28067e 100644 --- a/src/mongo/bson/mutable/document.cpp +++ b/src/mongo/bson/mutable/document.cpp @@ -1503,7 +1503,7 @@ bool Element::isIntegral() const { return ((type == mongo::NumberLong) || (type == mongo::NumberInt)); } -const BSONElement Element::getValue() const { +BSONElement Element::getValue() const { invariant(ok()); const Document::Impl& impl = getDocument().getImpl(); const ElementRep& thisRep = impl.getElementRep(_repIdx); diff --git a/src/mongo/bson/mutable/element.h b/src/mongo/bson/mutable/element.h index a0312c31b12..4fb43be5ab4 100644 --- a/src/mongo/bson/mutable/element.h +++ b/src/mongo/bson/mutable/element.h @@ -283,7 +283,7 @@ public: * BSONObj. However, the contents of the BSONElement returned here must be treated as * const. */ - const BSONElement getValue() const; + BSONElement getValue() const; /** Get the value from a double valued Element. */ inline double getValueDouble() const; diff --git a/src/mongo/client/dbclient_cursor.h b/src/mongo/client/dbclient_cursor.h index ad8eba20d77..520b1c1236c 100644 --- a/src/mongo/client/dbclient_cursor.h +++ b/src/mongo/client/dbclient_cursor.h @@ -390,7 +390,7 @@ public: return _c.getNamespaceString(); } - const long long getCursorId() const { + long long getCursorId() const { return _c.getCursorId(); } diff --git a/src/mongo/client/mongo_uri.cpp b/src/mongo/client/mongo_uri.cpp index fe125a4f060..835bfe51b92 100644 --- a/src/mongo/client/mongo_uri.cpp +++ b/src/mongo/client/mongo_uri.cpp @@ -533,7 +533,7 @@ StatusWith<MongoURI> MongoURI::parse(StringData url) try { return exceptionToStatus(); } -const boost::optional<std::string> MongoURI::getAppName() const { +boost::optional<std::string> MongoURI::getAppName() const { const auto optIter = _options.find("appName"); if (optIter != end(_options)) { return optIter->second; diff --git a/src/mongo/client/mongo_uri.h b/src/mongo/client/mongo_uri.h index 0118073f495..741ddf869c8 100644 --- a/src/mongo/client/mongo_uri.h +++ b/src/mongo/client/mongo_uri.h @@ -233,7 +233,7 @@ public: } - const boost::optional<std::string> getAppName() const; + boost::optional<std::string> getAppName() const; std::string canonicalizeURIAsString() const; diff --git a/src/mongo/client/sdam/mock_topology_manager.cpp b/src/mongo/client/sdam/mock_topology_manager.cpp index da01ff515bd..b45ccc57a7d 100644 --- a/src/mongo/client/sdam/mock_topology_manager.cpp +++ b/src/mongo/client/sdam/mock_topology_manager.cpp @@ -46,7 +46,7 @@ bool MockTopologyManager::onServerDescription(const HelloOutcome& helloOutcome) return true; } -const std::shared_ptr<TopologyDescription> MockTopologyManager::getTopologyDescription() const { +std::shared_ptr<TopologyDescription> MockTopologyManager::getTopologyDescription() const { stdx::lock_guard<mongo::Mutex> lock(_mutex); return _topologyDescription; } diff --git a/src/mongo/client/sdam/mock_topology_manager.h b/src/mongo/client/sdam/mock_topology_manager.h index e0827f6a422..c12afc758f2 100644 --- a/src/mongo/client/sdam/mock_topology_manager.h +++ b/src/mongo/client/sdam/mock_topology_manager.h @@ -42,7 +42,7 @@ public: void onServerRTTUpdated(HostAndPort hostAndPort, HelloRTT rtt) override; void setTopologyDescription(TopologyDescriptionPtr newDescription); - const TopologyDescriptionPtr getTopologyDescription() const override; + TopologyDescriptionPtr getTopologyDescription() const override; SemiFuture<std::vector<HostAndPort>> executeWithLock( std::function<SemiFuture<std::vector<HostAndPort>>(const TopologyDescriptionPtr&)> func) diff --git a/src/mongo/client/sdam/sdam_datatypes.cpp b/src/mongo/client/sdam/sdam_datatypes.cpp index 78e86bc3fae..3efea4140cb 100644 --- a/src/mongo/client/sdam/sdam_datatypes.cpp +++ b/src/mongo/client/sdam/sdam_datatypes.cpp @@ -83,7 +83,7 @@ std::ostream& operator<<(std::ostream& os, const ServerType serverType) { return os; } -const std::vector<ServerType> allServerTypes() { +std::vector<ServerType> allServerTypes() { static auto const result = std::vector<ServerType>{ServerType::kStandalone, ServerType::kMongos, ServerType::kRSPrimary, @@ -136,7 +136,7 @@ std::ostream& operator<<(std::ostream& os, const TopologyType topologyType) { return os; } -const std::vector<TopologyType> allTopologyTypes() { +std::vector<TopologyType> allTopologyTypes() { static auto const result = std::vector<TopologyType>{TopologyType::kSingle, TopologyType::kReplicaSetNoPrimary, TopologyType::kReplicaSetWithPrimary, diff --git a/src/mongo/client/sdam/sdam_datatypes.h b/src/mongo/client/sdam/sdam_datatypes.h index cf9a471079a..eae4bc4767a 100644 --- a/src/mongo/client/sdam/sdam_datatypes.h +++ b/src/mongo/client/sdam/sdam_datatypes.h @@ -53,7 +53,7 @@ enum class TopologyType { kSharded, kUnknown }; -const std::vector<TopologyType> allTopologyTypes(); +std::vector<TopologyType> allTopologyTypes(); std::string toString(TopologyType topologyType); StatusWith<TopologyType> parseTopologyType(StringData strTopologyType); std::ostream& operator<<(std::ostream& os, TopologyType topologyType); @@ -68,7 +68,7 @@ enum class ServerType { kRSGhost, kUnknown }; -const std::vector<ServerType> allServerTypes(); +std::vector<ServerType> allServerTypes(); std::string toString(ServerType serverType); StatusWith<ServerType> parseServerType(StringData strServerType); std::ostream& operator<<(std::ostream& os, ServerType serverType); diff --git a/src/mongo/client/sdam/server_description.cpp b/src/mongo/client/sdam/server_description.cpp index babe5d1a777..0fbba4dd33b 100644 --- a/src/mongo/client/sdam/server_description.cpp +++ b/src/mongo/client/sdam/server_description.cpp @@ -277,7 +277,7 @@ const boost::optional<std::string>& ServerDescription::getSetName() const { return _setName; } -const ElectionIdSetVersionPair ServerDescription::getElectionIdSetVersionPair() const { +ElectionIdSetVersionPair ServerDescription::getElectionIdSetVersionPair() const { return ElectionIdSetVersionPair{_electionId, _setVersion}; } @@ -285,7 +285,7 @@ const boost::optional<HostAndPort>& ServerDescription::getPrimary() const { return _primary; } -const mongo::Date_t ServerDescription::getLastUpdateTime() const { +mongo::Date_t ServerDescription::getLastUpdateTime() const { return *_lastUpdateTime; } @@ -436,7 +436,7 @@ ServerDescriptionPtr ServerDescription::cloneWithRTT(HelloRTT rtt) { return newServerDescription; } -const boost::optional<TopologyDescriptionPtr> ServerDescription::getTopologyDescription() { +boost::optional<TopologyDescriptionPtr> ServerDescription::getTopologyDescription() { if (_topologyDescription) { const auto result = _topologyDescription->lock(); invariant(result); diff --git a/src/mongo/client/sdam/server_description.h b/src/mongo/client/sdam/server_description.h index 4a7505a0973..0be4cfa426c 100644 --- a/src/mongo/client/sdam/server_description.h +++ b/src/mongo/client/sdam/server_description.h @@ -94,7 +94,7 @@ public: bool isDataBearingServer() const; // server 'time' - const Date_t getLastUpdateTime() const; + Date_t getLastUpdateTime() const; const boost::optional<Date_t>& getLastWriteDate() const; const boost::optional<repl::OpTime>& getOpTime() const; @@ -103,9 +103,9 @@ public: const std::set<HostAndPort>& getHosts() const; const std::set<HostAndPort>& getPassives() const; const std::set<HostAndPort>& getArbiters() const; - const ElectionIdSetVersionPair getElectionIdSetVersionPair() const; + ElectionIdSetVersionPair getElectionIdSetVersionPair() const; const boost::optional<TopologyVersion>& getTopologyVersion() const; - const boost::optional<TopologyDescriptionPtr> getTopologyDescription(); + boost::optional<TopologyDescriptionPtr> getTopologyDescription(); BSONObj toBson() const; std::string toString() const; diff --git a/src/mongo/client/sdam/topology_description.cpp b/src/mongo/client/sdam/topology_description.cpp index 9dd586f8a18..63ba155a3d8 100644 --- a/src/mongo/client/sdam/topology_description.cpp +++ b/src/mongo/client/sdam/topology_description.cpp @@ -141,7 +141,7 @@ std::vector<ServerDescriptionPtr> TopologyDescription::findServers( return result; } -const boost::optional<ServerDescriptionPtr> TopologyDescription::findServerByAddress( +boost::optional<ServerDescriptionPtr> TopologyDescription::findServerByAddress( HostAndPort address) const { auto results = findServers([address](const ServerDescriptionPtr& serverDescription) { return serverDescription->getAddress() == address; @@ -223,7 +223,7 @@ void TopologyDescription::checkWireCompatibilityVersions() { _compatibleError = (_compatible) ? boost::none : boost::make_optional(errorOss.str()); } -const std::string TopologyDescription::minimumRequiredMongoVersionString(int version) { +std::string TopologyDescription::minimumRequiredMongoVersionString(int version) { switch (version) { case RESUMABLE_INITIAL_SYNC: return "4.4"; diff --git a/src/mongo/client/sdam/topology_description.h b/src/mongo/client/sdam/topology_description.h index d8799356513..88da2d8b388 100644 --- a/src/mongo/client/sdam/topology_description.h +++ b/src/mongo/client/sdam/topology_description.h @@ -77,7 +77,7 @@ public: const boost::optional<int>& getLogicalSessionTimeoutMinutes() const; const Milliseconds& getHeartBeatFrequency() const; - const boost::optional<ServerDescriptionPtr> findServerByAddress(HostAndPort address) const; + boost::optional<ServerDescriptionPtr> findServerByAddress(HostAndPort address) const; bool containsServerAddress(const HostAndPort& address) const; std::vector<ServerDescriptionPtr> findServers( std::function<bool(const ServerDescriptionPtr&)> predicate) const; @@ -128,7 +128,7 @@ private: * Source: * https://github.com/mongodb/specifications/blob/master/source/wireversion-featurelist.rst */ - const std::string minimumRequiredMongoVersionString(int version); + std::string minimumRequiredMongoVersionString(int version); /** * From Server Discovery and Monitoring: diff --git a/src/mongo/client/sdam/topology_manager.cpp b/src/mongo/client/sdam/topology_manager.cpp index abd0dfc5e5b..f52fcc32330 100644 --- a/src/mongo/client/sdam/topology_manager.cpp +++ b/src/mongo/client/sdam/topology_manager.cpp @@ -116,7 +116,7 @@ bool TopologyManagerImpl::onServerDescription(const HelloOutcome& helloOutcome) return true; } -const std::shared_ptr<TopologyDescription> TopologyManagerImpl::getTopologyDescription() const { +std::shared_ptr<TopologyDescription> TopologyManagerImpl::getTopologyDescription() const { stdx::lock_guard<mongo::Mutex> lock(_mutex); return _topologyDescription; } diff --git a/src/mongo/client/sdam/topology_manager.h b/src/mongo/client/sdam/topology_manager.h index 3544144c911..6f70e327008 100644 --- a/src/mongo/client/sdam/topology_manager.h +++ b/src/mongo/client/sdam/topology_manager.h @@ -44,7 +44,7 @@ public: virtual void onServerRTTUpdated(HostAndPort hostAndPort, HelloRTT rtt) = 0; - virtual const TopologyDescriptionPtr getTopologyDescription() const = 0; + virtual TopologyDescriptionPtr getTopologyDescription() const = 0; virtual SemiFuture<std::vector<HostAndPort>> executeWithLock( std::function<SemiFuture<std::vector<HostAndPort>>(const TopologyDescriptionPtr&)> @@ -92,7 +92,7 @@ public: /** * Get the current TopologyDescription. This is safe to call from multiple threads. */ - const TopologyDescriptionPtr getTopologyDescription() const override; + TopologyDescriptionPtr getTopologyDescription() const override; /** * Executes the given function with the current TopologyDescription while holding the mutex. diff --git a/src/mongo/client/streamable_replica_set_monitor_discovery_time_processor.cpp b/src/mongo/client/streamable_replica_set_monitor_discovery_time_processor.cpp index 53ad894f94e..7a914b99985 100644 --- a/src/mongo/client/streamable_replica_set_monitor_discovery_time_processor.cpp +++ b/src/mongo/client/streamable_replica_set_monitor_discovery_time_processor.cpp @@ -58,7 +58,7 @@ void StreamableReplicaSetMonitor::StreamableReplicaSetMonitorDiscoveryTimeProces _elapsedTime.reset(); } } -const Milliseconds StreamableReplicaSetMonitor::StreamableReplicaSetMonitorDiscoveryTimeProcessor:: +Milliseconds StreamableReplicaSetMonitor::StreamableReplicaSetMonitorDiscoveryTimeProcessor:: getPrimaryServerChangeElapsedTime() const { stdx::lock_guard lock(_mutex); return Milliseconds(_elapsedTime.millis()); diff --git a/src/mongo/client/streamable_replica_set_monitor_discovery_time_processor.h b/src/mongo/client/streamable_replica_set_monitor_discovery_time_processor.h index ab786a5cb73..494c9e82fcc 100644 --- a/src/mongo/client/streamable_replica_set_monitor_discovery_time_processor.h +++ b/src/mongo/client/streamable_replica_set_monitor_discovery_time_processor.h @@ -38,7 +38,7 @@ public: void onTopologyDescriptionChangedEvent(sdam::TopologyDescriptionPtr previousDescription, sdam::TopologyDescriptionPtr newDescription) override; - const Milliseconds getPrimaryServerChangeElapsedTime() const; + Milliseconds getPrimaryServerChangeElapsedTime() const; private: mutable Mutex _mutex = diff --git a/src/mongo/crypto/fle_data_frames.h b/src/mongo/crypto/fle_data_frames.h index 23edc0378a7..897f273198a 100644 --- a/src/mongo/crypto/fle_data_frames.h +++ b/src/mongo/crypto/fle_data_frames.h @@ -112,7 +112,7 @@ public: FLEEncryptionFrame() : _plaintext(ConstDataRange(nullptr, 0)){}; - const ConstDataRange get() const& { + ConstDataRange get() const& { return ConstDataRange(_data); } @@ -120,11 +120,11 @@ public: return _key; } - const ConstDataRange getPlaintext() const { + ConstDataRange getPlaintext() const { return _plaintext; } - const ConstDataRange getAssociatedData() const { + ConstDataRange getAssociatedData() const { return ConstDataRange(_data.data(), kAssociatedDataLength); } @@ -177,7 +177,7 @@ public: return _key; } - const ConstDataRange getAssociatedData() const { + ConstDataRange getAssociatedData() const { return ConstDataRange(_data.data(), kAssociatedDataLength); } diff --git a/src/mongo/crypto/mechanism_scram.h b/src/mongo/crypto/mechanism_scram.h index 9c1fc91217d..fd70e585cfd 100644 --- a/src/mongo/crypto/mechanism_scram.h +++ b/src/mongo/crypto/mechanism_scram.h @@ -115,6 +115,8 @@ private: return std::tie(_password, _salt, _iterationCount); } + // clang-tidy flags this return type as readability-const-return-type + // NOLINTNEXTLINE(readability-const-return-type) static constexpr auto saltLength() -> decltype(HashBlock::kHashLength) { return HashBlock::kHashLength - 4; } diff --git a/src/mongo/db/auth/user.cpp b/src/mongo/db/auth/user.cpp index a418cfb8eb2..a80e833c9e7 100644 --- a/src/mongo/db/auth/user.cpp +++ b/src/mongo/db/auth/user.cpp @@ -103,7 +103,7 @@ const User::CredentialData& User::getCredentials() const { return _credentials; } -const ActionSet User::getActionsForResource(const ResourcePattern& resource) const { +ActionSet User::getActionsForResource(const ResourcePattern& resource) const { stdx::unordered_map<ResourcePattern, Privilege>::const_iterator it = _privileges.find(resource); if (it == _privileges.end()) { return ActionSet(); diff --git a/src/mongo/db/auth/user.h b/src/mongo/db/auth/user.h index 1aa5ad33da8..52b9e4e38d9 100644 --- a/src/mongo/db/auth/user.h +++ b/src/mongo/db/auth/user.h @@ -228,7 +228,7 @@ public: /** * Gets the set of actions this user is allowed to perform on the given resource. */ - const ActionSet getActionsForResource(const ResourcePattern& resource) const; + ActionSet getActionsForResource(const ResourcePattern& resource) const; /** * Returns true if the user has is allowed to perform an action on the given resource. diff --git a/src/mongo/db/catalog/collection.h b/src/mongo/db/catalog/collection.h index f4dec95dbc9..d65bc04e885 100644 --- a/src/mongo/db/catalog/collection.h +++ b/src/mongo/db/catalog/collection.h @@ -326,7 +326,7 @@ public: */ virtual std::shared_ptr<Ident> getSharedIdent() const = 0; - virtual const BSONObj getValidatorDoc() const = 0; + virtual BSONObj getValidatorDoc() const = 0; /** * Returns 'kPass' with an ok Status if the document passes this collection's schema validator. diff --git a/src/mongo/db/catalog/collection_impl.h b/src/mongo/db/catalog/collection_impl.h index fbfd83a6e0a..7d5bca73064 100644 --- a/src/mongo/db/catalog/collection_impl.h +++ b/src/mongo/db/catalog/collection_impl.h @@ -114,7 +114,7 @@ public: return {_shared, _shared->_recordStore.get()}; } - const BSONObj getValidatorDoc() const final { + BSONObj getValidatorDoc() const final { return _validator.validatorDoc.getOwned(); } diff --git a/src/mongo/db/catalog/collection_mock.h b/src/mongo/db/catalog/collection_mock.h index 901f7bdbbc9..aac15874e6b 100644 --- a/src/mongo/db/catalog/collection_mock.h +++ b/src/mongo/db/catalog/collection_mock.h @@ -96,7 +96,7 @@ public: std::abort(); } - const BSONObj getValidatorDoc() const { + BSONObj getValidatorDoc() const { std::abort(); } diff --git a/src/mongo/db/catalog/index_build_entry_test.cpp b/src/mongo/db/catalog/index_build_entry_test.cpp index ffa6a870874..0bac70f981b 100644 --- a/src/mongo/db/catalog/index_build_entry_test.cpp +++ b/src/mongo/db/catalog/index_build_entry_test.cpp @@ -45,7 +45,7 @@ namespace mongo { namespace { -const std::vector<std::string> generateIndexes(size_t numIndexes) { +std::vector<std::string> generateIndexes(size_t numIndexes) { std::vector<std::string> indexes; for (size_t i = 0; i < numIndexes; i++) { indexes.push_back("index_" + std::to_string(i)); @@ -53,7 +53,7 @@ const std::vector<std::string> generateIndexes(size_t numIndexes) { return indexes; } -const std::vector<HostAndPort> generateCommitReadyMembers(size_t numMembers) { +std::vector<HostAndPort> generateCommitReadyMembers(size_t numMembers) { std::vector<HostAndPort> members; for (size_t i = 0; i < numMembers; i++) { members.push_back(HostAndPort("localhost:27017")); diff --git a/src/mongo/db/cst/bson_lexer.cpp b/src/mongo/db/cst/bson_lexer.cpp index eaffb06752f..f1c2d9014a6 100644 --- a/src/mongo/db/cst/bson_lexer.cpp +++ b/src/mongo/db/cst/bson_lexer.cpp @@ -317,7 +317,8 @@ void BSONLexer::tokenize(BSONElement elem, bool includeFieldName) { context.emplace(this, elem.fieldNameStringData()); } else if (elem.fieldNameStringData().find('.') != std::string::npos) { auto components = std::vector<std::string>{}; - boost::split(components, elem.fieldNameStringData(), [](auto&& c) { return c == '.'; }); + const auto fieldName = elem.fieldNameStringData(); + boost::split(components, fieldName, [](auto c) { return c == '.'; }); pushToken(elem.fieldNameStringData(), ParserGen::token::DOTTED_FIELDNAME, std::move(components)); diff --git a/src/mongo/db/exec/bucket_unpacker.cpp b/src/mongo/db/exec/bucket_unpacker.cpp index aa28e4f3e0b..0651aae78ee 100644 --- a/src/mongo/db/exec/bucket_unpacker.cpp +++ b/src/mongo/db/exec/bucket_unpacker.cpp @@ -808,7 +808,7 @@ bool BucketUnpackerV1::getNext(MutableDocument& measurement, measurement.addField(*spec.metaFieldHashed(), metaValue); } - auto& currentIdx = timeElem.fieldNameStringData(); + const auto& currentIdx = timeElem.fieldNameStringData(); for (auto&& [colName, colIter] : _fieldIters) { if (auto&& elem = *colIter; colIter.more() && elem.fieldNameStringData() == currentIdx) { measurement.addField(colName, Value{elem}); @@ -838,7 +838,7 @@ void BucketUnpackerV1::extractSingleMeasurement( } for (auto&& dataElem : dataRegion) { - auto colName = dataElem.fieldNameStringData(); + const auto& colName = dataElem.fieldNameStringData(); if (!determineIncludeField(colName, behavior, unpackFieldsToIncludeExclude)) { continue; } @@ -1249,7 +1249,7 @@ void BucketUnpacker::reset(BSONObj&& bucket) { // Walk the data region of the bucket, and decide if an iterator should be set up based on the // include or exclude case. for (auto&& elem : dataRegion) { - auto& colName = elem.fieldNameStringData(); + auto colName = elem.fieldNameStringData(); if (colName == _spec.timeField()) { // Skip adding a FieldIterator for the timeField since the timestamp value from // _timeFieldIter can be placed accordingly in the materialized measurement. diff --git a/src/mongo/db/exec/document_value/document.cpp b/src/mongo/db/exec/document_value/document.cpp index dd833b3c28f..38fc2b8a758 100644 --- a/src/mongo/db/exec/document_value/document.cpp +++ b/src/mongo/db/exec/document_value/document.cpp @@ -698,7 +698,7 @@ static Value getNestedFieldHelper(const Document& doc, return getNestedFieldHelper(val.getDocument(), fieldNames, positions, level + 1); } -const Value Document::getNestedField(const FieldPath& path, vector<Position>* positions) const { +Value Document::getNestedField(const FieldPath& path, vector<Position>* positions) const { fassert(16489, path.getPathLength()); assertFieldPathLengthOK(path); return getNestedFieldHelper(*this, path, positions, 0); diff --git a/src/mongo/db/exec/document_value/document.h b/src/mongo/db/exec/document_value/document.h index 8fcfb28dd8b..81b87595ed6 100644 --- a/src/mongo/db/exec/document_value/document.h +++ b/src/mongo/db/exec/document_value/document.h @@ -137,16 +137,16 @@ public: * instead. */ template <typename T> - const Value operator[](T key) const { + Value operator[](T key) const { return getField(key); } template <typename T> - const Value getField(T key) const { + Value getField(T key) const { return storage().getField(key); } /// Look up a field by Position. See positionOf and getNestedField. - const Value getField(Position pos) const { + Value getField(Position pos) const { return storage().getField(pos).val; } @@ -155,8 +155,7 @@ public: * If 'positions' is non-null, it will be filled with a path suitable to pass to * MutableDocument::setNestedField(). */ - const Value getNestedField(const FieldPath& path, - std::vector<Position>* positions = nullptr) const; + Value getNestedField(const FieldPath& path, std::vector<Position>* positions = nullptr) const; /** * Returns field at given path as either BSONElement or Value, depending on how it is diff --git a/src/mongo/db/exec/document_value/document_internal.h b/src/mongo/db/exec/document_value/document_internal.h index 1387ca908b4..48a9135500c 100644 --- a/src/mongo/db/exec/document_value/document_internal.h +++ b/src/mongo/db/exec/document_value/document_internal.h @@ -183,7 +183,7 @@ public: * Get the field name that the iterator currently points to without bringing anything into * cache. */ - const StringData fieldName() { + StringData fieldName() { if (_it) { return _it->nameSD(); } diff --git a/src/mongo/db/field_ref_set.cpp b/src/mongo/db/field_ref_set.cpp index fccde6b2f09..39728b5f693 100644 --- a/src/mongo/db/field_ref_set.cpp +++ b/src/mongo/db/field_ref_set.cpp @@ -164,7 +164,7 @@ bool FieldRefSet::insert(const FieldRef* toInsert, const FieldRef** conflict) { return true; } -const std::string FieldRefSet::toString() const { +std::string FieldRefSet::toString() const { str::stream ss; ss << "{"; const auto last = _fieldSet.rbegin(); diff --git a/src/mongo/db/field_ref_set.h b/src/mongo/db/field_ref_set.h index 1100d0dbec9..001ea504e67 100644 --- a/src/mongo/db/field_ref_set.h +++ b/src/mongo/db/field_ref_set.h @@ -143,7 +143,7 @@ public: /** * A debug/log-able string */ - const std::string toString() const; + std::string toString() const; private: // A set of field_ref pointers, none of which is owned here. diff --git a/src/mongo/db/geo/geometry_container.h b/src/mongo/db/geo/geometry_container.h index bc73a6d9bd5..849996e9244 100644 --- a/src/mongo/db/geo/geometry_container.h +++ b/src/mongo/db/geo/geometry_container.h @@ -131,7 +131,7 @@ public: // TODO: Remove these hacks const CapWithCRS* getCapGeometryHack() const; - const BSONElement getGeoElement() const { + BSONElement getGeoElement() const { return _geoElm; } diff --git a/src/mongo/db/index_build_entry_helpers_test.cpp b/src/mongo/db/index_build_entry_helpers_test.cpp index f8563c66feb..9450bc58037 100644 --- a/src/mongo/db/index_build_entry_helpers_test.cpp +++ b/src/mongo/db/index_build_entry_helpers_test.cpp @@ -52,7 +52,7 @@ namespace mongo { namespace { using namespace indexbuildentryhelpers; -const std::vector<std::string> generateIndexes(size_t numIndexes) { +std::vector<std::string> generateIndexes(size_t numIndexes) { std::vector<std::string> indexes; for (size_t i = 0; i < numIndexes; i++) { indexes.push_back("index_" + std::to_string(i)); @@ -60,7 +60,7 @@ const std::vector<std::string> generateIndexes(size_t numIndexes) { return indexes; } -const std::vector<HostAndPort> generateCommitReadyMembers(size_t numMembers) { +std::vector<HostAndPort> generateCommitReadyMembers(size_t numMembers) { std::vector<HostAndPort> members; for (size_t i = 0; i < numMembers; i++) { members.push_back(HostAndPort("localhost:27017")); diff --git a/src/mongo/db/initialize_api_parameters.cpp b/src/mongo/db/initialize_api_parameters.cpp index 7700500b8fa..7e33daf526c 100644 --- a/src/mongo/db/initialize_api_parameters.cpp +++ b/src/mongo/db/initialize_api_parameters.cpp @@ -41,8 +41,7 @@ namespace mongo { -const APIParametersFromClient initializeAPIParameters(const BSONObj& requestBody, - Command* command) { +APIParametersFromClient initializeAPIParameters(const BSONObj& requestBody, Command* command) { auto apiParamsFromClient = APIParametersFromClient::parse("APIParametersFromClient"_sd, requestBody); diff --git a/src/mongo/db/initialize_api_parameters.h b/src/mongo/db/initialize_api_parameters.h index 05fa317a0f8..e360fd1d245 100644 --- a/src/mongo/db/initialize_api_parameters.h +++ b/src/mongo/db/initialize_api_parameters.h @@ -41,7 +41,7 @@ class OperationContext; * Parse a command's API Version parameters from a request and store the apiVersion, * apiStrict, and apiDeprecationErrors fields. */ -const APIParametersFromClient initializeAPIParameters(const BSONObj& requestBody, Command* command); +APIParametersFromClient initializeAPIParameters(const BSONObj& requestBody, Command* command); /** * If the server parameter "requireApiVersion" is set, enforce it. diff --git a/src/mongo/db/matcher/expression.h b/src/mongo/db/matcher/expression.h index 33ea3ce8790..3b38a4d099a 100644 --- a/src/mongo/db/matcher/expression.h +++ b/src/mongo/db/matcher/expression.h @@ -376,7 +376,7 @@ public: /** * Get the path of the leaf. Returns StringData() if there is no path (node is logical). */ - virtual const StringData path() const { + virtual StringData path() const { return StringData(); } /** diff --git a/src/mongo/db/matcher/expression_internal_bucket_geo_within.h b/src/mongo/db/matcher/expression_internal_bucket_geo_within.h index b46b6c5076c..34ec2ad9211 100644 --- a/src/mongo/db/matcher/expression_internal_bucket_geo_within.h +++ b/src/mongo/db/matcher/expression_internal_bucket_geo_within.h @@ -114,7 +114,7 @@ public: MONGO_UNREACHABLE; }; - const std::string getField() const { + std::string getField() const { return _field; } @@ -122,7 +122,7 @@ public: return *_geoContainer; } - const StringData path() const final { + StringData path() const final { return _indexField; } diff --git a/src/mongo/db/matcher/expression_path.h b/src/mongo/db/matcher/expression_path.h index 16182705a62..583cfef6a2a 100644 --- a/src/mongo/db/matcher/expression_path.h +++ b/src/mongo/db/matcher/expression_path.h @@ -66,7 +66,7 @@ public: return false; } - const StringData path() const override final { + StringData path() const override final { return _elementPath.fieldRef().dottedField(); } diff --git a/src/mongo/db/multi_key_path_tracker.cpp b/src/mongo/db/multi_key_path_tracker.cpp index 0ce2963dad4..6c1f52ddbe1 100644 --- a/src/mongo/db/multi_key_path_tracker.cpp +++ b/src/mongo/db/multi_key_path_tracker.cpp @@ -110,7 +110,7 @@ const WorkerMultikeyPathInfo& MultikeyPathTracker::getMultikeyPathInfo() const { return _multikeyPathInfo; } -const boost::optional<MultikeyPaths> MultikeyPathTracker::getMultikeyPathInfo( +boost::optional<MultikeyPaths> MultikeyPathTracker::getMultikeyPathInfo( const NamespaceString& nss, const std::string& indexName) { for (const auto& multikeyPathInfo : _multikeyPathInfo) { if (multikeyPathInfo.nss == nss && multikeyPathInfo.indexName == indexName) { diff --git a/src/mongo/db/multi_key_path_tracker.h b/src/mongo/db/multi_key_path_tracker.h index 808d6333f43..eeecf43a437 100644 --- a/src/mongo/db/multi_key_path_tracker.h +++ b/src/mongo/db/multi_key_path_tracker.h @@ -96,8 +96,8 @@ public: /** * Returns the multikey path information for the given inputs, or boost::none if none exist. */ - const boost::optional<MultikeyPaths> getMultikeyPathInfo(const NamespaceString& nss, - const std::string& indexName); + boost::optional<MultikeyPaths> getMultikeyPathInfo(const NamespaceString& nss, + const std::string& indexName); /** * Specifies that we should track multikey path information on this MultikeyPathTracker. This is diff --git a/src/mongo/db/ops/update_request.h b/src/mongo/db/ops/update_request.h index 3db331defa9..9c49e90fad6 100644 --- a/src/mongo/db/ops/update_request.h +++ b/src/mongo/db/ops/update_request.h @@ -257,7 +257,7 @@ public: return _stmtIds; } - const std::string toString() const { + std::string toString() const { StringBuilder builder; builder << " query: " << getQuery(); builder << " projection: " << _proj; diff --git a/src/mongo/db/pipeline/accumulator_multi.h b/src/mongo/db/pipeline/accumulator_multi.h index 13e7971ee0c..f5f57822ebb 100644 --- a/src/mongo/db/pipeline/accumulator_multi.h +++ b/src/mongo/db/pipeline/accumulator_multi.h @@ -335,7 +335,7 @@ public: */ void remove(const Value& val); - const SortPattern getSortPattern() const { + SortPattern getSortPattern() const { return _sortPattern; } diff --git a/src/mongo/db/pipeline/document_source_bucket_auto.cpp b/src/mongo/db/pipeline/document_source_bucket_auto.cpp index 10300e9c334..a2d00ad2472 100644 --- a/src/mongo/db/pipeline/document_source_bucket_auto.cpp +++ b/src/mongo/db/pipeline/document_source_bucket_auto.cpp @@ -443,7 +443,7 @@ DocumentSourceBucketAuto::DocumentSourceBucketAuto( } } -const boost::intrusive_ptr<Expression> DocumentSourceBucketAuto::getGroupByExpression() const { +boost::intrusive_ptr<Expression> DocumentSourceBucketAuto::getGroupByExpression() const { return _groupByExpression; } diff --git a/src/mongo/db/pipeline/document_source_bucket_auto.h b/src/mongo/db/pipeline/document_source_bucket_auto.h index 6a85e21c642..c79ff135ff6 100644 --- a/src/mongo/db/pipeline/document_source_bucket_auto.h +++ b/src/mongo/db/pipeline/document_source_bucket_auto.h @@ -92,7 +92,7 @@ public: static boost::intrusive_ptr<DocumentSource> createFromBson( BSONElement elem, const boost::intrusive_ptr<ExpressionContext>& pExpCtx); - const boost::intrusive_ptr<Expression> getGroupByExpression() const; + boost::intrusive_ptr<Expression> getGroupByExpression() const; const std::vector<AccumulationStatement>& getAccumulatedFields() const; protected: diff --git a/src/mongo/db/pipeline/document_source_group.h b/src/mongo/db/pipeline/document_source_group.h index 72fd2832bf1..dd392d8231d 100644 --- a/src/mongo/db/pipeline/document_source_group.h +++ b/src/mongo/db/pipeline/document_source_group.h @@ -145,7 +145,7 @@ public: /** * Returns the expression to use to determine the group id of each document. */ - const boost::intrusive_ptr<Expression> getIdExpression() const { + boost::intrusive_ptr<Expression> getIdExpression() const { return _idExpression; } diff --git a/src/mongo/db/pipeline/granularity_rounder.h b/src/mongo/db/pipeline/granularity_rounder.h index 82b067f5d0a..c0e9ac74b59 100644 --- a/src/mongo/db/pipeline/granularity_rounder.h +++ b/src/mongo/db/pipeline/granularity_rounder.h @@ -150,7 +150,7 @@ public: * Returns a vector that represents the preferred number series that this * GranularityRounderPreferredNumbers is using for rounding. */ - const std::vector<double> getSeries() const; + std::vector<double> getSeries() const; private: GranularityRounderPreferredNumbers(const boost::intrusive_ptr<ExpressionContext>& expCtx, diff --git a/src/mongo/db/pipeline/granularity_rounder_preferred_numbers.cpp b/src/mongo/db/pipeline/granularity_rounder_preferred_numbers.cpp index efdcf46e432..f60924b7a3f 100644 --- a/src/mongo/db/pipeline/granularity_rounder_preferred_numbers.cpp +++ b/src/mongo/db/pipeline/granularity_rounder_preferred_numbers.cpp @@ -348,7 +348,7 @@ string GranularityRounderPreferredNumbers::getName() { return _name; } -const vector<double> GranularityRounderPreferredNumbers::getSeries() const { +vector<double> GranularityRounderPreferredNumbers::getSeries() const { return _baseSeries; } } // namespace mongo diff --git a/src/mongo/db/pipeline/granularity_rounder_preferred_numbers_test.cpp b/src/mongo/db/pipeline/granularity_rounder_preferred_numbers_test.cpp index 0335b70a9d5..cbbc48766f7 100644 --- a/src/mongo/db/pipeline/granularity_rounder_preferred_numbers_test.cpp +++ b/src/mongo/db/pipeline/granularity_rounder_preferred_numbers_test.cpp @@ -60,7 +60,7 @@ void testEquals(Value actual, Value expected, double delta = DELTA) { } } -const vector<double> getSeries(intrusive_ptr<GranularityRounder> rounder) { +vector<double> getSeries(intrusive_ptr<GranularityRounder> rounder) { const auto* preferredNumbersRounder = dynamic_cast<GranularityRounderPreferredNumbers*>(rounder.get()); ASSERT(preferredNumbersRounder != nullptr); @@ -73,7 +73,7 @@ const vector<double> getSeries(intrusive_ptr<GranularityRounder> rounder) { * Decimal128. This helps with testing that the GranularityRounders work with the Decimal128 * datatype. */ -const vector<Decimal128> getSeriesDecimal(intrusive_ptr<GranularityRounder> rounder) { +vector<Decimal128> getSeriesDecimal(intrusive_ptr<GranularityRounder> rounder) { const auto* preferredNumbersRounder = dynamic_cast<GranularityRounderPreferredNumbers*>(rounder.get()); ASSERT(preferredNumbersRounder != nullptr); diff --git a/src/mongo/db/process_health/fault_manager_config.h b/src/mongo/db/process_health/fault_manager_config.h index 83d87b1d67d..5918c677e41 100644 --- a/src/mongo/db/process_health/fault_manager_config.h +++ b/src/mongo/db/process_health/fault_manager_config.h @@ -68,7 +68,7 @@ static const StringData FaultFacetTypeStrings[] = { FaultFacetType toFaultFacetType(HealthObserverTypeEnum type); -static const StringData FaultFacetType_serializer(const FaultFacetType value) { +static StringData FaultFacetType_serializer(const FaultFacetType value) { return FaultFacetTypeStrings[static_cast<int>(value)]; } diff --git a/src/mongo/db/query/canonical_query.h b/src/mongo/db/query/canonical_query.h index c06051347d6..e466379a5e8 100644 --- a/src/mongo/db/query/canonical_query.h +++ b/src/mongo/db/query/canonical_query.h @@ -118,11 +118,11 @@ public: */ static Status isValidNormalized(const MatchExpression* root); - const NamespaceString nss() const { + NamespaceString nss() const { invariant(_findCommand->getNamespaceOrUUID().nss()); return *_findCommand->getNamespaceOrUUID().nss(); } - const std::string ns() const { + std::string ns() const { return nss().ns(); } diff --git a/src/mongo/db/query/plan_explainer_impl.cpp b/src/mongo/db/query/plan_explainer_impl.cpp index 1e34cf73ebe..ca0bd6162a7 100644 --- a/src/mongo/db/query/plan_explainer_impl.cpp +++ b/src/mongo/db/query/plan_explainer_impl.cpp @@ -630,7 +630,7 @@ MultiPlanStage* getMultiPlanStage(PlanStage* root) { * If 'root' has a MultiPlanStage returns the index of its best plan. Otherwise returns an * initialized value. */ -const boost::optional<size_t> getWinningPlanIdx(PlanStage* root) { +boost::optional<size_t> getWinningPlanIdx(PlanStage* root) { if (auto mps = getMultiPlanStage(root); mps) { auto planIdx = mps->bestPlanIdx(); tassert(3420008, "Trying to get stats of a MultiPlanStage without winning plan", planIdx); diff --git a/src/mongo/db/record_id.h b/src/mongo/db/record_id.h index 58931fed9f9..544518ad544 100644 --- a/src/mongo/db/record_id.h +++ b/src/mongo/db/record_id.h @@ -168,7 +168,7 @@ public: * Returns the raw value to be used as a key in a RecordStore. Requires that this RecordId was * constructed with a binary string value, and invariants otherwise. */ - const StringData getStr() const { + StringData getStr() const { invariant( isStr(), fmt::format("expected RecordID string format, got: {}", _formatToString(_format))); diff --git a/src/mongo/db/repl/base_cloner.h b/src/mongo/db/repl/base_cloner.h index f6367d33126..524601725fd 100644 --- a/src/mongo/db/repl/base_cloner.h +++ b/src/mongo/db/repl/base_cloner.h @@ -162,7 +162,7 @@ protected: mutable Mutex _mutex = MONGO_MAKE_LATCH(_clonerName + "::_mutex"_sd); - const StringData getClonerName() const { + StringData getClonerName() const { return _clonerName; } diff --git a/src/mongo/db/repl/check_quorum_for_config_change_test.cpp b/src/mongo/db/repl/check_quorum_for_config_change_test.cpp index 46be125ec6e..3565f165ac0 100644 --- a/src/mongo/db/repl/check_quorum_for_config_change_test.cpp +++ b/src/mongo/db/repl/check_quorum_for_config_change_test.cpp @@ -203,7 +203,7 @@ TEST_F(CheckQuorumForInitiate, QuorumCheckFailedDueToSeveralDownNodes) { ASSERT_REASON_CONTAINS(status, "h5:1"); } -const BSONObj makeHeartbeatRequest(const ReplSetConfig& rsConfig, int myConfigIndex) { +BSONObj makeHeartbeatRequest(const ReplSetConfig& rsConfig, int myConfigIndex) { const MemberConfig& myConfig = rsConfig.getMemberAt(myConfigIndex); ReplSetHeartbeatArgsV1 hbArgs; hbArgs.setHeartbeatVersion(1); diff --git a/src/mongo/db/repl/hello_response.h b/src/mongo/db/repl/hello_response.h index 489f97e4d2d..953db13c570 100644 --- a/src/mongo/db/repl/hello_response.h +++ b/src/mongo/db/repl/hello_response.h @@ -137,7 +137,7 @@ public: return _secondaryDelaySecs; } - const stdx::unordered_map<std::string, std::string> getTags() const { + stdx::unordered_map<std::string, std::string> getTags() const { return _tags; } diff --git a/src/mongo/db/repl/oplog_entry.cpp b/src/mongo/db/repl/oplog_entry.cpp index f55e7352b79..2eb825ddf69 100644 --- a/src/mongo/db/repl/oplog_entry.cpp +++ b/src/mongo/db/repl/oplog_entry.cpp @@ -571,7 +571,7 @@ const boost::optional<mongo::LogicalSessionId>& OplogEntry::getSessionId() const return _entry.getSessionId(); } -const boost::optional<std::int64_t> OplogEntry::getTxnNumber() const { +boost::optional<std::int64_t> OplogEntry::getTxnNumber() const { return _entry.getTxnNumber(); } @@ -603,7 +603,7 @@ const boost::optional<mongo::BSONObj>& OplogEntry::getObject2() const { return _entry.getObject2(); } -const boost::optional<bool> OplogEntry::getUpsert() const { +boost::optional<bool> OplogEntry::getUpsert() const { return _entry.getUpsert(); } @@ -619,7 +619,7 @@ const mongo::Timestamp& OplogEntry::getTimestamp() const { return _entry.getTimestamp(); } -const boost::optional<std::int64_t> OplogEntry::getTerm() const { +boost::optional<std::int64_t> OplogEntry::getTerm() const { return _entry.getTerm(); } @@ -627,7 +627,7 @@ const mongo::Date_t& OplogEntry::getWallClockTime() const { return _entry.getWallClockTime(); } -const boost::optional<std::int64_t> OplogEntry::getHash() const& { +boost::optional<std::int64_t> OplogEntry::getHash() const& { return _entry.getHash(); } @@ -635,7 +635,7 @@ std::int64_t OplogEntry::getVersion() const { return _entry.getVersion(); } -const boost::optional<bool> OplogEntry::getFromMigrate() const& { +boost::optional<bool> OplogEntry::getFromMigrate() const& { return _entry.getFromMigrate(); } @@ -651,7 +651,7 @@ const boost::optional<mongo::repl::OpTime>& OplogEntry::getPostImageOpTime() con return _entry.getPostImageOpTime(); } -const boost::optional<RetryImageEnum> OplogEntry::getNeedsRetryImage() const { +boost::optional<RetryImageEnum> OplogEntry::getNeedsRetryImage() const { return _entry.getNeedsRetryImage(); } diff --git a/src/mongo/db/repl/oplog_entry.h b/src/mongo/db/repl/oplog_entry.h index 87a946fe634..3a25461dcb4 100644 --- a/src/mongo/db/repl/oplog_entry.h +++ b/src/mongo/db/repl/oplog_entry.h @@ -662,7 +662,7 @@ public: std::vector<StmtId> getStatementIds() const&; const OperationSessionInfo& getOperationSessionInfo() const; const boost::optional<mongo::LogicalSessionId>& getSessionId() const; - const boost::optional<std::int64_t> getTxnNumber() const; + boost::optional<std::int64_t> getTxnNumber() const; const DurableReplOperation& getDurableReplOperation() const; mongo::repl::OpTypeEnum getOpType() const; const boost::optional<mongo::TenantId>& getTid() const; @@ -670,19 +670,19 @@ public: const boost::optional<mongo::UUID>& getUuid() const; const mongo::BSONObj& getObject() const; const boost::optional<mongo::BSONObj>& getObject2() const; - const boost::optional<bool> getUpsert() const; + boost::optional<bool> getUpsert() const; const boost::optional<mongo::repl::OpTime>& getPreImageOpTime() const; const boost::optional<mongo::ShardId>& getDestinedRecipient() const; const mongo::Timestamp& getTimestamp() const; - const boost::optional<std::int64_t> getTerm() const; + boost::optional<std::int64_t> getTerm() const; const mongo::Date_t& getWallClockTime() const; - const boost::optional<std::int64_t> getHash() const&; + boost::optional<std::int64_t> getHash() const&; std::int64_t getVersion() const; - const boost::optional<bool> getFromMigrate() const&; + boost::optional<bool> getFromMigrate() const&; const boost::optional<mongo::UUID>& getFromTenantMigration() const&; const boost::optional<mongo::repl::OpTime>& getPrevWriteOpTimeInTransaction() const&; const boost::optional<mongo::repl::OpTime>& getPostImageOpTime() const&; - const boost::optional<RetryImageEnum> getNeedsRetryImage() const; + boost::optional<RetryImageEnum> getNeedsRetryImage() const; OpTime getOpTime() const; bool isCommand() const; bool isPartialTransaction() const; diff --git a/src/mongo/db/repl/repl_set_heartbeat_response.h b/src/mongo/db/repl/repl_set_heartbeat_response.h index 775047023f5..ce8fc367a95 100644 --- a/src/mongo/db/repl/repl_set_heartbeat_response.h +++ b/src/mongo/db/repl/repl_set_heartbeat_response.h @@ -67,7 +67,7 @@ public: /** * Returns toBSON().toString() */ - const std::string toString() const { + std::string toString() const { return toBSON().toString(); } diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index 3e6dca73357..c78135dcf59 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -2018,7 +2018,7 @@ ReplicationCoordinator::StatusAndDuration ReplicationCoordinatorImpl::awaitRepli return {interruptStatus, duration_cast<Milliseconds>(timer.elapsed())}; } - const auto wTimeoutDate = [&]() -> const Date_t { + auto wTimeoutDate = [&]() -> Date_t { auto clockSource = opCtx->getServiceContext()->getFastClockSource(); if (writeConcern.wDeadline != Date_t::max()) { return writeConcern.wDeadline; diff --git a/src/mongo/db/repl/tenant_migration_access_blocker_registry.h b/src/mongo/db/repl/tenant_migration_access_blocker_registry.h index b5967b82a9b..2e604c86c89 100644 --- a/src/mongo/db/repl/tenant_migration_access_blocker_registry.h +++ b/src/mongo/db/repl/tenant_migration_access_blocker_registry.h @@ -49,7 +49,7 @@ public: std::shared_ptr<TenantMigrationRecipientAccessBlocker> recipient) : _donor(donor), _recipient(recipient) {} - const std::shared_ptr<TenantMigrationAccessBlocker> getAccessBlocker( + std::shared_ptr<TenantMigrationAccessBlocker> getAccessBlocker( TenantMigrationAccessBlocker::BlockerType type) const { if (type == TenantMigrationAccessBlocker::BlockerType::kDonor) { return _donor; diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.cpp b/src/mongo/db/repl/tenant_migration_recipient_service.cpp index 3bd6f4110de..b4c7fba9ff8 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service.cpp +++ b/src/mongo/db/repl/tenant_migration_recipient_service.cpp @@ -2982,7 +2982,7 @@ const MigrationProtocolEnum& TenantMigrationRecipientService::Instance::getProto return _protocol; } -const TenantMigrationRecipientDocument TenantMigrationRecipientService::Instance::getState() const { +TenantMigrationRecipientDocument TenantMigrationRecipientService::Instance::getState() const { stdx::lock_guard lk(_mutex); return _stateDoc; } diff --git a/src/mongo/db/repl/tenant_migration_recipient_service.h b/src/mongo/db/repl/tenant_migration_recipient_service.h index 3378ffac337..9b2c7feab95 100644 --- a/src/mongo/db/repl/tenant_migration_recipient_service.h +++ b/src/mongo/db/repl/tenant_migration_recipient_service.h @@ -152,7 +152,7 @@ public: /* * Returns the recipient document state. */ - const TenantMigrationRecipientDocument getState() const; + TenantMigrationRecipientDocument getState() const; /** * To be called on the instance returned by PrimaryOnlyService::getOrCreate(). Returns an diff --git a/src/mongo/db/repl/topology_coordinator.cpp b/src/mongo/db/repl/topology_coordinator.cpp index 327f0069593..0b91a57a59b 100644 --- a/src/mongo/db/repl/topology_coordinator.cpp +++ b/src/mongo/db/repl/topology_coordinator.cpp @@ -383,7 +383,7 @@ HostAndPort TopologyCoordinator::_chooseNearbySyncSource(Date_t now, return syncSource; } -const OpTime TopologyCoordinator::_getOldestSyncOpTime() const { +OpTime TopologyCoordinator::_getOldestSyncOpTime() const { OpTime oldestSyncOpTime = OpTime(); // Find primary's oplog time. We will reject sync candidates that are more than @@ -2376,7 +2376,7 @@ MemberData& TopologyCoordinator::_selfMemberData() { return _memberData[_selfMemberDataIndex()]; } -const int TopologyCoordinator::_selfMemberDataIndex() const { +int TopologyCoordinator::_selfMemberDataIndex() const { invariant(!_memberData.empty()); if (_selfIndex >= 0) return _selfIndex; diff --git a/src/mongo/db/repl/topology_coordinator.h b/src/mongo/db/repl/topology_coordinator.h index 3d3084ddf76..c80daba86a9 100644 --- a/src/mongo/db/repl/topology_coordinator.h +++ b/src/mongo/db/repl/topology_coordinator.h @@ -986,7 +986,7 @@ private: // Returns the oldest acceptable OpTime that a node must have for us to choose it as our sync // source. - const OpTime _getOldestSyncOpTime() const; + OpTime _getOldestSyncOpTime() const; // Returns true if the candidate node is viable as our sync source. bool _isEligibleSyncSource(int candidateIndex, @@ -1038,7 +1038,7 @@ private: MemberData& _selfMemberData(); // Index of self member in member data. - const int _selfMemberDataIndex() const; + int _selfMemberDataIndex() const; /* * Returns information we have on the state of the node identified by memberId. Returns diff --git a/src/mongo/db/repl/transaction_oplog_application.cpp b/src/mongo/db/repl/transaction_oplog_application.cpp index b34403b0de6..f3a1fcea541 100644 --- a/src/mongo/db/repl/transaction_oplog_application.cpp +++ b/src/mongo/db/repl/transaction_oplog_application.cpp @@ -168,8 +168,7 @@ Status _applyTransactionFromOplogChain(OperationContext* opCtx, /** * Helper used to get previous oplog entry from the same transaction. */ -const repl::OplogEntry getPreviousOplogEntry(OperationContext* opCtx, - const repl::OplogEntry& entry) { +repl::OplogEntry getPreviousOplogEntry(OperationContext* opCtx, const repl::OplogEntry& entry) { const auto prevOpTime = entry.getPrevWriteOpTimeInTransaction(); invariant(prevOpTime); TransactionHistoryIterator iter(prevOpTime.get()); diff --git a/src/mongo/db/repl/transaction_oplog_application.h b/src/mongo/db/repl/transaction_oplog_application.h index 57f554acafe..52be9223475 100644 --- a/src/mongo/db/repl/transaction_oplog_application.h +++ b/src/mongo/db/repl/transaction_oplog_application.h @@ -53,8 +53,7 @@ Status applyAbortTransaction(OperationContext* opCtx, /** * Helper used to get previous oplog entry from the same transaction. */ -const repl::OplogEntry getPreviousOplogEntry(OperationContext* opCtx, - const repl::OplogEntry& entry); +repl::OplogEntry getPreviousOplogEntry(OperationContext* opCtx, const repl::OplogEntry& entry); /** * Follow an oplog chain and copy the operations to destination. Operations will be copied in diff --git a/src/mongo/db/s/auto_split_vector.cpp b/src/mongo/db/s/auto_split_vector.cpp index 8be8c5dde8b..45bc6ffe8b5 100644 --- a/src/mongo/db/s/auto_split_vector.cpp +++ b/src/mongo/db/s/auto_split_vector.cpp @@ -63,9 +63,9 @@ BSONObj prettyKey(const BSONObj& keyPattern, const BSONObj& key) { * object extended to cover the entire shardKey. See KeyPattern::extendRangeBound documentation for * some examples. */ -const std::tuple<BSONObj, BSONObj> getMinMaxExtendedBounds(const ShardKeyIndex& shardKeyIdx, - const BSONObj& min, - const BSONObj& max) { +std::tuple<BSONObj, BSONObj> getMinMaxExtendedBounds(const ShardKeyIndex& shardKeyIdx, + const BSONObj& min, + const BSONObj& max) { KeyPattern kp(shardKeyIdx.keyPattern()); // Extend min to get (min, MinKey, MinKey, ....) diff --git a/src/mongo/db/s/balancer/balancer.cpp b/src/mongo/db/s/balancer/balancer.cpp index 1b832d0f79e..37fd6eee24b 100644 --- a/src/mongo/db/s/balancer/balancer.cpp +++ b/src/mongo/db/s/balancer/balancer.cpp @@ -207,7 +207,7 @@ uint64_t getMaxChunkSizeBytes(OperationContext* opCtx, const CollectionType& col return coll.getMaxChunkSizeBytes().value_or(balancerConfig->getMaxChunkSizeBytes()); } -const int64_t getMaxChunkSizeMB(OperationContext* opCtx, const CollectionType& coll) { +int64_t getMaxChunkSizeMB(OperationContext* opCtx, const CollectionType& coll) { return getMaxChunkSizeBytes(opCtx, coll) / (1024 * 1024); } diff --git a/src/mongo/db/s/config/initial_split_policy_test.cpp b/src/mongo/db/s/config/initial_split_policy_test.cpp index 75d1f2ae0a1..fa8c312f8b7 100644 --- a/src/mongo/db/s/config/initial_split_policy_test.cpp +++ b/src/mongo/db/s/config/initial_split_policy_test.cpp @@ -199,9 +199,9 @@ public: * shardIds[i] is the id of shard for the chunk for chunkRanges[i]. * Checks that chunkRanges and shardIds have the same length. */ - const std::vector<ChunkType> makeChunks(const std::vector<ChunkRange> chunkRanges, - const std::vector<ShardId> shardIds, - Timestamp timeStamp) { + std::vector<ChunkType> makeChunks(const std::vector<ChunkRange> chunkRanges, + const std::vector<ShardId> shardIds, + Timestamp timeStamp) { ASSERT_EQ(chunkRanges.size(), shardIds.size()); std::vector<ChunkType> chunks; @@ -218,7 +218,7 @@ public: * Returns a vector of numShards shard ids with shard names * prefixed by _shardName */ - const std::vector<ShardId> makeShardIds(const int numShards) { + std::vector<ShardId> makeShardIds(const int numShards) { std::vector<ShardId> shardIds; for (int i = 0; i < numShards; i++) { shardIds.push_back(shardId(std::to_string(i))); @@ -226,7 +226,7 @@ public: return shardIds; } - const NamespaceString nss() { + NamespaceString nss() { return _nss; } @@ -242,11 +242,11 @@ public: return _shardKeyPattern.getKeyPattern(); } - const ShardId shardId(std::string shardNum) { + ShardId shardId(std::string shardNum) { return ShardId(_shardName + shardNum); } - const Timestamp timeStamp() { + Timestamp timeStamp() { return _timeStamp; } @@ -352,11 +352,11 @@ public: assertChunkVectorsAreEqual(expectedChunks, shardCollectionConfig.chunks); } - const std::string shardKey() { + std::string shardKey() { return _shardKey; } - const std::string zoneName(std::string zoneNum) { + std::string zoneName(std::string zoneNum) { return _zoneName + zoneNum; } diff --git a/src/mongo/db/s/dist_lock_manager.h b/src/mongo/db/s/dist_lock_manager.h index 556cdbd8788..7d6bdf8379a 100644 --- a/src/mongo/db/s/dist_lock_manager.h +++ b/src/mongo/db/s/dist_lock_manager.h @@ -76,7 +76,7 @@ public: ScopedLock(ScopedLock&& other); - const StringData getNs() { + StringData getNs() { return _ns; } diff --git a/src/mongo/db/s/rename_collection_participant_service.h b/src/mongo/db/s/rename_collection_participant_service.h index 965bd93e332..70599a843d3 100644 --- a/src/mongo/db/s/rename_collection_participant_service.h +++ b/src/mongo/db/s/rename_collection_participant_service.h @@ -96,7 +96,7 @@ public: */ bool hasSameOptions(const BSONObj& participantDoc); - const BSONObj doc() { + BSONObj doc() { return _doc.toBSON(); } diff --git a/src/mongo/db/s/resharding/resharding_util_test.cpp b/src/mongo/db/s/resharding/resharding_util_test.cpp index 888ba775ee5..6404975d2d5 100644 --- a/src/mongo/db/s/resharding/resharding_util_test.cpp +++ b/src/mongo/db/s/resharding/resharding_util_test.cpp @@ -68,7 +68,7 @@ protected: ConfigServerTestFixture::tearDown(); } - const std::string shardKey() { + std::string shardKey() { return _shardKey; } @@ -76,7 +76,7 @@ protected: return _shardKeyPattern.getKeyPattern(); } - const NamespaceString nss() { + NamespaceString nss() { return _nss; } @@ -84,7 +84,7 @@ protected: return ReshardingZoneType(zoneName, range.getMin(), range.getMax()); } - const std::string zoneName(std::string zoneNum) { + std::string zoneName(std::string zoneNum) { return "_zoneName" + zoneNum; } diff --git a/src/mongo/db/s/shard_key_index_util.cpp b/src/mongo/db/s/shard_key_index_util.cpp index 56d6ca08656..5269e6d87fb 100644 --- a/src/mongo/db/s/shard_key_index_util.cpp +++ b/src/mongo/db/s/shard_key_index_util.cpp @@ -40,7 +40,7 @@ namespace mongo { namespace { -const boost::optional<ShardKeyIndex> _findShardKeyPrefixedIndex( +boost::optional<ShardKeyIndex> _findShardKeyPrefixedIndex( OperationContext* opCtx, const CollectionPtr& collection, const IndexCatalog* indexCatalog, @@ -138,11 +138,11 @@ bool isLastShardKeyIndex(OperationContext* opCtx, .is_initialized(); } -const boost::optional<ShardKeyIndex> findShardKeyPrefixedIndex(OperationContext* opCtx, - const CollectionPtr& collection, - const IndexCatalog* indexCatalog, - const BSONObj& shardKey, - bool requireSingleKey) { +boost::optional<ShardKeyIndex> findShardKeyPrefixedIndex(OperationContext* opCtx, + const CollectionPtr& collection, + const IndexCatalog* indexCatalog, + const BSONObj& shardKey, + bool requireSingleKey) { return _findShardKeyPrefixedIndex( opCtx, collection, indexCatalog, boost::none, shardKey, requireSingleKey); } diff --git a/src/mongo/db/s/shard_key_index_util.h b/src/mongo/db/s/shard_key_index_util.h index db59c57ceca..515523b0803 100644 --- a/src/mongo/db/s/shard_key_index_util.h +++ b/src/mongo/db/s/shard_key_index_util.h @@ -85,11 +85,11 @@ bool isCompatibleWithShardKey(OperationContext* opCtx, * If the parameter 'requireSingleKey' is true, then this index additionally must not be * multi-key. */ -const boost::optional<ShardKeyIndex> findShardKeyPrefixedIndex(OperationContext* opCtx, - const CollectionPtr& collection, - const IndexCatalog* indexCatalog, - const BSONObj& shardKey, - bool requireSingleKey); +boost::optional<ShardKeyIndex> findShardKeyPrefixedIndex(OperationContext* opCtx, + const CollectionPtr& collection, + const IndexCatalog* indexCatalog, + const BSONObj& shardKey, + bool requireSingleKey); /** * Returns true if the given index name is the last remaining index that is compatible with the diff --git a/src/mongo/db/s/shard_local.cpp b/src/mongo/db/s/shard_local.cpp index fec64ebd8f2..eb4b1aba4ff 100644 --- a/src/mongo/db/s/shard_local.cpp +++ b/src/mongo/db/s/shard_local.cpp @@ -55,7 +55,7 @@ ShardLocal::ShardLocal(const ShardId& id) : Shard(id) { invariant(serverGlobalParams.clusterRole == ClusterRole::ConfigServer); } -const ConnectionString ShardLocal::getConnString() const { +ConnectionString ShardLocal::getConnString() const { return repl::ReplicationCoordinator::get(getGlobalServiceContext()) ->getConfigConnectionString(); } diff --git a/src/mongo/db/s/shard_local.h b/src/mongo/db/s/shard_local.h index e7c6e74b000..32405508df3 100644 --- a/src/mongo/db/s/shard_local.h +++ b/src/mongo/db/s/shard_local.h @@ -52,7 +52,7 @@ public: * These functions are implemented for the Shard interface's sake. They should not be called on * ShardLocal because doing so triggers invariants. */ - const ConnectionString getConnString() const override; + ConnectionString getConnString() const override; std::shared_ptr<RemoteCommandTargeter> getTargeter() const override; void updateReplSetMonitor(const HostAndPort& remoteHost, const Status& remoteCommandStatus) override; diff --git a/src/mongo/db/s/split_chunk_request_type.cpp b/src/mongo/db/s/split_chunk_request_type.cpp index 951e4d91e7a..2099e245521 100644 --- a/src/mongo/db/s/split_chunk_request_type.cpp +++ b/src/mongo/db/s/split_chunk_request_type.cpp @@ -181,7 +181,7 @@ const std::string& SplitChunkRequest::getShardName() const { return _shardName; } -const bool SplitChunkRequest::isFromChunkSplitter() const { +bool SplitChunkRequest::isFromChunkSplitter() const { return _fromChunkSplitter; } diff --git a/src/mongo/db/s/split_chunk_request_type.h b/src/mongo/db/s/split_chunk_request_type.h index 52cedce7b5c..7302755b998 100644 --- a/src/mongo/db/s/split_chunk_request_type.h +++ b/src/mongo/db/s/split_chunk_request_type.h @@ -90,7 +90,7 @@ public: const ChunkRange& getChunkRange() const; const std::vector<BSONObj>& getSplitPoints() const; const std::string& getShardName() const; - const bool isFromChunkSplitter() const; + bool isFromChunkSplitter() const; private: /** diff --git a/src/mongo/db/s/start_chunk_clone_request.h b/src/mongo/db/s/start_chunk_clone_request.h index c6ecba1f839..555f5fe0c4e 100644 --- a/src/mongo/db/s/start_chunk_clone_request.h +++ b/src/mongo/db/s/start_chunk_clone_request.h @@ -102,7 +102,7 @@ public: return _lsid; } - const TxnNumber getTxnNumber() const { + TxnNumber getTxnNumber() const { return _txnNumber; } diff --git a/src/mongo/db/s/transaction_coordinator_service.cpp b/src/mongo/db/s/transaction_coordinator_service.cpp index f936323dcee..70a6cd7ccd2 100644 --- a/src/mongo/db/s/transaction_coordinator_service.cpp +++ b/src/mongo/db/s/transaction_coordinator_service.cpp @@ -370,7 +370,7 @@ void TransactionCoordinatorService::cancelIfCommitNotYetStarted( } } -const std::vector<SharedSemiFuture<void>> +std::vector<SharedSemiFuture<void>> TransactionCoordinatorService::getAllRemovalFuturesForCoordinatorsForInternalTransactions( OperationContext* opCtx) { std::vector<SharedSemiFuture<void>> coordinatorStateDocRemovalFutures; diff --git a/src/mongo/db/s/transaction_coordinator_service.h b/src/mongo/db/s/transaction_coordinator_service.h index f0795d857e0..33cd4153009 100644 --- a/src/mongo/db/s/transaction_coordinator_service.h +++ b/src/mongo/db/s/transaction_coordinator_service.h @@ -132,8 +132,8 @@ public: * Returns a vector of futures that wait on the removal of transaction * coordinators for internal transactions. */ - const std::vector<SharedSemiFuture<void>> - getAllRemovalFuturesForCoordinatorsForInternalTransactions(OperationContext* opCtx); + std::vector<SharedSemiFuture<void>> getAllRemovalFuturesForCoordinatorsForInternalTransactions( + OperationContext* opCtx); private: struct CatalogAndScheduler { diff --git a/src/mongo/db/s/transaction_coordinator_worker_curop_info.h b/src/mongo/db/s/transaction_coordinator_worker_curop_info.h index a1cd91f70ed..f21dc7b949c 100644 --- a/src/mongo/db/s/transaction_coordinator_worker_curop_info.h +++ b/src/mongo/db/s/transaction_coordinator_worker_curop_info.h @@ -46,7 +46,7 @@ public: void reportState(BSONObjBuilder* parent) const; private: - static const std::string toString(CoordinatorAction action); + static std::string toString(CoordinatorAction action); LogicalSessionId _lsid; TxnNumberAndRetryCounter _txnNumberAndRetryCounter; diff --git a/src/mongo/db/s/transaction_coordinator_worker_curop_repository_mongod.cpp b/src/mongo/db/s/transaction_coordinator_worker_curop_repository_mongod.cpp index e1604738ef3..34d5622cca9 100644 --- a/src/mongo/db/s/transaction_coordinator_worker_curop_repository_mongod.cpp +++ b/src/mongo/db/s/transaction_coordinator_worker_curop_repository_mongod.cpp @@ -87,7 +87,7 @@ TransactionCoordinatorWorkerCurOpInfo::TransactionCoordinatorWorkerCurOpInfo( _action(action) {} -const std::string TransactionCoordinatorWorkerCurOpInfo::toString(CoordinatorAction action) { +std::string TransactionCoordinatorWorkerCurOpInfo::toString(CoordinatorAction action) { switch (action) { case CoordinatorAction::kSendingPrepare: return "sendingPrepare"; diff --git a/src/mongo/db/s/type_lockpings.h b/src/mongo/db/s/type_lockpings.h index e834e3ae32f..480045f16ea 100644 --- a/src/mongo/db/s/type_lockpings.h +++ b/src/mongo/db/s/type_lockpings.h @@ -79,7 +79,7 @@ public: } void setProcess(const std::string& process); - const Date_t getPing() const { + Date_t getPing() const { return _ping.get(); } void setPing(Date_t ping); diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp index 8d1999534d8..a9815a09235 100644 --- a/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp +++ b/src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp @@ -1023,7 +1023,7 @@ Status WiredTigerKVEngine::disableIncrementalBackup(OperationContext* opCtx) { namespace { -const boost::filesystem::path constructFilePath(std::string path, std::string filename) { +boost::filesystem::path constructFilePath(std::string path, std::string filename) { const auto directoryPath = boost::filesystem::path(path); const auto wiredTigerLogFilePrefix = "WiredTigerLog"; diff --git a/src/mongo/db/tenant_database_name.h b/src/mongo/db/tenant_database_name.h index 4ae9e6a6cf1..27aca9131d9 100644 --- a/src/mongo/db/tenant_database_name.h +++ b/src/mongo/db/tenant_database_name.h @@ -73,7 +73,7 @@ public: static TenantDatabaseName createSystemTenantDbName(StringData dbName); - const boost::optional<TenantId> tenantId() const { + boost::optional<TenantId> tenantId() const { return _tenantId; } diff --git a/src/mongo/db/timeseries/bucket_catalog.cpp b/src/mongo/db/timeseries/bucket_catalog.cpp index c16da6175df..5712ce17523 100644 --- a/src/mongo/db/timeseries/bucket_catalog.cpp +++ b/src/mongo/db/timeseries/bucket_catalog.cpp @@ -1153,7 +1153,7 @@ std::shared_ptr<BucketCatalog::ExecutionStats> BucketCatalog::_getExecutionStats return res.first->second; } -const std::shared_ptr<BucketCatalog::ExecutionStats> BucketCatalog::_getExecutionStats( +std::shared_ptr<BucketCatalog::ExecutionStats> BucketCatalog::_getExecutionStats( const NamespaceString& ns) const { static const auto kEmptyStats{std::make_shared<ExecutionStats>()}; diff --git a/src/mongo/db/timeseries/bucket_catalog.h b/src/mongo/db/timeseries/bucket_catalog.h index 9807cdea1a1..eeef9b30c11 100644 --- a/src/mongo/db/timeseries/bucket_catalog.h +++ b/src/mongo/db/timeseries/bucket_catalog.h @@ -461,7 +461,7 @@ private: const CreationInfo& info); std::shared_ptr<ExecutionStats> _getExecutionStats(const NamespaceString& ns); - const std::shared_ptr<ExecutionStats> _getExecutionStats(const NamespaceString& ns) const; + std::shared_ptr<ExecutionStats> _getExecutionStats(const NamespaceString& ns) const; /** * Retreives the bucket state if it is tracked in the catalog. diff --git a/src/mongo/db/transaction_participant.cpp b/src/mongo/db/transaction_participant.cpp index e617491e0b2..a6f8e7fc1c7 100644 --- a/src/mongo/db/transaction_participant.cpp +++ b/src/mongo/db/transaction_participant.cpp @@ -1683,7 +1683,7 @@ void TransactionParticipant::Participant::setPrepareOpTimeForRecovery(OperationC o(lk).recoveryPrepareOpTime = prepareOpTime; } -const repl::OpTime TransactionParticipant::Participant::getPrepareOpTimeForRecovery() const { +repl::OpTime TransactionParticipant::Participant::getPrepareOpTimeForRecovery() const { return o().recoveryPrepareOpTime; } diff --git a/src/mongo/db/transaction_participant.h b/src/mongo/db/transaction_participant.h index 26fb9b7ec7d..fa5b98757af 100644 --- a/src/mongo/db/transaction_participant.h +++ b/src/mongo/db/transaction_participant.h @@ -567,7 +567,7 @@ public: /** * Gets the prepare optime used for recovery. Returns a null optime if unset. */ - const repl::OpTime getPrepareOpTimeForRecovery() const; + repl::OpTime getPrepareOpTimeForRecovery() const; /** * Commits the transaction, including committing the write unit of work and updating diff --git a/src/mongo/dbtests/clienttests.cpp b/src/mongo/dbtests/clienttests.cpp index 104df26d599..427ec9926c6 100644 --- a/src/mongo/dbtests/clienttests.cpp +++ b/src/mongo/dbtests/clienttests.cpp @@ -62,7 +62,7 @@ public: db.dropCollection(_ns); } - const NamespaceString nss() { + NamespaceString nss() { return NamespaceString(_ns); } diff --git a/src/mongo/dbtests/mock/mock_conn_registry.cpp b/src/mongo/dbtests/mock/mock_conn_registry.cpp index 018cc8ba7b2..1508c7877e4 100644 --- a/src/mongo/dbtests/mock/mock_conn_registry.cpp +++ b/src/mongo/dbtests/mock/mock_conn_registry.cpp @@ -73,8 +73,7 @@ bool MockConnRegistry::removeServer(const std::string& hostName) { return _registry.erase(hostName) == 1; } -MockRemoteDBServer* const MockConnRegistry::getMockRemoteDBServer( - const std::string& hostName) const { +MockRemoteDBServer* MockConnRegistry::getMockRemoteDBServer(const std::string& hostName) const { stdx::lock_guard lk(_registryMutex); auto iter = _registry.find(hostName); if (iter == _registry.end()) diff --git a/src/mongo/dbtests/mock/mock_conn_registry.h b/src/mongo/dbtests/mock/mock_conn_registry.h index 354cf68d181..798671caeaf 100644 --- a/src/mongo/dbtests/mock/mock_conn_registry.h +++ b/src/mongo/dbtests/mock/mock_conn_registry.h @@ -75,7 +75,7 @@ public: * @return the pointer to MockRemoteDBServer for the given hostname if available in * the registry. Otherwise, returns nullptr. */ - MockRemoteDBServer* const getMockRemoteDBServer(const std::string& hostName) const; + MockRemoteDBServer* getMockRemoteDBServer(const std::string& hostName) const; /** * Clears the registry. diff --git a/src/mongo/dbtests/querytests.cpp b/src/mongo/dbtests/querytests.cpp index 1309ecedc8c..576a791a1bf 100644 --- a/src/mongo/dbtests/querytests.cpp +++ b/src/mongo/dbtests/querytests.cpp @@ -927,7 +927,7 @@ public: static const char* ns() { return "unittests.querytests.AutoResetIndexCache"; } - static const NamespaceString nss() { + static NamespaceString nss() { return NamespaceString(ns()); } void index() { diff --git a/src/mongo/embedded/stitch_support/stitch_support_test.cpp b/src/mongo/embedded/stitch_support/stitch_support_test.cpp index 0b2807c9d02..fa0d4ecd55e 100644 --- a/src/mongo/embedded/stitch_support/stitch_support_test.cpp +++ b/src/mongo/embedded/stitch_support/stitch_support_test.cpp @@ -284,7 +284,7 @@ protected: return std::string(stitch_support_v1_status_get_explanation(updateStatus)); } - const std::string getModifiedPaths() { + std::string getModifiedPaths() { ASSERT(updateDetails); std::stringstream ss; diff --git a/src/mongo/executor/task_executor_cursor.h b/src/mongo/executor/task_executor_cursor.h index f7f545de2a5..0523f38a9a5 100644 --- a/src/mongo/executor/task_executor_cursor.h +++ b/src/mongo/executor/task_executor_cursor.h @@ -124,7 +124,7 @@ public: */ void populateCursor(OperationContext* opCtx); - const CursorId getCursorId() const { + CursorId getCursorId() const { return _cursorId; } diff --git a/src/mongo/idl/idl_test_types.h b/src/mongo/idl/idl_test_types.h index 990d3d64406..0d369b681bb 100644 --- a/src/mongo/idl/idl_test_types.h +++ b/src/mongo/idl/idl_test_types.h @@ -78,7 +78,7 @@ public: return object; } - const BSONObj serializeToBSON() const { + BSONObj serializeToBSON() const { return _obj; } diff --git a/src/mongo/logv2/attribute_storage.h b/src/mongo/logv2/attribute_storage.h index 862e6c8d6a5..dbd9bdd20fa 100644 --- a/src/mongo/logv2/attribute_storage.h +++ b/src/mongo/logv2/attribute_storage.h @@ -200,10 +200,10 @@ inline StringData mapValue(const char* value) { return value; } -inline const BSONObj mapValue(BSONObj const& value) { +inline BSONObj mapValue(BSONObj const& value) { return value; } -inline const BSONArray mapValue(BSONArray const& value) { +inline BSONArray mapValue(BSONArray const& value) { return value; } inline CustomAttributeValue mapValue(BSONElement const& val) { diff --git a/src/mongo/s/catalog/type_chunk.cpp b/src/mongo/s/catalog/type_chunk.cpp index 61c964af93d..a74bd9d879c 100644 --- a/src/mongo/s/catalog/type_chunk.cpp +++ b/src/mongo/s/catalog/type_chunk.cpp @@ -138,7 +138,7 @@ BSONObj ChunkRange::toBSON() const { return builder.obj(); } -const Status ChunkRange::extractKeyPattern(KeyPattern* shardKeyPatternOut) const { +Status ChunkRange::extractKeyPattern(KeyPattern* shardKeyPatternOut) const { BSONObjIterator min(getMin()); BSONObjIterator max(getMax()); BSONObjBuilder b; diff --git a/src/mongo/s/catalog/type_chunk.h b/src/mongo/s/catalog/type_chunk.h index be05f7af42f..c76a0d1c507 100644 --- a/src/mongo/s/catalog/type_chunk.h +++ b/src/mongo/s/catalog/type_chunk.h @@ -79,7 +79,7 @@ public: return _maxKey; } - const Status extractKeyPattern(KeyPattern* shardKeyPatternOut) const; + Status extractKeyPattern(KeyPattern* shardKeyPatternOut) const; /** * Checks whether the specified key is within the bounds of this chunk range. diff --git a/src/mongo/s/catalog/type_config_version.h b/src/mongo/s/catalog/type_config_version.h index 9734061ef4d..2881b34ab3c 100644 --- a/src/mongo/s/catalog/type_config_version.h +++ b/src/mongo/s/catalog/type_config_version.h @@ -107,7 +107,7 @@ public: } void setClusterId(const OID& clusterId); - const std::vector<MongoVersionRange> getExcludingMongoVersions() const { + std::vector<MongoVersionRange> getExcludingMongoVersions() const { if (!isExcludingMongoVersionsSet()) { return std::vector<MongoVersionRange>(); } diff --git a/src/mongo/s/client/shard.h b/src/mongo/s/client/shard.h index f690341fcb2..ae64564a01f 100644 --- a/src/mongo/s/client/shard.h +++ b/src/mongo/s/client/shard.h @@ -109,7 +109,7 @@ public: /** * Returns the current connection string for the shard. */ - virtual const ConnectionString getConnString() const = 0; + virtual ConnectionString getConnString() const = 0; /** * Returns the RemoteCommandTargeter for the hosts in this shard. diff --git a/src/mongo/s/client/shard_remote.h b/src/mongo/s/client/shard_remote.h index 6c99a8a5247..6dbc7b32e6d 100644 --- a/src/mongo/s/client/shard_remote.h +++ b/src/mongo/s/client/shard_remote.h @@ -56,7 +56,7 @@ public: ~ShardRemote(); - const ConnectionString getConnString() const override { + ConnectionString getConnString() const override { return _connString; } diff --git a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp index 1dbb6ad427d..f80a1694cd4 100644 --- a/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp +++ b/src/mongo/s/commands/cluster_enable_sharding_cmd.cpp @@ -95,7 +95,7 @@ public: } private: - const StringData getDbName() const { + StringData getDbName() const { return request().getCommandParameter(); } NamespaceString ns() const override { diff --git a/src/mongo/s/request_types/move_chunk_request.h b/src/mongo/s/request_types/move_chunk_request.h index d71ff3b4a2a..ab403492d1e 100644 --- a/src/mongo/s/request_types/move_chunk_request.h +++ b/src/mongo/s/request_types/move_chunk_request.h @@ -114,7 +114,7 @@ public: return _range.getMax(); } - const OID getVersionEpoch() const { + OID getVersionEpoch() const { return _versionEpoch; } diff --git a/src/mongo/s/request_types/set_shard_version_request.cpp b/src/mongo/s/request_types/set_shard_version_request.cpp index af46669d3de..d6b7a463129 100644 --- a/src/mongo/s/request_types/set_shard_version_request.cpp +++ b/src/mongo/s/request_types/set_shard_version_request.cpp @@ -135,7 +135,7 @@ const NamespaceString& SetShardVersionRequest::getNS() const { return _nss.get(); } -const ChunkVersion SetShardVersionRequest::getNSVersion() const { +ChunkVersion SetShardVersionRequest::getNSVersion() const { return _version.get(); } diff --git a/src/mongo/s/request_types/set_shard_version_request.h b/src/mongo/s/request_types/set_shard_version_request.h index 44cacff0415..c0d9aa1c0c4 100644 --- a/src/mongo/s/request_types/set_shard_version_request.h +++ b/src/mongo/s/request_types/set_shard_version_request.h @@ -92,7 +92,7 @@ public: * Returns the version of the namespace associated with this set shard version request. It is * illegal to access this field if isInit() returns true. */ - const ChunkVersion getNSVersion() const; + ChunkVersion getNSVersion() const; private: SetShardVersionRequest(); diff --git a/src/mongo/s/write_ops/batch_write_exec.cpp b/src/mongo/s/write_ops/batch_write_exec.cpp index 45b89579dbb..2a580115aa7 100644 --- a/src/mongo/s/write_ops/batch_write_exec.cpp +++ b/src/mongo/s/write_ops/batch_write_exec.cpp @@ -514,7 +514,7 @@ const HostOpTimeMap& BatchWriteExecStats::getWriteOpTimes() const { return _writeOpTimes; } -const boost::optional<int> BatchWriteExecStats::getNumShardsOwningChunks() const { +boost::optional<int> BatchWriteExecStats::getNumShardsOwningChunks() const { return _numShardsOwningChunks; } diff --git a/src/mongo/s/write_ops/batch_write_exec.h b/src/mongo/s/write_ops/batch_write_exec.h index 3bd4a135fe9..b4016f22d77 100644 --- a/src/mongo/s/write_ops/batch_write_exec.h +++ b/src/mongo/s/write_ops/batch_write_exec.h @@ -97,7 +97,7 @@ public: const std::set<ShardId>& getTargetedShards() const; const HostOpTimeMap& getWriteOpTimes() const; - const boost::optional<int> getNumShardsOwningChunks() const; + boost::optional<int> getNumShardsOwningChunks() const; // Expose via helpers if this gets more complex diff --git a/src/mongo/scripting/deadline_monitor_test.cpp b/src/mongo/scripting/deadline_monitor_test.cpp index 1d95d761ee3..8024bc8982e 100644 --- a/src/mongo/scripting/deadline_monitor_test.cpp +++ b/src/mongo/scripting/deadline_monitor_test.cpp @@ -74,7 +74,7 @@ public: _group->noteKill(); } void interrupt() {} - const bool isKillPending() { + bool isKillPending() { return killPending; } TaskGroup* _group; diff --git a/src/mongo/transport/mock_session.h b/src/mongo/transport/mock_session.h index 139db86c4ad..9f6c662e251 100644 --- a/src/mongo/transport/mock_session.h +++ b/src/mongo/transport/mock_session.h @@ -87,7 +87,7 @@ public: return nullptr; } - const std::shared_ptr<SSLManagerInterface> getSSLManager() const override { + std::shared_ptr<SSLManagerInterface> getSSLManager() const override { return nullptr; } #endif diff --git a/src/mongo/transport/session.h b/src/mongo/transport/session.h index 12a8c983615..3fb79183db4 100644 --- a/src/mongo/transport/session.h +++ b/src/mongo/transport/session.h @@ -212,7 +212,7 @@ public: /** * Get the SSL manager associated with this session. */ - virtual const std::shared_ptr<SSLManagerInterface> getSSLManager() const = 0; + virtual std::shared_ptr<SSLManagerInterface> getSSLManager() const = 0; #endif protected: diff --git a/src/mongo/transport/session_asio.cpp b/src/mongo/transport/session_asio.cpp index 4049556b3fd..165d6639032 100644 --- a/src/mongo/transport/session_asio.cpp +++ b/src/mongo/transport/session_asio.cpp @@ -291,7 +291,7 @@ const SSLConfiguration* TransportLayerASIO::ASIOSession::getSSLConfiguration() c return nullptr; } -const std::shared_ptr<SSLManagerInterface> TransportLayerASIO::ASIOSession::getSSLManager() const { +std::shared_ptr<SSLManagerInterface> TransportLayerASIO::ASIOSession::getSSLManager() const { return _sslContext->manager; } diff --git a/src/mongo/transport/session_asio.h b/src/mongo/transport/session_asio.h index 5142d60202d..024fac29a95 100644 --- a/src/mongo/transport/session_asio.h +++ b/src/mongo/transport/session_asio.h @@ -143,7 +143,7 @@ public: #ifdef MONGO_CONFIG_SSL const SSLConfiguration* getSSLConfiguration() const override; - const std::shared_ptr<SSLManagerInterface> getSSLManager() const override; + std::shared_ptr<SSLManagerInterface> getSSLManager() const override; #endif protected: diff --git a/src/mongo/util/assert_util.h b/src/mongo/util/assert_util.h index 55bacf750e5..048aaea5a01 100644 --- a/src/mongo/util/assert_util.h +++ b/src/mongo/util/assert_util.h @@ -112,7 +112,7 @@ public: /** * Returns the generic ErrorExtraInfo if present. */ - const std::shared_ptr<const ErrorExtraInfo> extraInfo() const { + std::shared_ptr<const ErrorExtraInfo> extraInfo() const { return _status.extraInfo(); } diff --git a/src/mongo/util/net/ssl_manager_openssl.cpp b/src/mongo/util/net/ssl_manager_openssl.cpp index 7651d286be1..99448698abe 100644 --- a/src/mongo/util/net/ssl_manager_openssl.cpp +++ b/src/mongo/util/net/ssl_manager_openssl.cpp @@ -601,7 +601,7 @@ struct OCSPFetchResponse { return (statusOfResponse == ErrorCodes::OCSPCertificateStatusRevoked) || hasNextUpdate; } - const Milliseconds fetchNewResponseDuration() { + Milliseconds fetchNewResponseDuration() { Milliseconds timeBeforeNextUpdate = refreshTime - Date_t::now(); if (timeBeforeNextUpdate < Milliseconds(0)) { return Milliseconds(0); @@ -620,7 +620,7 @@ struct OCSPFetchResponse { return timeBeforeNextUpdate / 2; } - const Date_t nextStapleRefresh() { + Date_t nextStapleRefresh() { return refreshTime; } }; @@ -1323,7 +1323,7 @@ public: SSLInformationToLog getSSLInformationToLog() const final; - const std::shared_ptr<OCSPStaplingContext> getOcspStaplingContext() { + std::shared_ptr<OCSPStaplingContext> getOcspStaplingContext() { stdx::lock_guard<mongo::Mutex> guard(_sharedResponseMutex); return _ocspStaplingContext; } |