buttercup-pw/buttercup-core

View on GitHub

Showing 83 of 216 total issues

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

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

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

    export class Entry extends VaultItem {
        static Attributes = Object.freeze({
            AttachmentPrefix: "BC_ENTRY_ATTACHMENT:",
            FacadeType: "BC_ENTRY_FACADE_TYPE",
            FieldTypePrefix: "BC_ENTRY_FIELD_TYPE:",
    Severity: Minor
    Found in source/core/Entry.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

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

      export function findGroupContainingEntryID(groups: Array<FormatAGroup>, id: EntryID) {
          for (let i = 0, groupsLen = groups.length; i < groupsLen; i += 1) {
              const group = groups[i];
              if (group.entries) {
                  for (var 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

      File vault.ts has 251 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import { consumeEntryFacade, createEntryFacade } from "./entry.js";
      import { idSignifiesNew } from "./tools.js";
      import { FACADE_VERSION } from "./symbols.js";
      import { Entry } from "../core/Entry.js";
      import { Group } from "../core/Group.js";
      Severity: Minor
      Found in source/facades/vault.ts - About 2 hrs to fix

        Function searchByURL has 49 lines of code (exceeds 25 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 1 hr to fix

          Function calculateCommonRecentCommand has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
          Open

          function calculateCommonRecentCommand(
              historyA: History,
              historyB: History
          ): CommonRecentCommandResult | null {
              const getCommandType = (fullCommand) =>
          Severity: Minor
          Found in source/io/formatA/VaultComparator.ts - About 1 hr 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 changeMasterPassword has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              async changeMasterPassword(
                  oldPassword: string,
                  newPassword: string,
                  meta: { [key: string]: any } = {}
              ) {
          Severity: Minor
          Found in source/core/VaultSource.ts - About 1 hr to fix

            Function valuesDiffer has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            export function valuesDiffer(value1: FormatBValue, value2: FormatBValue): boolean {
                if ((!value1 && value2) || (value1 && !value2)) return true;
                for (const prop of ["value", "created", "updated"]) {
                    if (value1[prop] !== value2[prop]) return true;
                }
            Severity: Minor
            Found in source/io/formatB/compare.ts - About 1 hr 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 createEntryFacade has 36 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function createEntryFacade(
                entry?: Entry,
                options: CreateEntryFacadeOptions = {}
            ): EntryFacade {
                if (entry && entry instanceof Entry !== true) {
            Severity: Minor
            Found in source/facades/entry.ts - About 1 hr to fix

              Function setAttachment has 36 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  async setAttachment(
                      entry: Entry,
                      attachmentID: string,
                      attachmentData: Buffer | ArrayBuffer,
                      name: string,
              Severity: Minor
              Found in source/attachments/AttachmentManager.ts - About 1 hr to fix

                Function optimise has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                Open

                    optimise() {
                        // Initialise first
                        this.initialise();
                        // Clean up orphans
                        {
                Severity: Minor
                Found in source/io/VaultFormatB.ts - About 1 hr 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 mergeRawVaults has a Cognitive Complexity of 12 (exceeds 5 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: Minor
                Found in source/io/formatB/merge.ts - About 1 hr 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 optimise has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    optimise() {
                        // Initialise first
                        this.initialise();
                        // Clean up orphans
                        {
                Severity: Minor
                Found in source/io/VaultFormatB.ts - About 1 hr to fix

                  Function save has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      async save(config: VaultSourceSaveOptions = {}) {
                          const { storeOfflineCopy = true } = config;
                          await this._enqueueStateChange(async () => {
                              if (await this.localDiffersFromRemote()) {
                                  await this.mergeFromRemote();
                  Severity: Minor
                  Found in source/core/VaultSource.ts - About 1 hr to fix

                    Function localDiffersFromRemote has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        localDiffersFromRemote(): Promise<boolean> {
                            if (this.status !== VaultSource.STATUS_UNLOCKED) {
                                return Promise.reject(
                                    new Layerr(
                                        `Failed diffing source: Source not unlocked (${this.status}): ${this.id}`
                    Severity: Minor
                    Found in source/core/VaultSource.ts - About 1 hr to fix

                      Function writeFile has 32 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                              writeFile: (remotePath, data, options, callback) => {
                                  const encrypt = getSharedAppEnv().getProperty("crypto/v1/encryptText");
                                  const cb = typeof options === "function" ? options : callback;
                                  if (typeof data !== "string") {
                                      throw new Error("Failed writing file: Expected data to be of type string");
                      Severity: Minor
                      Found in source/web/localFileClient.ts - About 1 hr to fix

                        Function findEntriesByTag has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            findEntriesByTag(tag: string, exact: boolean = true): Array<Entry> {
                                const tagLower = tag.toLowerCase();
                                if (!exact) {
                                    const entryIDs = new Set<string>();
                                    for (const [currentTag, currentIDs] of this._tagMap.entries()) {
                        Severity: Minor
                        Found in source/core/Vault.ts - About 1 hr 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 findGroupContainingGroupID has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                            findGroupContainingGroupID(id: GroupID): FormatAGroup {
                                const searchGroups = (groups: Array<FormatAGroup>): FormatAGroup => {
                                    for (const group of groups) {
                                        if (group.id === id) return null;
                                        const children = group.groups || [];
                        Severity: Minor
                        Found in source/io/VaultFormatA.ts - About 1 hr 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 consumeVaultFacade has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                        Open

                        export function consumeVaultFacade(
                            vault: Vault,
                            facade: VaultFacade,
                            options: ConsumeVaultFacadeOptions = {}
                        ) {
                        Severity: Minor
                        Found in source/facades/vault.ts - About 1 hr 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