Skip to content

Commit cca4024

Browse files
committed
lint
1 parent 0124b82 commit cca4024

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/version_weaver.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#include "version_weaver.h"
2+
23
#include <algorithm>
34
#include <cctype>
4-
#include <regex>
55
#include <charconv>
6+
#include <regex>
67
#include <sstream>
78
namespace version_weaver {
89
bool validate(std::string_view version) { return parse(version).has_value(); }
@@ -369,7 +370,9 @@ std::optional<std::string> minimum(std::string_view range) {
369370
}
370371
}
371372

372-
return bestCandidate;
373+
if (validCandidates.empty()) return std::nullopt;
374+
return *std::min_element(validCandidates.begin(), validCandidates.end(),
375+
compareSemVer);
373376
}
374377

375378
std::expected<std::string, parse_error> inc(version input,
@@ -420,6 +423,14 @@ std::expected<std::string, parse_error> inc(version input,
420423
}
421424
}
422425

426+
constexpr inline void trim_whitespace(std::string_view *input) noexcept {
427+
while (!input->empty() && std::isspace(input->front())) {
428+
input->remove_prefix(1);
429+
}
430+
while (!input->empty() && std::isspace(input->back())) {
431+
input->remove_suffix(1);
432+
}
433+
}
423434

424435
constexpr inline bool contains_only_digits(std::string_view input) noexcept {
425436
// Optimization opportunity: Replace this with a hash table lookup.

0 commit comments

Comments
 (0)