buttercup-pw/buttercup-core

View on GitHub

Showing 216 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

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      export function encryptAttachment(buff: BufferLike, credentials: Credentials): Promise<BufferLike> {
          const masterPassword = getMasterPassword(credentials.id);
          const encrypt = getSharedAppEnv().getProperty("crypto/v2/encryptBuffer");
          return encrypt(buff, masterPassword);
      }
      Severity: Major
      Found in source/tools/attachments.ts and 1 other location - About 2 hrs to fix
      source/tools/attachments.ts on lines 8..12

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 78.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      Further Reading

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      export function decryptAttachment(buff: BufferLike, credentials: Credentials): Promise<BufferLike> {
          const masterPassword = getMasterPassword(credentials.id);
          const decrypt = getSharedAppEnv().getProperty("crypto/v2/decryptBuffer");
          return decrypt(buff, masterPassword);
      }
      Severity: Major
      Found in source/tools/attachments.ts and 1 other location - About 2 hrs to fix
      source/tools/attachments.ts on lines 14..18

      Duplicated Code

      Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

      Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

      When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

      Tuning

      This issue has a mass of 78.

      We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

      The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

      If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

      See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

      Refactorings

      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

      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

      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

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          function createLoginFields(entry: Entry): Array<EntryFacadeField> {
              return [
                  ...createBaseFields(entry),
                  createFieldDescriptor(entry, "Username", EntryPropertyType.Property, "username"),
                  createFieldDescriptor(entry, "Password", EntryPropertyType.Property, "password", {
          Severity: Major
          Found in source/facades/entryFields.ts and 1 other location - About 1 hr to fix
          source/facades/entryFields.ts on lines 99..107

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 73.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  for (const entryID in this.source.del.e) {
                      if (this.source.del.e[entryID] < cutoff) {
                          delete this.source.del.e[entryID];
                      }
                  }
          Severity: Major
          Found in source/io/VaultFormatB.ts and 1 other location - About 1 hr to fix
          source/io/VaultFormatB.ts on lines 406..410

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 73.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

          function createSSHKeyFields(entry: Entry): Array<EntryFacadeField> {
              return [
                  ...createBaseFields(entry),
                  createFieldDescriptor(entry, "Public key", EntryPropertyType.Property, "publicKey"),
                  createFieldDescriptor(entry, "Private key", EntryPropertyType.Property, "privateKey", {
          Severity: Major
          Found in source/facades/entryFields.ts and 1 other location - About 1 hr to fix
          source/facades/entryFields.ts on lines 80..88

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 73.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                  for (const groupID in this.source.del.g) {
                      if (this.source.del.g[groupID] < cutoff) {
                          delete this.source.del.g[groupID];
                      }
                  }
          Severity: Major
          Found in source/io/VaultFormatB.ts and 1 other location - About 1 hr to fix
          source/io/VaultFormatB.ts on lines 401..405

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 73.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          export function vaultContentsEncrypted(contents: string): boolean {
              if (typeof contents === "string" && hasValidSignature(contents)) {
                  const exSig = stripSignature(contents);
                  return /["\s\t\n~]/.test(exSig) === false;
              }
          Severity: Major
          Found in source/io/formatB/signing.ts and 1 other location - About 1 hr to fix
          source/io/formatA/signing.ts on lines 53..59

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 72.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

              createEntry(groupID: GroupID, entryID: EntryID) {
                  this.execute(
                      Inigo.create(Inigo.Command.CreateEntry)
                          .addArgument(groupID)
                          .addArgument(entryID)
          Severity: Major
          Found in source/io/VaultFormatA.ts and 3 other locations - About 1 hr to fix
          source/io/VaultFormatA.ts on lines 220..227
          source/io/VaultFormatA.ts on lines 417..424
          source/io/VaultFormatA.ts on lines 426..433

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 72.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

              moveEntry(entryID: EntryID, groupID: GroupID) {
                  this.execute(
                      Inigo.create(Inigo.Command.MoveEntry)
                          .addArgument(entryID)
                          .addArgument(groupID)
          Severity: Major
          Found in source/io/VaultFormatA.ts and 3 other locations - About 1 hr to fix
          source/io/VaultFormatA.ts on lines 211..218
          source/io/VaultFormatA.ts on lines 220..227
          source/io/VaultFormatA.ts on lines 426..433

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 72.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

              createGroup(parentID: GroupID, groupID: GroupID) {
                  this.execute(
                      Inigo.create(Inigo.Command.CreateGroup)
                          .addArgument(parentID)
                          .addArgument(groupID)
          Severity: Major
          Found in source/io/VaultFormatA.ts and 3 other locations - About 1 hr to fix
          source/io/VaultFormatA.ts on lines 211..218
          source/io/VaultFormatA.ts on lines 417..424
          source/io/VaultFormatA.ts on lines 426..433

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 72.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Identical blocks of code found in 2 locations. Consider refactoring.
          Open

          export function vaultContentsEncrypted(contents: string): boolean {
              if (typeof contents === "string" && hasValidSignature(contents)) {
                  const exSig = stripSignature(contents);
                  return /["\s\t\n~]/.test(exSig) === false;
              }
          Severity: Major
          Found in source/io/formatA/signing.ts and 1 other location - About 1 hr to fix
          source/io/formatB/signing.ts on lines 45..51

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 72.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 4 locations. Consider refactoring.
          Open

              moveGroup(groupID: GroupID, newParentID: GroupID) {
                  this.execute(
                      Inigo.create(Inigo.Command.MoveGroup)
                          .addArgument(groupID)
                          .addArgument(newParentID)
          Severity: Major
          Found in source/io/VaultFormatA.ts and 3 other locations - About 1 hr to fix
          source/io/VaultFormatA.ts on lines 211..218
          source/io/VaultFormatA.ts on lines 220..227
          source/io/VaultFormatA.ts on lines 417..424

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 72.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

              findEntryByID(id: EntryID): Entry | null {
                  return (
                      getAllChildEntries(this.vault._entries, this.id).find((entry) => entry.id === id) ||
                      null
                  );
          Severity: Major
          Found in source/core/Group.ts and 1 other location - About 1 hr to fix
          source/core/Group.ts on lines 154..158

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 72.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

                      for (const group of groups) {
                          if (groupIDs.includes(group.g) === false) {
                              // Re-attach orphaned group
                              const orphansGroup = this.prepareOrphansGroup();
                              this.moveGroup(group.id, orphansGroup.id);
          Severity: Major
          Found in source/io/VaultFormatB.ts and 1 other location - About 1 hr to fix
          source/io/VaultFormatB.ts on lines 391..397

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 72.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language