Skip to content

Commit

Permalink
Merge pull request #27881 from element-hq/t3chguy/make-sonar-happier
Browse files Browse the repository at this point in the history
Make sonarcloud happier
  • Loading branch information
t3chguy authored Jul 31, 2024
2 parents 446a4c8 + d5f4b1b commit 1424314
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/favicon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export default class Favicon {
h: number;
} {
const opt = {
n: typeof n === "number" ? Math.abs(n as number | 0) : n,
n: typeof n === "number" ? Math.abs(n | 0) : n,
len: ("" + n).length,
// badge positioning constants as percentages
x: 0.4,
Expand Down Expand Up @@ -178,7 +178,7 @@ export default class Favicon {
this.context.fillStyle = params.textColor;

if (typeof opt.n === "number" && opt.n > 999) {
const count = (opt.n > 9999 ? 9 : Math.floor((opt.n as number) / 1000)) + "k+";
const count = (opt.n > 9999 ? 9 : Math.floor(opt.n / 1000)) + "k+";
this.context.fillText(count, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.2));
} else {
this.context.fillText("" + opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));
Expand Down
2 changes: 1 addition & 1 deletion src/vector/getconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function getVectorConfig(relativeLocation = ""): Promise<IConfigOpt

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

Expand Down
2 changes: 1 addition & 1 deletion src/vector/localstorage-fix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

if (window.localStorage) {
Object.keys(window.localStorage).forEach((key) => {
if (key.indexOf("loglevel:") === 0) {
if (key.startsWith("loglevel:")) {
window.localStorage.removeItem(key);
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/vector/mobile_guide/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ async function initPage(): Promise<void> {
try {
const result = await fetch(`https://${serverName}/.well-known/matrix/client`);
const wkConfig = await result.json();
if (wkConfig && wkConfig["m.homeserver"]) {
if (wkConfig?.["m.homeserver"]) {
hsUrl = wkConfig["m.homeserver"]["base_url"];

if (wkConfig["m.identity_server"]) {
isUrl = wkConfig["m.identity_server"]["base_url"];
}
}
} catch (e) {
if (wkConfig && wkConfig["m.homeserver"]) {
if (wkConfig?.["m.homeserver"]) {
hsUrl = wkConfig["m.homeserver"]["base_url"] || undefined;

if (wkConfig["m.identity_server"]) {
Expand Down

0 comments on commit 1424314

Please sign in to comment.