Showing 74 of 203 total issues
File VaultSource.ts
has 532 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import EventEmitter from "eventemitter3";
import { ChannelQueue } from "@buttercup/channel-queue";
import { Layerr } from "layerr";
import { Vault } from "./Vault.js";
import { Credentials } from "../credentials/Credentials.js";
File VaultFormatA.ts
has 473 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { Layerr } from "layerr";
import { VaultFormat } from "./VaultFormat.js";
import { Vault } from "../core/Vault.js";
import { Credentials } from "../credentials/Credentials.js";
import {
VaultFormat
has 50 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class VaultFormat extends EventEmitter {
static encodeRaw(rawContent: History, credentials: Credentials) {
notImplemented();
}
VaultFormatA
has 50 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class VaultFormatA extends VaultFormat {
static async encodeRaw(rawContent: History, credentials: Credentials): Promise<string> {
const compress = getSharedAppEnv().getProperty("compression/v1/compressText");
const encrypt = getSharedAppEnv().getProperty("crypto/v1/encryptText");
const { masterPassword } = getCredentials(credentials.id);
VaultFormatB
has 48 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class VaultFormatB extends VaultFormat {
static encodeRaw(rawContent: History, credentials: Credentials): Promise<string> {
const compress = getSharedAppEnv().getProperty("compression/v2/compressText");
const encrypt = getSharedAppEnv().getProperty("crypto/v1/encryptText");
const { masterPassword } = getCredentials(credentials.id);
File VaultFormatB.ts
has 398 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { ORPHANS_GROUP_TITLE, VaultFormat } from "./VaultFormat.js";
import { Vault } from "../core/Vault.js";
import { generateUUID } from "../tools/uuid.js";
import { getSharedAppEnv } from "../env/appEnv.js";
import { getCredentials } from "../credentials/channel.js";
Function consumeVaultFacade
has 134 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function consumeVaultFacade(vault: Vault, facade: VaultFacade, options: ConsumeVaultFacadeOptions = {}) {
if (facade._ver !== FACADE_VERSION) {
throw new Error("Invalid vault facade version");
}
if (!facade || (facade && facade.type !== "vault")) {
VaultSource
has 38 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class VaultSource extends EventEmitter {
static STATUS_LOCKED = VaultSourceStatus.Locked;
static STATUS_PENDING = VaultSourceStatus.Pending;
static STATUS_UNLOCKED = VaultSourceStatus.Unlocked;
Function describeVaultDataset
has 100 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function describeVaultDataset(dataset: FormatAVault | FormatAGroup, parentGroupID: GroupID): History {
const isVault = typeof (<FormatAVault>dataset).format === "string";
const currentGroupID = isVault ? "0" : dataset.id;
const entries = currentGroupID === "0" ? [] : (<FormatAGroup>dataset).entries || [];
var commands = [];
Function buildClient
has 92 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function buildClient(token: string) {
const encrypt = getSharedAppEnv().getProperty("crypto/v1/encryptText");
const decrypt = getSharedAppEnv().getProperty("crypto/v1/decryptText");
return {
readdir: (remotePath, callback) => {
Function describeVaultDataset
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
Open
export function describeVaultDataset(dataset: FormatAVault | FormatAGroup, parentGroupID: GroupID): History {
const isVault = typeof (<FormatAVault>dataset).format === "string";
const currentGroupID = isVault ? "0" : dataset.id;
const entries = currentGroupID === "0" ? [] : (<FormatAGroup>dataset).entries || [];
var commands = [];
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function generateVaultInsights
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function generateVaultInsights(vault: Vault): VaultInsights {
let groupCount = 0,
entryCount = 0,
trashEntryCount = 0,
trashGroupCount = 0,
VaultManager
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class VaultManager extends EventEmitter {
/**
* Key prefix for stored vaults
* @static
* @memberof VaultManager
File VaultManager.ts
has 276 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import EventEmitter from "eventemitter3";
import { Layerr } from "layerr";
import isPromise from "is-promise";
import { ChannelQueue } from "@buttercup/channel-queue";
import { MemoryStorageInterface } from "../storage/MemoryStorageInterface.js";
Function unlock
has 65 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
async unlock(vaultCredentials: Credentials, config: VaultSourceUnlockOptions = {}) {
if (!Credentials.isCredentials(vaultCredentials)) {
throw new Layerr(`Failed unlocking source: Invalid credentials passed to source: ${this.id}`);
}
const { initialiseRemote = false, loadOfflineCopy = false, storeOfflineCopy = true } = config;
Function createCreditCardFields
has 61 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function createCreditCardFields(entry: Entry): Array<EntryFacadeField> {
return [
...createBaseFields(entry),
createFieldDescriptor(entry, "Card Holder", EntryPropertyType.Property, "username"),
createFieldDescriptor(entry, "Card Number", EntryPropertyType.Property, "password", {
Function searchByURL
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
Open
searchByURL(url: string): Array<SearchResult> {
const incomingDomain = extractDomain(url);
if (!incomingDomain) {
this._results = [];
return this._results;
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function mergeRawVaults
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function mergeRawVaults(base: FormatBVault, incoming: FormatBVault): FormatBVault {
const newVault: FormatBVault = {
id: base.id,
a: mergeProperties(base.a, incoming.a, EntryPropertyType.Attribute),
g: [],
File tools.ts
has 257 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import { encodeStringValue } from "../../tools/encoding.js";
import { generateUUID } from "../../tools/uuid.js";
import {
EntryLegacyHistoryItem,
EntryID,
Vault
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
Open
export class Vault extends EventEmitter {
static Attribute = Object.freeze({
AttachmentsKey: "BC_ATTACHMENTS_KEY"
});