buttercup-pw/buttercup-core

View on GitHub

Showing 83 of 216 total issues

File VaultSource.ts has 619 lines of code (exceeds 250 allowed). Consider refactoring.
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";
Severity: Major
Found in source/core/VaultSource.ts - About 1 day to fix

    File VaultFormatA.ts has 483 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import { Layerr } from "layerr";
    import { VaultFormat } from "./VaultFormat.js";
    import { Vault } from "../core/Vault.js";
    import { Credentials } from "../credentials/Credentials.js";
    import {
    Severity: Minor
    Found in source/io/VaultFormatA.ts - About 7 hrs to fix

      VaultFormat has 50 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export class VaultFormat extends EventEmitter {
          static encodeRaw(rawContent: History, credentials: Credentials) {
              notImplemented();
          }
      
      
      Severity: Minor
      Found in source/io/VaultFormat.ts - About 7 hrs to fix

        VaultFormatA has 50 functions (exceeds 20 allowed). Consider refactoring.
        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 = getMasterPassword(credentials.id);
        Severity: Minor
        Found in source/io/VaultFormatA.ts - About 7 hrs to fix

          VaultFormatB has 48 functions (exceeds 20 allowed). Consider refactoring.
          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 = getMasterPassword(credentials.id);
          Severity: Minor
          Found in source/io/VaultFormatB.ts - About 6 hrs to fix

            File VaultFormatB.ts has 423 lines of code (exceeds 250 allowed). Consider refactoring.
            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 { getMasterPassword } from "../credentials/memory/password.js";
            Severity: Minor
            Found in source/io/VaultFormatB.ts - About 6 hrs to fix

              Function consumeVaultFacade has 139 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              export function consumeVaultFacade(
                  vault: Vault,
                  facade: VaultFacade,
                  options: ConsumeVaultFacadeOptions = {}
              ) {
              Severity: Major
              Found in source/facades/vault.ts - About 5 hrs to fix

                VaultSource has 38 functions (exceeds 20 allowed). Consider refactoring.
                Open

                export class VaultSource extends EventEmitter {
                    static STATUS_LOCKED = VaultSourceStatus.Locked;
                    static STATUS_PENDING = VaultSourceStatus.Pending;
                    static STATUS_UNLOCKED = VaultSourceStatus.Unlocked;
                
                
                Severity: Minor
                Found in source/core/VaultSource.ts - About 5 hrs to fix

                  Function describeVaultDataset has 98 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export function describeVaultDataset(
                      dataset: FormatAVault | FormatAGroup,
                      parentGroupID: GroupID
                  ): History {
                      const isVault = typeof (<FormatAVault>dataset).format === "string";
                  Severity: Major
                  Found in source/io/formatA/describe.ts - About 3 hrs to fix

                    Function buildClient has 92 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function buildClient(token: string) {
                        const encrypt = getSharedAppEnv().getProperty("crypto/v1/encryptText");
                        const decrypt = getSharedAppEnv().getProperty("crypto/v1/decryptText");
                        return {
                            readdir: (remotePath, callback) => {
                    Severity: Major
                    Found in source/web/localFileClient.ts - About 3 hrs to fix

                      Function describeVaultDataset has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
                      Open

                      export function describeVaultDataset(
                          dataset: FormatAVault | FormatAGroup,
                          parentGroupID: GroupID
                      ): History {
                          const isVault = typeof (<FormatAVault>dataset).format === "string";
                      Severity: Minor
                      Found in source/io/formatA/describe.ts - About 3 hrs to fix

                      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

                      File commands.ts has 300 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      import {
                          findEntryByID,
                          findGroupByID,
                          findGroupContainingEntryID,
                          findGroupContainingGroupID,
                      Severity: Minor
                      Found in source/io/formatA/commands.ts - About 3 hrs to fix

                        Function unlock has 78 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            async unlock(vaultCredentials: Credentials, config: VaultSourceUnlockOptions = {}) {
                                if (!Credentials.isCredentials(vaultCredentials)) {
                                    throw new Layerr(
                                        `Failed unlocking source: Invalid credentials passed to source: ${this.id}`
                                    );
                        Severity: Major
                        Found in source/core/VaultSource.ts - About 3 hrs to fix

                          File VaultManager.ts has 286 lines of code (exceeds 250 allowed). Consider refactoring.
                          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";
                          Severity: Minor
                          Found in source/core/VaultManager.ts - About 2 hrs to fix

                            Function generateVaultInsights has 69 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                            export function generateVaultInsights(vault: Vault): VaultInsights {
                                let groupCount = 0,
                                    entryCount = 0,
                                    trashEntryCount = 0,
                                    trashGroupCount = 0,
                            Severity: Major
                            Found in source/insight/vault.ts - About 2 hrs to fix

                              Vault has 24 functions (exceeds 20 allowed). Consider refactoring.
                              Open

                              export class Vault extends EventEmitter {
                                  static Attribute = Object.freeze({
                                      AttachmentsKey: "BC_ATTACHMENTS_KEY"
                                  });
                              
                              
                              Severity: Minor
                              Found in source/core/Vault.ts - About 2 hrs to fix

                                VaultManager has 24 functions (exceeds 20 allowed). Consider refactoring.
                                Open

                                export class VaultManager extends EventEmitter {
                                    /**
                                     * Key prefix for stored vaults
                                     * @static
                                     * @memberof VaultManager
                                Severity: Minor
                                Found in source/core/VaultManager.ts - About 2 hrs to fix

                                  Function mergeRawVaults has 64 lines of code (exceeds 25 allowed). Consider refactoring.
                                  Open

                                  export function mergeRawVaults(base: FormatBVault, incoming: FormatBVault): FormatBVault {
                                      const newVault: FormatBVault = {
                                          id: base.id,
                                          a: mergeProperties(base.a, incoming.a, EntryPropertyType.Attribute),
                                          g: [],
                                  Severity: Major
                                  Found in source/io/formatB/merge.ts - About 2 hrs to fix

                                    Function createCreditCardFields has 61 lines of code (exceeds 25 allowed). Consider refactoring.
                                    Open

                                    function createCreditCardFields(entry: Entry): Array<EntryFacadeField> {
                                        return [
                                            ...createBaseFields(entry),
                                            createFieldDescriptor(entry, "Card Holder", EntryPropertyType.Property, "username"),
                                            createFieldDescriptor(entry, "Card Number", EntryPropertyType.Property, "password", {
                                    Severity: Major
                                    Found in source/facades/entryFields.ts - About 2 hrs to fix

                                      Function searchByURL has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          searchByURL(url: string): Array<SearchResult> {
                                              const incomingDomain = extractDomain(url);
                                              if (!incomingDomain) {
                                                  this._results = [];
                                                  return this._results;
                                      Severity: Minor
                                      Found in source/search/BaseSearch.ts - About 2 hrs to fix

                                      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

                                      Severity
                                      Category
                                      Status
                                      Source
                                      Language