fix sonar findings and translation structure
Sonarqube Scanner / Prepare environment (push) Successful in 19s
Sonarqube Scanner / Build and test (push) Successful in 43s
Sonarqube Scanner / SonarQube analysis (push) Failing after 2m28s
Sonarqube Scanner / Deploy to Server (push) Successful in 16s

This commit is contained in:
Florian Zumpe
2026-10-01 16:31:46 +02:00
parent 2b42507f13
commit 5c4d20bd1d
30 changed files with 1753 additions and 894 deletions
+29 -29
View File
@@ -15,7 +15,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
function storage() {
const target = globalThis.localStorage;
if (!target) throw new Error(ns.I18n.t("local-routes.deine.strecke.kann.auf.diesem.gerat.gerade"));
if (!target) throw new Error(ns.I18n.t("local.error.route-storage"));
return target;
}
@@ -27,7 +27,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
if (mediaDatabasePromise) return mediaDatabasePromise;
const indexedDb = globalThis.indexedDB;
if (!indexedDb || typeof indexedDb.open !== 'function') {
return Promise.reject(new Error(ns.I18n.t("local-routes.bilder.und.ton.konnen.auf.diesem.gerat")));
return Promise.reject(new Error(ns.I18n.t("local.error.media-storage")));
}
mediaDatabasePromise = new Promise((resolve, reject) => {
@@ -41,11 +41,11 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
request.onsuccess = () => resolve(request.result);
request.onerror = () => {
mediaDatabasePromise = null;
reject(request.error || new Error(ns.I18n.t("local-routes.gespeicherte.bilder.und.ton.konnten.nicht.geoffnet")));
reject(request.error || new Error(ns.I18n.t("local.error.media-read")));
};
request.onblocked = () => {
mediaDatabasePromise = null;
reject(new Error(ns.I18n.t("local-routes.schliesse.andere.fenster.mit.wegwichtel.und.versuche")));
reject(new Error(ns.I18n.t("local.error.other-tabs")));
};
});
return mediaDatabasePromise;
@@ -59,8 +59,8 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
const transaction = database.transaction(MEDIA_STORE_NAME, mode);
request = operation(transaction.objectStore(MEDIA_STORE_NAME));
request.onsuccess = () => resolve(request.result ?? null);
request.onerror = () => reject(request.error || new Error(ns.I18n.t("local-routes.bilder.und.ton.konnten.nicht.geoffnet.oder")));
transaction.onabort = () => reject(transaction.error || new Error(ns.I18n.t("local-routes.das.speichern.von.bildern.und.ton.wurde")));
request.onerror = () => reject(request.error || new Error(ns.I18n.t("local.error.media-access")));
transaction.onabort = () => reject(transaction.error || new Error(ns.I18n.t("local.error.media-cancelled")));
} catch (error) {
reject(error);
}
@@ -100,7 +100,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
};
} catch (error) {
if (error?.name === 'QuotaExceededError') {
throw new Error(ns.I18n.t("local-routes.der.platz.fur.bilder.und.ton.ist"), { cause: error });
throw new Error(ns.I18n.t("local.error.media-quota-hint"), { cause: error });
}
// Manche Browser können FileSystemFileHandle noch nicht in IndexedDB serialisieren.
// In diesem Fall wird die Datei als Blob in IndexedDB gespeichert.
@@ -111,9 +111,9 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
await putMediaRecord({ ...metadata, storage: 'indexeddb', blob: file });
} catch (error) {
const prefix = error?.name === 'QuotaExceededError'
? ns.I18n.t("local-routes.der.platz.fur.bilder.und.ton.ist.2")
: ns.I18n.t("local-routes.das.bild.oder.die.tonaufnahme.konnte.nicht");
throw new Error(ns.I18n.t("local-routes.entferne.bilder.tonaufnahmen.oder.eigene.strecken.die", { value1: prefix }), { cause: error });
? ns.I18n.t("local.error.media-quota")
: ns.I18n.t("local.error.media-save");
throw new Error(ns.I18n.t("local.error.media-cleanup-hint", { value1: prefix }), { cause: error });
}
return {
id: String(mediaId),
@@ -135,12 +135,12 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
permission = await handle.requestPermission({ mode: 'read' });
}
if (permission !== 'granted') {
throw new Error(ns.I18n.t("local-routes.erlaube.noch.einmal.den.zugriff.auf.das"));
throw new Error(ns.I18n.t("local.error.file-permission"));
}
try {
return await handle.getFile();
} catch (error) {
throw new Error(ns.I18n.t("local-routes.ein.ausgewahltes.bild.oder.eine.tonaufnahme.wurde"), { cause: error });
throw new Error(ns.I18n.t("local.error.file-missing"), { cause: error });
}
}
@@ -238,7 +238,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
if (typeof cryptoApi?.getRandomValues === 'function') {
return `local-${uuidFromRandomValues(cryptoApi)}`;
}
throw new Error(ns.I18n.t("local-routes.auf.diesem.gerat.kann.gerade.keine.neue"));
throw new Error(ns.I18n.t("local.error.create-route"));
}
function createPoiId() {
@@ -255,7 +255,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
.replaceAll("'", ''');
}
function emptyGpx(name = ns.I18n.t("editor-ui.neue.strecke")) {
function emptyGpx(name = ns.I18n.t("editor.new-route")) {
const safeName = escapeXml(name);
return `<?xml version="1.0" encoding="UTF-8"?>\n`
+ `<gpx version="1.1" creator="Wegwichtel" xmlns="${GPX_NAMESPACE}" xmlns:wegwichtel="${POI_NAMESPACE}">\n`
@@ -268,7 +268,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
const parser = new DOMParser();
const document = parser.parseFromString(String(gpx || ''), 'application/xml');
if (document.querySelector('parsererror') || document.documentElement?.localName !== 'gpx') {
throw new Error(ns.I18n.t("local-routes.diese.datei.enthalt.keinen.lesbaren.weg.wahle"));
throw new Error(ns.I18n.t("local.error.invalid-track"));
}
return document;
}
@@ -300,7 +300,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
const document = parseXml(gpx);
return Array.from(document.getElementsByTagNameNS('*', 'wpt')).map((node, index) => ({
id: waypointId(node),
title: textOfChild(node, 'name') || ns.I18n.t("editor-ui.station", { value1: index + 1 }),
title: textOfChild(node, 'name') || ns.I18n.t("editor.station-number", { value1: index + 1 }),
description: textOfChild(node, 'desc'),
lat: numberAttribute(node, 'lat'),
lon: numberAttribute(node, 'lon'),
@@ -360,7 +360,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
}
function syncGpx(gpx, route, pois) {
const routeName = route?.name || ns.I18n.t("editor-ui.neue.strecke");
const routeName = route?.name || ns.I18n.t("editor.new-route");
const document = parseXml(gpx || emptyGpx(routeName));
updateMetadataName(document, routeName);
@@ -374,9 +374,9 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
const segment = ensureTrackSegment(document, routeName);
const orderedPois = [...(pois || [])].sort((left, right) => Number(left.sequence) - Number(right.sequence));
orderedPois.forEach((poi, index) => {
const title = poi.title || ns.I18n.t("editor-ui.station", { value1: index + 1 });
const title = poi.title || ns.I18n.t("editor.station-number", { value1: index + 1 });
if (!Number.isFinite(Number(poi.lat)) || !Number.isFinite(Number(poi.lon))) {
throw new TypeError(ns.I18n.t("local-routes.der.ort.von.fehlt", { value1: title }));
throw new TypeError(ns.I18n.t("local.error.station-location", { value1: title }));
}
const gpxPoint = createElement(document, 'trkpt');
@@ -469,9 +469,9 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
}
ns.StorageUsage?.reportError(error);
const name = error?.name === 'QuotaExceededError'
? ns.I18n.t("local-routes.der.platz.fur.deine.strecken.ist.voll")
: ns.I18n.t("local-routes.deine.strecke.konnte.nicht.gespeichert.werden");
throw new Error(ns.I18n.t("local-routes.entferne.eigene.strecken.die.du.nicht.mehr", { value1: name }), { cause: error });
? ns.I18n.t("local.error.route-quota")
: ns.I18n.t("local.error.save-route");
throw new Error(ns.I18n.t("local.error.route-cleanup-hint", { value1: name }), { cause: error });
}
notify(id, 'saved');
@@ -514,9 +514,9 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
}
function gpxForUpload(routePackage) {
if (!routePackage?.gpx) throw new Error(ns.I18n.t("local-routes.der.weg.deiner.strecke.fehlt"));
if (!routePackage?.gpx) throw new Error(ns.I18n.t("local.error.path-missing"));
if (!routePoints(routePackage.gpx).length) {
throw new Error(ns.I18n.t("local-routes.deine.strecke.hat.noch.keinen.aufgezeichneten.weg"));
throw new Error(ns.I18n.t("local.error.path-empty"));
}
return routePackage.gpx;
}
@@ -577,7 +577,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
function appPoi(poi) {
return {
id: Number(poi.id),
title: poi.title || ns.I18n.t("editor-ui.station.ohne.namen"),
title: poi.title || ns.I18n.t("editor.untitled-station"),
description: poi.description || '',
lat: Number(poi.lat),
lon: Number(poi.lon),
@@ -604,7 +604,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
id: String(routePackage.id),
source: 'local',
local: true,
name: routePackage.route?.name || ns.I18n.t("editor-ui.unbenannte.strecke"),
name: routePackage.route?.name || ns.I18n.t("editor.untitled-route"),
description: routePackage.route?.description || '',
schoolName: ns.I18n.t("local.device"),
status: 'local',
@@ -625,7 +625,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
async function getAppRoute(id, options = {}) {
const routePackage = await withMedia(readPackage(id), options);
if (!routePackage) throw new Error(ns.I18n.t("local-routes.deine.strecke.wurde.nicht.gefunden"));
if (!routePackage) throw new Error(ns.I18n.t("local.error.route-missing"));
return toAppRoute(routePackage);
}
@@ -636,7 +636,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
function readFileAsText(file) {
if (!file) return Promise.resolve('');
if (typeof file.text !== 'function') {
return Promise.reject(new TypeError(ns.I18n.t("local-routes.diese.datei.kann.auf.deinem.gerat.nicht")));
return Promise.reject(new TypeError(ns.I18n.t("local.error.file-unsupported")));
}
return file.text();
}
@@ -647,7 +647,7 @@ globalThis.Wegwichtel = globalThis.Wegwichtel || {};
const reader = new FileReader();
reader.addEventListener('load', () => {
if (typeof reader.result !== 'string') {
reject(new TypeError(ns.I18n.t("local-routes.diese.datei.konnte.nicht.geoffnet.werden.wahle")));
reject(new TypeError(ns.I18n.t("local.error.file-read")));
return;
}
resolve({