fix sonarqube findings
Sonarqube Scanner / Prepare environment (push) Successful in 7s
Sonarqube Scanner / Build and test (push) Successful in 24s
Sonarqube Scanner / SonarQube analysis (push) Successful in 1m12s
Sonarqube Scanner / Deploy to Server (push) Successful in 6s

This commit is contained in:
Florian Zumpe
2026-10-03 12:59:58 +02:00
parent cf4170f590
commit edfe227641
3 changed files with 63 additions and 5 deletions
+8 -3
View File
@@ -52,7 +52,8 @@ export function parseGpx(xml, replacementPoints = null) {
const points = replacementPoints ?? (routed.length ? routed : simplifyTrack(recorded));
const waypoints = validPoints(asList(gpx.wpt));
if (!points.length && !waypoints.length && !gpx.extensions?.['wegwichtel:gpsGap'] && !gpx.extensions?.['wegwichtel:pendingWaypoint']) throw new HttpError(400, 'Die GPX-Datei enthält keine verwertbaren Punkte.');
const metrics = points.length || waypoints.length ? routeMetrics(points.length ? points : waypoints) : {
const metricPoints = points.length ? points : waypoints;
const metrics = metricPoints.length ? routeMetrics(metricPoints) : {
startLat: null, startLon: null, centerLat: null, centerLon: null,
minLat: null, minLon: null, maxLat: null, maxLon: null,
distanceM: 0, elevationGainM: 0, pointCount: 0
@@ -63,6 +64,8 @@ export function parseGpx(xml, replacementPoints = null) {
delete gpx.rte;
// GPX 1.1 order: metadata, waypoints, route, extensions.
const { extensions, ...base } = gpx;
// GPX 1.1 namespace identifier: this URI is written into XML, never fetched.
// Its exact spelling is part of the GPX standard; HTTPS would be another namespace.
const normalized = { ...base, '@_version': '1.1', '@_creator': 'Wegwichtel', '@_xmlns': 'http://www.topografix.com/GPX/1/1' };
if (points.length) normalized.rte = { ...(name ? { name } : {}), rtept: points.map(point => ({
'@_lat': point.lat, '@_lon': point.lon,
@@ -75,13 +78,15 @@ export function parseGpx(xml, replacementPoints = null) {
export function gpxWithWaypoints(xml, pois) {
const gpx = parseXml(xml).gpx;
const { wpt: _oldWaypoints, rte, trk, extensions = {}, ...base } = gpx;
delete gpx.wpt;
const { rte, trk, extensions = {}, ...base } = gpx;
const waypoint = poi => ({ '@_lat': poi.lat, '@_lon': poi.lon, name: poi.title,
...(poi.description ? { desc: poi.description } : {}),
extensions: { 'wegwichtel:poiId': poi.id } });
const located = pois.filter(poi => Number.isFinite(poi.lat) && Number.isFinite(poi.lon));
const pending = pois.filter(poi => !Number.isFinite(poi.lat) || !Number.isFinite(poi.lon));
const { 'wegwichtel:pendingWaypoint': _oldPending, ...extra } = extensions;
const extra = { ...extensions };
delete extra['wegwichtel:pendingWaypoint'];
if (pending.length) extra['wegwichtel:pendingWaypoint'] = pending.map(poi => ({ name: poi.title,
...(poi.description ? { desc: poi.description } : {}), extensions: { 'wegwichtel:poiId': poi.id } }));
const normalized = { ...base, '@_xmlns:wegwichtel': 'urn:wegwichtel:poi',