mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
refactor: Add simple clang-tidy readability checks (#6556)
This change enables the following clang-tidy checks: - readability-avoid-nested-conditional-operator, - readability-avoid-return-with-void-value, - readability-braces-around-statements, - readability-const-return-type, - readability-container-contains, - readability-container-size-empty, - readability-else-after-return, - readability-make-member-function-const, - readability-redundant-casting, - readability-redundant-inline-specifier, - readability-redundant-member-init, - readability-redundant-string-init, - readability-reference-to-constructed-temporary, - readability-static-definition
This commit is contained in:
@@ -1045,9 +1045,13 @@ private:
|
||||
auto const valKey = randomNode();
|
||||
cfgKeys.push_back(toBase58(TokenType::NodePublic, valKey));
|
||||
if (cfgKeys.size() <= maxKeys - 5)
|
||||
{
|
||||
activeValidatorsOuter.emplace(calcNodeID(valKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
unseenValidators.emplace(calcNodeID(valKey));
|
||||
}
|
||||
}
|
||||
|
||||
BEAST_EXPECT(trustedKeysOuter->load({}, cfgKeys, cfgPublishersOuter));
|
||||
@@ -1075,7 +1079,9 @@ private:
|
||||
BEAST_EXPECT(trustedKeysOuter->trusted(*valKey));
|
||||
}
|
||||
else
|
||||
{
|
||||
fail();
|
||||
}
|
||||
}
|
||||
|
||||
changes = trustedKeysOuter->updateTrusted(
|
||||
@@ -1266,9 +1272,13 @@ private:
|
||||
cfgKeys.push_back(toBase58(TokenType::NodePublic, valKey));
|
||||
expectedTrusted.emplace(calcNodeID(valKey));
|
||||
if (cfgKeys.size() < std::ceil(n * 0.8f))
|
||||
{
|
||||
activeValidators.emplace(calcNodeID(valKey));
|
||||
}
|
||||
else if (cfgKeys.size() < std::ceil(n * 0.8f))
|
||||
{
|
||||
toBeSeen = calcNodeID(valKey);
|
||||
}
|
||||
}
|
||||
|
||||
BEAST_EXPECT(trustedKeys->load({}, cfgKeys, cfgPublishersOuter));
|
||||
@@ -1462,9 +1472,13 @@ private:
|
||||
env.app().getHashRouter());
|
||||
BEAST_EXPECT(changes.removed.empty());
|
||||
if (cfgKeys.size() > 2)
|
||||
{
|
||||
BEAST_EXPECT(changes.added == asNodeIDs({valKey}));
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(changes.added == asNodeIDs({localKey, valKey}));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(trustedKeys->quorum() == std::ceil(cfgKeys.size() * 0.8f));
|
||||
|
||||
@@ -1617,14 +1631,28 @@ private:
|
||||
auto const sequence = 1;
|
||||
using namespace std::chrono_literals;
|
||||
// Want to drop 1 sooner
|
||||
NetClock::time_point const validUntil = env.timeKeeper().now() +
|
||||
(i == 2 ? 120s
|
||||
: i == 1 ? 60s
|
||||
: 3600s);
|
||||
std::chrono::seconds duration;
|
||||
if (i == 2)
|
||||
{
|
||||
duration = 120s;
|
||||
}
|
||||
else if (i == 1)
|
||||
{
|
||||
duration = 60s;
|
||||
}
|
||||
else
|
||||
{
|
||||
duration = 3600s;
|
||||
}
|
||||
NetClock::time_point const validUntil = env.timeKeeper().now() + duration;
|
||||
if (i == 1)
|
||||
{
|
||||
validUntil1 = validUntil;
|
||||
}
|
||||
else if (i == 2)
|
||||
{
|
||||
validUntil2 = validUntil;
|
||||
}
|
||||
std::vector<Validator> localKeys{locals[i].first, locals[i].second};
|
||||
auto const blob =
|
||||
makeList(localKeys, sequence, validUntil.time_since_epoch().count());
|
||||
@@ -1665,7 +1693,9 @@ private:
|
||||
added.insert(calcNodeID(val.masterPublic));
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(!trustedKeys->trusted(val.masterPublic));
|
||||
}
|
||||
}
|
||||
BEAST_EXPECT(changes.added == added);
|
||||
BEAST_EXPECT(changes.removed.empty());
|
||||
@@ -1689,7 +1719,9 @@ private:
|
||||
{
|
||||
auto const& val = valKeys[i];
|
||||
if (i >= 2 && i < maxKeys - 4)
|
||||
{
|
||||
BEAST_EXPECT(trustedKeys->trusted(val.masterPublic));
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(!trustedKeys->trusted(val.masterPublic));
|
||||
@@ -1717,9 +1749,13 @@ private:
|
||||
{
|
||||
auto const& val = valKeys[i];
|
||||
if (i < maxKeys - 4)
|
||||
{
|
||||
BEAST_EXPECT(trustedKeys->listed(val.masterPublic));
|
||||
}
|
||||
else
|
||||
{
|
||||
BEAST_EXPECT(!trustedKeys->listed(val.masterPublic));
|
||||
}
|
||||
|
||||
BEAST_EXPECT(!trustedKeys->trusted(val.masterPublic));
|
||||
if (i >= 2 && i < maxKeys - 4)
|
||||
@@ -2020,7 +2056,7 @@ private:
|
||||
{
|
||||
for (auto& n : nUnl_temp)
|
||||
{
|
||||
if (nUnl.find(n) == nUnl.end())
|
||||
if (!nUnl.contains(n))
|
||||
return false;
|
||||
}
|
||||
validators->updateTrusted(
|
||||
@@ -2338,7 +2374,7 @@ private:
|
||||
1, 8, maxSequence, version, manifest, blobInfos, messages),
|
||||
0,
|
||||
0);
|
||||
BEAST_EXPECT(messages.size() == 0);
|
||||
BEAST_EXPECT(messages.empty());
|
||||
|
||||
// Don't repeat the work if messages is populated, even though the
|
||||
// peerSequence provided indicates it should. Note that this
|
||||
@@ -2392,7 +2428,7 @@ private:
|
||||
2, maxSequence * 2, maxSequence, version, manifest, blobInfos, messages),
|
||||
0,
|
||||
0);
|
||||
BEAST_EXPECT(messages.size() == 0);
|
||||
BEAST_EXPECT(messages.empty());
|
||||
|
||||
// Don't repeat the work if messages is populated, even though the
|
||||
// peerSequence provided indicates it should. Note that this
|
||||
@@ -2491,7 +2527,7 @@ private:
|
||||
PublicKey pubKey;
|
||||
std::pair<PublicKey, SecretKey> signingKeys;
|
||||
std::string manifest;
|
||||
NetClock::time_point expiry = {};
|
||||
NetClock::time_point expiry = {}; // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
// Create ValidatorList with a set of countTotal publishers, of which
|
||||
@@ -2528,7 +2564,12 @@ private:
|
||||
pubSigningKeys.second,
|
||||
i < countRevoked ? revoked : 1));
|
||||
publishers.push_back(
|
||||
Publisher{i < countRevoked, publisherPublic, pubSigningKeys, manifest});
|
||||
Publisher{
|
||||
.revoked = i < countRevoked,
|
||||
.pubKey = publisherPublic,
|
||||
.signingKeys = pubSigningKeys,
|
||||
.manifest = manifest,
|
||||
});
|
||||
}
|
||||
|
||||
std::vector<std::string> const emptyCfgKeys;
|
||||
@@ -2670,7 +2711,7 @@ private:
|
||||
env.app().overlay(),
|
||||
env.app().getHashRouter());
|
||||
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
|
||||
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 0);
|
||||
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty());
|
||||
|
||||
hash_set<NodeID> removed;
|
||||
for (auto const& val : valKeys)
|
||||
@@ -2938,7 +2979,7 @@ private:
|
||||
env.app().overlay(),
|
||||
env.app().getHashRouter());
|
||||
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
|
||||
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 0);
|
||||
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty());
|
||||
|
||||
hash_set<NodeID> removed;
|
||||
for (auto const& val : valKeys)
|
||||
@@ -3376,7 +3417,7 @@ private:
|
||||
env.app().overlay(),
|
||||
env.app().getHashRouter());
|
||||
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
|
||||
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 0);
|
||||
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty());
|
||||
|
||||
hash_set<NodeID> removed;
|
||||
for (auto const& val : valKeys)
|
||||
@@ -3558,7 +3599,7 @@ private:
|
||||
env.app().overlay(),
|
||||
env.app().getHashRouter());
|
||||
BEAST_EXPECT(trustedKeys->quorum() == quorumDisabled);
|
||||
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().size() == 0);
|
||||
BEAST_EXPECT(trustedKeys->getTrustedMasterKeys().empty());
|
||||
|
||||
hash_set<NodeID> removed;
|
||||
for (auto const& val : valKeys)
|
||||
|
||||
Reference in New Issue
Block a user