Skip to content

Commit d5f4b1b

Browse files
committed
Make sonarcloud happier
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent 26ac746 commit d5f4b1b

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

src/favicon.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export default class Favicon {
101101
h: number;
102102
} {
103103
const opt = {
104-
n: typeof n === "number" ? Math.abs(n as number | 0) : n,
104+
n: typeof n === "number" ? Math.abs(n | 0) : n,
105105
len: ("" + n).length,
106106
// badge positioning constants as percentages
107107
x: 0.4,
@@ -178,7 +178,7 @@ export default class Favicon {
178178
this.context.fillStyle = params.textColor;
179179

180180
if (typeof opt.n === "number" && opt.n > 999) {
181-
const count = (opt.n > 9999 ? 9 : Math.floor((opt.n as number) / 1000)) + "k+";
181+
const count = (opt.n > 9999 ? 9 : Math.floor(opt.n / 1000)) + "k+";
182182
this.context.fillText(count, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.2));
183183
} else {
184184
this.context.fillText("" + opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));

src/vector/getconfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export async function getVectorConfig(relativeLocation = ""): Promise<IConfigOpt
2323

2424
// Handle trailing dot FQDNs
2525
let domain = window.location.hostname.trimEnd();
26-
if (domain[domain.length - 1] === ".") {
26+
if (domain.endsWith(".")) {
2727
domain = domain.slice(0, -1);
2828
}
2929

src/vector/localstorage-fix.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
if (window.localStorage) {
77
Object.keys(window.localStorage).forEach((key) => {
8-
if (key.indexOf("loglevel:") === 0) {
8+
if (key.startsWith("loglevel:")) {
99
window.localStorage.removeItem(key);
1010
}
1111
});

src/vector/mobile_guide/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ async function initPage(): Promise<void> {
7070
try {
7171
const result = await fetch(`https://${serverName}/.well-known/matrix/client`);
7272
const wkConfig = await result.json();
73-
if (wkConfig && wkConfig["m.homeserver"]) {
73+
if (wkConfig?.["m.homeserver"]) {
7474
hsUrl = wkConfig["m.homeserver"]["base_url"];
7575

7676
if (wkConfig["m.identity_server"]) {
7777
isUrl = wkConfig["m.identity_server"]["base_url"];
7878
}
7979
}
8080
} catch (e) {
81-
if (wkConfig && wkConfig["m.homeserver"]) {
81+
if (wkConfig?.["m.homeserver"]) {
8282
hsUrl = wkConfig["m.homeserver"]["base_url"] || undefined;
8383

8484
if (wkConfig["m.identity_server"]) {

0 commit comments

Comments
 (0)