17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-10 14:53:15 +01:00

fix: the bugs and vulnerabilities SonarCloud reports on PR #216

This commit is contained in:
2026-11-07 22:11:08 +01:00
parent 8e85def98f
commit 7667e5b2ec
65 changed files with 910 additions and 121 deletions

View File

@@ -62,8 +62,12 @@ std::vector<glm::dvec2> traced(alignment::result const &Line, double const Spaci
return glm::dvec2{station.position.x, station.position.z} + glm::normalize(across) * Shift;
};
int count{0};
for (auto chainage{std::max(0.0, from - 30.0)}; chainage <= to; chainage += Spacing, ++count)
auto chainage{std::max(0.0, from - 30.0)};
while (chainage <= to) {
points.push_back(along(chainage, Noise * (count % 3 == 0 ? 1.0 : count % 3 == 1 ? -0.6 : 0.2)));
chainage += Spacing;
++count;
}
points.push_back(along(to + 30.0, Noise * 0.5));
points.push_back(along(to + 60.0, -Noise * 0.5));
return points;
@@ -750,7 +754,7 @@ TEST_CASE("alignment: a curve laid into a curved free end ends at it with its cu
}
TEST_CASE("alignment: the pieces of a compound curve are never of no length, whatever its arcs and transitions") {
std::mt19937 random{20261025};
std::mt19937 random{20261025}; // NOSONAR: deterministic test input, not security-relevant
auto const uniform = [&](double const Low, double const High) { return std::uniform_real_distribution<double>(Low, High)(random); };
auto const pick = [&](int const Count) { return std::uniform_int_distribution<int>(0, Count - 1)(random); };
int bad{0}, valid{0};