mirror of
https://github.com/bitwarden/browser
synced 2025-12-18 09:13:33 +00:00
Remove empty catch blocks, and update tslint rule (#513)
This commit is contained in:
@@ -21,7 +21,9 @@ export class PasspackCsvImporter extends BaseImporter implements Importer {
|
||||
try {
|
||||
const t = JSON.parse(tagJson);
|
||||
return this.getValueOrDefault(t.tag);
|
||||
} catch { }
|
||||
} catch {
|
||||
// Ignore error
|
||||
}
|
||||
return null;
|
||||
}).filter((t: string) => !this.isNullOrWhitespace(t)) : null;
|
||||
|
||||
@@ -72,7 +74,9 @@ export class PasspackCsvImporter extends BaseImporter implements Importer {
|
||||
fieldsJson.extraFields.length > 0 ? fieldsJson.extraFields.map((fieldJson: string) => {
|
||||
try {
|
||||
return JSON.parse(fieldJson);
|
||||
} catch { }
|
||||
} catch {
|
||||
// Ignore error
|
||||
}
|
||||
return null;
|
||||
}) : null;
|
||||
if (fields != null) {
|
||||
|
||||
@@ -84,7 +84,9 @@ export class PasswordBossJsonImporter extends BaseImporter implements Importer {
|
||||
const expDate = new Date(val);
|
||||
cipher.card.expYear = expDate.getFullYear().toString();
|
||||
cipher.card.expMonth = (expDate.getMonth() + 1).toString();
|
||||
} catch { }
|
||||
} catch {
|
||||
// Ignore error
|
||||
}
|
||||
continue;
|
||||
} else if (property === 'cardType') {
|
||||
continue;
|
||||
|
||||
@@ -43,7 +43,9 @@ export class RememBearCsvImporter extends BaseImporter implements Importer {
|
||||
cipher.card.expMonth = expMonthNumber.toString();
|
||||
}
|
||||
}
|
||||
} catch { }
|
||||
} catch {
|
||||
// Ignore error
|
||||
}
|
||||
try {
|
||||
const expYear = this.getValueOrDefault(value.expiryYear);
|
||||
if (expYear != null) {
|
||||
@@ -52,7 +54,9 @@ export class RememBearCsvImporter extends BaseImporter implements Importer {
|
||||
cipher.card.expYear = expYearNumber.toString();
|
||||
}
|
||||
}
|
||||
} catch { }
|
||||
} catch {
|
||||
// Ignore error
|
||||
}
|
||||
|
||||
const pin = this.getValueOrDefault(value.pin);
|
||||
if (pin != null) {
|
||||
|
||||
@@ -47,7 +47,9 @@ export class TrueKeyCsvImporter extends BaseImporter implements Importer {
|
||||
const expDate = new Date(value.expiryDate);
|
||||
cipher.card.expYear = expDate.getFullYear().toString();
|
||||
cipher.card.expMonth = (expDate.getMonth() + 1).toString();
|
||||
} catch { }
|
||||
} catch {
|
||||
// Ignore error
|
||||
}
|
||||
}
|
||||
} else if (value.kind !== 'login') {
|
||||
cipher.type = CipherType.SecureNote;
|
||||
|
||||
@@ -238,7 +238,9 @@ export class Utils {
|
||||
|
||||
const urlDomain = tldjs != null && tldjs.getDomain != null ? tldjs.getDomain(url.hostname) : null;
|
||||
return urlDomain != null ? urlDomain : url.hostname;
|
||||
} catch (e) { }
|
||||
} catch (e) {
|
||||
// Invalid domain, try another approach below.
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -367,7 +369,9 @@ export class Utils {
|
||||
anchor.href = uriString;
|
||||
return anchor as any;
|
||||
}
|
||||
} catch (e) { }
|
||||
} catch (e) {
|
||||
// Ignore error
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,9 @@ export class AttachmentView implements View {
|
||||
if (this.size != null) {
|
||||
return parseInt(this.size, null);
|
||||
}
|
||||
} catch { }
|
||||
} catch {
|
||||
// Invalid file size.
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ export class SendFileView implements View {
|
||||
if (this.size != null) {
|
||||
return parseInt(this.size, null);
|
||||
}
|
||||
} catch { }
|
||||
} catch {
|
||||
// Invalid file size.
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -185,7 +185,9 @@ class Version {
|
||||
this.year = parts[0];
|
||||
this.month = parts[1];
|
||||
this.day = parts[2];
|
||||
} catch { }
|
||||
} catch {
|
||||
// Ignore error
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Compares two Azure Versions against each other
|
||||
|
||||
@@ -51,6 +51,7 @@ import { UserService } from '../abstractions/user.service';
|
||||
|
||||
import { ConstantsService } from './constants.service';
|
||||
|
||||
import { LogService } from '../abstractions/log.service';
|
||||
import { sequentialize } from '../misc/sequentialize';
|
||||
import { Utils } from '../misc/utils';
|
||||
|
||||
@@ -73,7 +74,8 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
constructor(private cryptoService: CryptoService, private userService: UserService,
|
||||
private settingsService: SettingsService, private apiService: ApiService,
|
||||
private fileUploadService: FileUploadService, private storageService: StorageService,
|
||||
private i18nService: I18nService, private searchService: () => SearchService) {
|
||||
private i18nService: I18nService, private searchService: () => SearchService,
|
||||
private logService: LogService) {
|
||||
}
|
||||
|
||||
get decryptedCipherCache() {
|
||||
@@ -423,7 +425,9 @@ export class CipherService implements CipherServiceAbstraction {
|
||||
if (regex.test(url)) {
|
||||
return true;
|
||||
}
|
||||
} catch { }
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
}
|
||||
break;
|
||||
case UriMatchType.Never:
|
||||
default:
|
||||
|
||||
@@ -564,7 +564,9 @@ export class CryptoService implements CryptoServiceAbstraction {
|
||||
try {
|
||||
encType = parseInt(headerPieces[0], null);
|
||||
encPieces = headerPieces[1].split('|');
|
||||
} catch (e) { }
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
switch (encType) {
|
||||
|
||||
@@ -10,13 +10,15 @@ import { EventService as EventServiceAbstraction } from '../abstractions/event.s
|
||||
import { StorageService } from '../abstractions/storage.service';
|
||||
import { UserService } from '../abstractions/user.service';
|
||||
|
||||
import { LogService } from '../abstractions/log.service';
|
||||
import { ConstantsService } from './constants.service';
|
||||
|
||||
export class EventService implements EventServiceAbstraction {
|
||||
private inited = false;
|
||||
|
||||
constructor(private storageService: StorageService, private apiService: ApiService,
|
||||
private userService: UserService, private cipherService: CipherService) { }
|
||||
private userService: UserService, private cipherService: CipherService,
|
||||
private logService: LogService) { }
|
||||
|
||||
init(checkOnInterval: boolean) {
|
||||
if (this.inited) {
|
||||
@@ -83,7 +85,9 @@ export class EventService implements EventServiceAbstraction {
|
||||
try {
|
||||
await this.apiService.postEventsCollect(request);
|
||||
this.clearEvents();
|
||||
} catch { }
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async clearEvents(): Promise<any> {
|
||||
|
||||
@@ -192,7 +192,9 @@ export class NotificationsService implements NotificationsServiceAbstraction {
|
||||
if (sync) {
|
||||
await this.syncService.fullSync(false);
|
||||
}
|
||||
} catch { }
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
}
|
||||
|
||||
if (!this.connected) {
|
||||
this.reconnectTimer = setTimeout(() => this.reconnect(sync), this.random(120000, 300000));
|
||||
|
||||
@@ -125,7 +125,9 @@ export class SearchService implements SearchServiceAbstraction {
|
||||
if (isQueryString) {
|
||||
try {
|
||||
searchResults = index.search(query.substr(1).trim());
|
||||
} catch { }
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
}
|
||||
} else {
|
||||
// tslint:disable-next-line
|
||||
const soWild = lunr.Query.wildcard.LEADING | lunr.Query.wildcard.TRAILING;
|
||||
|
||||
@@ -3,6 +3,7 @@ import { CipherService } from '../abstractions/cipher.service';
|
||||
import { CollectionService } from '../abstractions/collection.service';
|
||||
import { CryptoService } from '../abstractions/crypto.service';
|
||||
import { FolderService } from '../abstractions/folder.service';
|
||||
import { LogService } from '../abstractions/log.service';
|
||||
import { MessagingService } from '../abstractions/messaging.service';
|
||||
import { PolicyService } from '../abstractions/policy.service';
|
||||
import { SendService } from '../abstractions/send.service';
|
||||
@@ -44,7 +45,8 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
private cipherService: CipherService, private cryptoService: CryptoService,
|
||||
private collectionService: CollectionService, private storageService: StorageService,
|
||||
private messagingService: MessagingService, private policyService: PolicyService,
|
||||
private sendService: SendService, private logoutCallback: (expired: boolean) => Promise<void>) {
|
||||
private sendService: SendService, private logService: LogService,
|
||||
private logoutCallback: (expired: boolean) => Promise<void>) {
|
||||
}
|
||||
|
||||
async getLastSync(): Promise<Date> {
|
||||
@@ -131,7 +133,9 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
return this.syncCompleted(true);
|
||||
}
|
||||
}
|
||||
} catch { }
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
}
|
||||
}
|
||||
return this.syncCompleted(false);
|
||||
}
|
||||
@@ -230,7 +234,9 @@ export class SyncService implements SyncServiceAbstraction {
|
||||
return this.syncCompleted(true);
|
||||
}
|
||||
}
|
||||
} catch { }
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
}
|
||||
}
|
||||
return this.syncCompleted(false);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ConstantsService } from './constants.service';
|
||||
|
||||
import { CryptoFunctionService } from '../abstractions/cryptoFunction.service';
|
||||
import { LogService } from '../abstractions/log.service';
|
||||
import { StorageService } from '../abstractions/storage.service';
|
||||
import { TotpService as TotpServiceAbstraction } from '../abstractions/totp.service';
|
||||
|
||||
@@ -10,7 +11,8 @@ const B32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
||||
const SteamChars = '23456789BCDFGHJKMNPQRTVWXY';
|
||||
|
||||
export class TotpService implements TotpServiceAbstraction {
|
||||
constructor(private storageService: StorageService, private cryptoFunctionService: CryptoFunctionService) { }
|
||||
constructor(private storageService: StorageService, private cryptoFunctionService: CryptoFunctionService,
|
||||
private logService: LogService) { }
|
||||
|
||||
async getCode(key: string): Promise<string> {
|
||||
if (key == null) {
|
||||
@@ -32,7 +34,9 @@ export class TotpService implements TotpServiceAbstraction {
|
||||
} else if (digitParams > 0) {
|
||||
digits = digitParams;
|
||||
}
|
||||
} catch { }
|
||||
} catch {
|
||||
this.logService.error('Invalid digits param.');
|
||||
}
|
||||
}
|
||||
if (params.has('period') && params.get('period') != null) {
|
||||
try {
|
||||
@@ -40,7 +44,9 @@ export class TotpService implements TotpServiceAbstraction {
|
||||
if (periodParam > 0) {
|
||||
period = periodParam;
|
||||
}
|
||||
} catch { }
|
||||
} catch {
|
||||
this.logService.error('Invalid period param.');
|
||||
}
|
||||
}
|
||||
if (params.has('secret') && params.get('secret') != null) {
|
||||
keyB32 = params.get('secret');
|
||||
@@ -99,7 +105,9 @@ export class TotpService implements TotpServiceAbstraction {
|
||||
if (params.has('period') && params.get('period') != null) {
|
||||
try {
|
||||
period = parseInt(params.get('period').trim(), null);
|
||||
} catch { }
|
||||
} catch {
|
||||
this.logService.error('Invalid period param.');
|
||||
}
|
||||
}
|
||||
}
|
||||
return period;
|
||||
|
||||
Reference in New Issue
Block a user