From 8582462ba36e06b9c90317f8de13c2ead5319b88 Mon Sep 17 00:00:00 2001 From: Mark Haslinghuis Date: Sat, 7 Dec 2024 00:45:34 +0100 Subject: [PATCH] Fix sonar --- src/components/data-flash/DataFlash.vue | 60 +++++++++---------------- src/components/init.js | 2 +- 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/src/components/data-flash/DataFlash.vue b/src/components/data-flash/DataFlash.vue index 21116561c8..b4d1714f0e 100644 --- a/src/components/data-flash/DataFlash.vue +++ b/src/components/data-flash/DataFlash.vue @@ -34,48 +34,30 @@ export default defineComponent({ }, computed: { supportDataflash() { - if (this.fcTotalSize > 0) return true; - else return false; + return this.fcTotalSize > 0; }, - computed: { - supportDataflash() { - if (this.fcTotalSize > 0) return true; - else return false; - }, - freeSpace() { - if (!this.supportDataflash) return; - const bytes = this.fcTotalSize - this.fcUsedSize; - if (this.fcUsedSize >= this.fcTotalSize) { - return "0B"; - } - if (bytes < 1024) { - return `${bytes}B`; - } - const kilobytes = bytes / 1024; - if (kilobytes < 1024) { - return `${Math.round(kilobytes)}KB`; - } - const megabytes = kilobytes / 1024; - if (megabytes < 1024) { - return `${megabytes.toFixed(1)}MB`; - } - const gigabytes = megabytes / 1024; - return `${gigabytes.toFixed(1)}GB`; - }, - indicatorWidth() { - if (!this.supportDataflash) return; - return `${Math.min( - (this.fcUsedSize / this.fcTotalSize) * 100, - 100, - )}%`; - }, + freeSpace() { + if (!this.supportDataflash) { return; } + const bytes = this.fcTotalSize - this.fcUsedSize; + if (this.fcUsedSize >= this.fcTotalSize) { + return "0B"; + } + if (bytes < 1024) { + return `${bytes}B`; + } + const kilobytes = bytes / 1024; + if (kilobytes < 1024) { + return `${Math.round(kilobytes)}KB`; + } + const megabytes = kilobytes / 1024; + if (megabytes < 1024) { + return `${megabytes.toFixed(1)}MB`; + } + const gigabytes = megabytes / 1024; + return `${gigabytes.toFixed(1)}GB`; }, indicatorWidth() { - if (!this.supportDataflash) return; - return `${Math.min( - (this.fcUsedSize / this.fcTotalSize) * 100, - 100, - )}%`; + return this.supportDataflash ? `${Math.min((this.fcUsedSize / this.fcTotalSize) * 100, 100)}%` : "0%"; }, }, }); diff --git a/src/components/init.js b/src/components/init.js index d56c212730..ff0408dd15 100644 --- a/src/components/init.js +++ b/src/components/init.js @@ -48,7 +48,7 @@ i18next.on('initialized', function() { if (process.env.NODE_ENV === 'development') { console.log("Development mode enabled, installing Vue tools"); - // Vue.config.devtools = true; + // TODO Vue.config.devtools = true; app.config.performance = true; } });