buttercup-pw/buttercup-core

View on GitHub

Showing 184 of 184 total issues

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

export function decryptAttachment(buff: BufferLike, credentials: Credentials): Promise<BufferLike> {
    const { masterPassword } = getCredentials(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 84.

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 encryptAttachment(buff: BufferLike, credentials: Credentials): Promise<BufferLike> {
    const { masterPassword } = getCredentials(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 84.

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

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

          setGroupAttribute(groupID: GroupID, attribute: string, value: string) {
              this.execute(
                  Inigo.create(Inigo.Command.SetGroupAttribute)
                      .addArgument(groupID)
                      .addArgument(attribute)
      Severity: Major
      Found in source/io/VaultFormatA.ts and 2 other locations - About 2 hrs to fix
      source/io/VaultFormatA.ts on lines 442..450
      source/io/VaultFormatA.ts on lines 452..460

      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 83.

      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 3 locations. Consider refactoring.
      Open

          setEntryAttribute(entryID: EntryID, attribute: string, value: string) {
              this.execute(
                  Inigo.create(Inigo.Command.SetEntryAttribute)
                      .addArgument(entryID)
                      .addArgument(attribute)
      Severity: Major
      Found in source/io/VaultFormatA.ts and 2 other locations - About 2 hrs to fix
      source/io/VaultFormatA.ts on lines 452..460
      source/io/VaultFormatA.ts on lines 462..470

      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 83.

      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 3 locations. Consider refactoring.
      Open

          setEntryProperty(entryID: EntryID, property: string, value: string) {
              this.execute(
                  Inigo.create(Inigo.Command.SetEntryProperty)
                      .addArgument(entryID)
                      .addArgument(property)
      Severity: Major
      Found in source/io/VaultFormatA.ts and 2 other locations - About 2 hrs to fix
      source/io/VaultFormatA.ts on lines 442..450
      source/io/VaultFormatA.ts on lines 462..470

      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 83.

      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

      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

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

            deleteEntry(entryID: EntryID) {
                const ind = this.source.e.findIndex(entry => entry.id === entryID);
                if (ind >= 0) {
                    this.source.e.splice(ind, 1);
                }
        Severity: Major
        Found in source/io/VaultFormatB.ts and 1 other location - About 2 hrs to fix
        source/io/VaultFormatB.ts on lines 167..172

        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 81.

        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

            deleteGroup(groupID: GroupID) {
                const ind = this.source.g.findIndex(group => group.id === groupID);
                if (ind >= 0) {
                    this.source.g.splice(ind, 1);
                }
        Severity: Major
        Found in source/io/VaultFormatB.ts and 1 other location - About 2 hrs to fix
        source/io/VaultFormatB.ts on lines 148..153

        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 81.

        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

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

            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

                  moveEntry(entryID: EntryID, groupID: GroupID) {
                      const entry = this.source.e.find((e: FormatBEntry) => e.id === entryID);
                      entry.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 332..335

              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 74.

              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

                  moveGroup(groupID: GroupID, newParentID: GroupID) {
                      const group = this.source.g.find((g: FormatBGroup) => g.id === groupID);
                      group.g = newParentID;
                  }
              Severity: Major
              Found in source/io/VaultFormatB.ts and 1 other location - About 1 hr to fix
              source/io/VaultFormatB.ts on lines 327..330

              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 74.

              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 75..83

              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 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 94..102

              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

              Severity
              Category
              Status
              Source
              Language