Skip to content

Commit 7e8ef95

Browse files
committed
refactor: Fix Sonar rule cpp:S4998 - avoid unique_ptr const& as parameter
Changed `FindChallenges()` parameter from `const std::unique_ptr<const Node<Key>>&` to const `Node*`. Sonar rule `cpp:S4998` - https://sonarcloud.io/project/issues?issueStatuses=OPEN%2CCONFIRMED&branch=32351-8c0e673c4ac31c1c04750756de749fb813b2c33f&id=aureleoules_bitcoin&open=AZZ2q88IvFhp-eMuMy96: > Replace this use of "unique_ptr" by a raw pointer or a reference (possibly const). > Function parameters should not be of type "std::unique_ptr<T> const &" cpp:S4998 > Software qualities impacted: Maintainability
1 parent e400ac5 commit 7e8ef95

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/test/miniscript_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,12 +297,12 @@ using miniscript::operator""_mst;
297297
using Node = miniscript::Node<CPubKey>;
298298

299299
/** Compute all challenges (pubkeys, hashes, timelocks) that occur in a given Miniscript. */
300-
std::set<Challenge> FindChallenges(const NodeRef& root)
300+
std::set<Challenge> FindChallenges(const Node* root)
301301
{
302302
std::set<Challenge> chal;
303303

304-
for (std::vector stack{root.get()}; !stack.empty();) {
305-
const Node* ref{stack.back()};
304+
for (std::vector stack{root}; !stack.empty();) {
305+
const auto* ref{stack.back()};
306306
stack.pop_back();
307307

308308
for (const auto& key : ref->keys) {
@@ -348,7 +348,7 @@ struct MiniScriptTest : BasicTestingSetup {
348348
/** Run random satisfaction tests. */
349349
void TestSatisfy(const KeyConverter& converter, const std::string& testcase, const NodeRef& node) {
350350
auto script = node->ToScript(converter);
351-
const auto challenges{FindChallenges(node)}; // Find all challenges in the generated miniscript.
351+
const auto challenges{FindChallenges(node.get())}; // Find all challenges in the generated miniscript.
352352
std::vector<Challenge> challist(challenges.begin(), challenges.end());
353353
for (int iter = 0; iter < 3; ++iter) {
354354
std::shuffle(challist.begin(), challist.end(), m_rng);

0 commit comments

Comments
 (0)