From 2d74f2a4806bbf113ed13a3cbbd022e628664420 Mon Sep 17 00:00:00 2001 From: Trevor Guidry Date: Thu, 22 Sep 2022 22:11:45 +0000 Subject: SERVER-69908 fix clang_tidy on enterprise-rhel80-dynamic-clang-tidy-v4 --- src/mongo/client/sdam/topology_description.cpp | 2 +- src/mongo/db/index/column_key_generator_test.cpp | 4 ++-- src/mongo/db/query/ce/ce_histogram_test.cpp | 2 +- src/mongo/db/query/ce/max_diff.h | 2 +- src/mongo/db/query/ce/maxdiff_test_utils.cpp | 2 +- src/mongo/db/query/ce/maxdiff_test_utils.h | 2 +- src/mongo/db/query/ce/value_utils.cpp | 4 ++-- src/mongo/db/query/ce/value_utils.h | 4 ++-- src/mongo/db/query/sbe_and_hash_test.cpp | 2 +- src/mongo/db/query/sbe_and_sorted_test.cpp | 2 +- src/mongo/db/s/range_deleter_service.cpp | 6 +++--- src/mongo/db/s/resharding/resharding_manual_cleanup.cpp | 2 +- src/mongo/db/serverless/shard_split_utils.cpp | 2 +- 13 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/mongo/client/sdam/topology_description.cpp b/src/mongo/client/sdam/topology_description.cpp index 31d3a3e0760..6c4bc2dfea1 100644 --- a/src/mongo/client/sdam/topology_description.cpp +++ b/src/mongo/client/sdam/topology_description.cpp @@ -56,7 +56,7 @@ TopologyDescription::TopologyDescription(SdamConfiguration config) : _type(config.getInitialType()), _setName(config.getSetName()) { if (auto seeds = config.getSeedList()) { _servers.clear(); - for (auto address : *seeds) { + for (const auto& address : *seeds) { _servers.push_back(std::make_shared(address)); } } diff --git a/src/mongo/db/index/column_key_generator_test.cpp b/src/mongo/db/index/column_key_generator_test.cpp index f235af478b8..cc873d1a6e8 100644 --- a/src/mongo/db/index/column_key_generator_test.cpp +++ b/src/mongo/db/index/column_key_generator_test.cpp @@ -311,7 +311,7 @@ void basicTests(int line, for (auto&& [keyGen, expectedPaths] : expected) { StringMap expected; // Create expected by retrieving flags and vals from expected paths - for (auto path : expectedPaths) { + for (const auto& path : expectedPaths) { expected.insert({path, pathMap.find(path)->second}); } // Add in the RowID column. Since it is always the same, tests shouldn't include it. @@ -961,7 +961,7 @@ void updateTest( std::vector elems; for (auto&& [keyGen, expectedPaths] : projPairs) { StringMap> expected; - for (auto path : expectedPaths) { + for (const auto& path : expectedPaths) { expected.insert({path, pathMap.find(path)->second}); } StringSet seenPaths; diff --git a/src/mongo/db/query/ce/ce_histogram_test.cpp b/src/mongo/db/query/ce/ce_histogram_test.cpp index 7afab4ccf3e..70c884c6e8a 100644 --- a/src/mongo/db/query/ce/ce_histogram_test.cpp +++ b/src/mongo/db/query/ce/ce_histogram_test.cpp @@ -73,7 +73,7 @@ ScalarHistogram getHistogramFromData(std::vector testBuckets) { int cumulativeFreq = 0; int cumulativeNDV = 0; - for (auto b : testBuckets) { + for (const auto& b : testBuckets) { // Add bucket boundary value to bounds. auto [tag, val] = stage_builder::makeValue(b.val); bounds.push_back(tag, val); diff --git a/src/mongo/db/query/ce/max_diff.h b/src/mongo/db/query/ce/max_diff.h index 267f304c089..8677bc57211 100644 --- a/src/mongo/db/query/ce/max_diff.h +++ b/src/mongo/db/query/ce/max_diff.h @@ -42,7 +42,7 @@ namespace mongo::ce { struct ValFreq { ValFreq(size_t idx, size_t freq) : _idx(idx), _freq(freq), _area(-1.0), _normArea(-1) {} - const std::string toString() const { + std::string toString() const { std::ostringstream os; os << "idx: " << _idx << ", freq: " << _freq << ", area: " << _area << ", normArea: " << _normArea; diff --git a/src/mongo/db/query/ce/maxdiff_test_utils.cpp b/src/mongo/db/query/ce/maxdiff_test_utils.cpp index 5dfb5b105de..fdd42ff627b 100644 --- a/src/mongo/db/query/ce/maxdiff_test_utils.cpp +++ b/src/mongo/db/query/ce/maxdiff_test_utils.cpp @@ -96,7 +96,7 @@ std::string makeMatchExpr(const SBEValue& val, EstimationType cmpOp) { return matchExpr.str(); } -const ScalarHistogram makeHistogram(std::vector& randData, size_t nBuckets) { +ScalarHistogram makeHistogram(std::vector& randData, size_t nBuckets) { sortValueVector(randData); const DataDistribution& dataDistrib = getDataDistribution(randData); return genMaxDiffHistogram(dataDistrib, nBuckets); diff --git a/src/mongo/db/query/ce/maxdiff_test_utils.h b/src/mongo/db/query/ce/maxdiff_test_utils.h index e95aaf78315..b1367d7dcd8 100644 --- a/src/mongo/db/query/ce/maxdiff_test_utils.h +++ b/src/mongo/db/query/ce/maxdiff_test_utils.h @@ -73,7 +73,7 @@ std::string makeMatchExpr(const SBEValue& val, EstimationType cmpOp); Given a vector of values, create a histogram reflection the distribution of the vector with the supplied number of buckets. */ -const ScalarHistogram makeHistogram(std::vector& randData, size_t nBuckets); +ScalarHistogram makeHistogram(std::vector& randData, size_t nBuckets); /** Serialize a vector of values. diff --git a/src/mongo/db/query/ce/value_utils.cpp b/src/mongo/db/query/ce/value_utils.cpp index d170eb5d6ae..9838f91a285 100644 --- a/src/mongo/db/query/ce/value_utils.cpp +++ b/src/mongo/db/query/ce/value_utils.cpp @@ -91,11 +91,11 @@ value::Value SBEValue::getValue() const { return _val; } -const std::pair makeInt64Value(int v) { +std::pair makeInt64Value(int v) { return std::make_pair(value::TypeTags::NumberInt64, value::bitcastFrom(v)); }; -const std::pair makeNullValue() { +std::pair makeNullValue() { return std::make_pair(value::TypeTags::Null, 0); }; diff --git a/src/mongo/db/query/ce/value_utils.h b/src/mongo/db/query/ce/value_utils.h index a9d664b0b4c..8ede1362c37 100644 --- a/src/mongo/db/query/ce/value_utils.h +++ b/src/mongo/db/query/ce/value_utils.h @@ -64,12 +64,12 @@ private: Generate an SBE Value pair that represents the supplied int with type Int64 */ -const std::pair makeInt64Value(int v); +std::pair makeInt64Value(int v); /** Generate an SBE Value pair representing a BSON null value */ -const std::pair makeNullValue(); +std::pair makeNullValue(); /** Do the supplied type tags represent the same BSON type? diff --git a/src/mongo/db/query/sbe_and_hash_test.cpp b/src/mongo/db/query/sbe_and_hash_test.cpp index 95f0d083cbc..217696b3cdf 100644 --- a/src/mongo/db/query/sbe_and_hash_test.cpp +++ b/src/mongo/db/query/sbe_and_hash_test.cpp @@ -48,7 +48,7 @@ protected: std::unique_ptr makeHashAndTree( std::vector> docsVec) { auto andHashNode = std::make_unique(); - for (auto docs : docsVec) { + for (const auto& docs : docsVec) { auto virtScan = std::make_unique(docs, VirtualScanNode::ScanType::kCollScan, true); andHashNode->children.push_back(std::move(virtScan)); diff --git a/src/mongo/db/query/sbe_and_sorted_test.cpp b/src/mongo/db/query/sbe_and_sorted_test.cpp index 45e0d38f3ac..eada10cb8bf 100644 --- a/src/mongo/db/query/sbe_and_sorted_test.cpp +++ b/src/mongo/db/query/sbe_and_sorted_test.cpp @@ -46,7 +46,7 @@ protected: std::unique_ptr makeAndSortedTree( std::vector> docsVec) { auto andSortedNode = std::make_unique(); - for (auto docs : docsVec) { + for (const auto& docs : docsVec) { auto virtScan = std::make_unique(docs, VirtualScanNode::ScanType::kCollScan, true); andSortedNode->children.push_back(std::move(virtScan)); diff --git a/src/mongo/db/s/range_deleter_service.cpp b/src/mongo/db/s/range_deleter_service.cpp index e0027e09bfe..d27c71f3932 100644 --- a/src/mongo/db/s/range_deleter_service.cpp +++ b/src/mongo/db/s/range_deleter_service.cpp @@ -48,9 +48,9 @@ namespace mongo { namespace { const auto rangeDeleterServiceDecorator = ServiceContext::declareDecoration(); -const BSONObj getShardKeyPattern(OperationContext* opCtx, - const DatabaseName& dbName, - const UUID& collectionUuid) { +BSONObj getShardKeyPattern(OperationContext* opCtx, + const DatabaseName& dbName, + const UUID& collectionUuid) { while (true) { opCtx->checkForInterrupt(); boost::optional optNss; diff --git a/src/mongo/db/s/resharding/resharding_manual_cleanup.cpp b/src/mongo/db/s/resharding/resharding_manual_cleanup.cpp index 74911c8518f..c9141a1a5b3 100644 --- a/src/mongo/db/s/resharding/resharding_manual_cleanup.cpp +++ b/src/mongo/db/s/resharding/resharding_manual_cleanup.cpp @@ -65,7 +65,7 @@ std::vector createShardCleanupRequests( auto participants = getAllParticipantsFromCoordDoc(doc); std::vector requests; - for (auto participant : participants) { + for (const auto& participant : participants) { requests.emplace_back(participant, ShardsvrCleanupReshardCollection(nss, reshardingUUID).toBSON({})); } diff --git a/src/mongo/db/serverless/shard_split_utils.cpp b/src/mongo/db/serverless/shard_split_utils.cpp index 2168526b22b..846543bf140 100644 --- a/src/mongo/db/serverless/shard_split_utils.cpp +++ b/src/mongo/db/serverless/shard_split_utils.cpp @@ -47,7 +47,7 @@ std::vector getRecipientMembers(const repl::ReplSetConfig& c const StringData& recipientTagName) { std::vector result; const auto& tagConfig = config.getTagConfig(); - for (auto member : config.members()) { + for (const auto& member : config.members()) { auto matchesTag = std::any_of(member.tagsBegin(), member.tagsEnd(), [&](const repl::ReplSetTag& tag) { return tagConfig.getTagKey(tag) == recipientTagName; -- cgit v1.2.1