buttercup-pw/buttercup-core

View on GitHub

Showing 67 of 184 total issues

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

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

    File VaultSource.ts has 466 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";
    import Credentials from "../credentials/Credentials";
    Severity: Minor
    Found in source/core/VaultSource.ts - About 7 hrs to fix

      VaultFormatA has 51 functions (exceeds 20 allowed). Consider refactoring.
      Open

      export default class VaultFormatA extends VaultFormat {
          static 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);
      Severity: Major
      Found in source/io/VaultFormatA.ts - About 7 hrs to fix

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

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

          VaultFormatB has 48 functions (exceeds 20 allowed). Consider refactoring.
          Open

          export default 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);
          Severity: Minor
          Found in source/io/VaultFormatB.ts - About 6 hrs to fix

            Function consumeVaultFacade has 134 lines of code (exceeds 25 allowed). Consider refactoring.
            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")) {
            Severity: Major
            Found in source/facades/vault.ts - About 5 hrs to fix

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

              export default 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 4 hrs to fix

                File VaultFormatB.ts has 338 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                import VaultFormat from "./VaultFormat";
                import Vault from "../core/Vault";
                import { generateUUID } from "../tools/uuid";
                import { getSharedAppEnv } from "../env/appEnv";
                import { getCredentials } from "../credentials/channel";
                Severity: Minor
                Found in source/io/VaultFormatB.ts - About 4 hrs to fix

                  Function describeVaultDataset has 100 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";
                      const currentGroupID = isVault ? "0" : dataset.id;
                      const entries = currentGroupID === "0" ? [] : (<FormatAGroup>dataset).entries || [];
                      var commands = [];
                  Severity: Major
                  Found in source/io/formatA/describe.ts - About 4 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";
                          const currentGroupID = isVault ? "0" : dataset.id;
                          const entries = currentGroupID === "0" ? [] : (<FormatAGroup>dataset).entries || [];
                          var commands = [];
                      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

                      Function unlock has 75 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}`);
                              }
                              const { initialiseRemote = false, loadOfflineCopy = false, storeOfflineCopy = true } = config;
                      Severity: Major
                      Found in source/core/VaultSource.ts - About 3 hrs to fix

                        Function generateVaultInsights has 68 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

                          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

                            File tools.ts has 267 lines of code (exceeds 250 allowed). Consider refactoring.
                            Open

                            import { encodeStringValue } from "../../tools/encoding";
                            import { generateUUID } from "../../tools/uuid";
                            import {
                                EntryLegacyHistoryItem,
                                EntryID,
                            Severity: Minor
                            Found in source/io/formatA/tools.ts - About 2 hrs to fix

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

                              export default 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

                                File VaultManager.ts has 262 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";
                                Severity: Minor
                                Found in source/core/VaultManager.ts - About 2 hrs to fix

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

                                  export default 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

                                    Function findEntryByID has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                                    Open

                                    export function findEntryByID(groups: Array<FormatAGroup>, id: EntryID) {
                                        for (let i = 0, groupsLen = groups.length; i < groupsLen; i += 1) {
                                            const group = groups[i];
                                            if (group.entries) {
                                                for (let j = 0, entriesLen = group.entries.length; j < entriesLen; j += 1) {
                                    Severity: Minor
                                    Found in source/io/formatA/tools.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