buttercup-pw/buttercup-core

View on GitHub

Showing 185 of 185 total issues

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

export function executeSetEntryAttribute(
    archive: FormatAVault,
    opts: any,
    entryID: EntryID,
    attribute: string,
Severity: Major
Found in source/io/formatA/commands.ts and 1 other location - About 1 day to fix
source/io/formatA/commands.ts on lines 218..235

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

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 executeSetEntryProperty(
    archive: FormatAVault,
    opts: any,
    entryID: EntryID,
    property: string,
Severity: Major
Found in source/io/formatA/commands.ts and 1 other location - About 1 day to fix
source/io/formatA/commands.ts on lines 199..216

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

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

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

                setGroupAttribute(groupID: GroupID, attribute: string, value: string) {
                    const group = this.source.g.find((g: FormatBGroup) => g.id === groupID);
                    if (!group.a[attribute]) {
                        group.a[attribute] = newRawValue(value);
                    } else {
            Severity: Major
            Found in source/io/VaultFormatB.ts and 2 other locations - About 6 hrs to fix
            source/io/VaultFormatB.ts on lines 339..349
            source/io/VaultFormatB.ts on lines 351..361

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

            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) {
                    const entry = this.source.e.find((e: FormatBEntry) => e.id === entryID);
                    if (!entry.p[property]) {
                        entry.p[property] = newRawValue(value);
                    } else {
            Severity: Major
            Found in source/io/VaultFormatB.ts and 2 other locations - About 6 hrs to fix
            source/io/VaultFormatB.ts on lines 339..349
            source/io/VaultFormatB.ts on lines 363..373

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

            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) {
                    const entry = this.source.e.find((e: FormatBEntry) => e.id === entryID);
                    if (!entry.a[attribute]) {
                        entry.a[attribute] = newRawValue(value);
                    } else {
            Severity: Major
            Found in source/io/VaultFormatB.ts and 2 other locations - About 6 hrs to fix
            source/io/VaultFormatB.ts on lines 351..361
            source/io/VaultFormatB.ts on lines 363..373

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

            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

                        encrypt(remotePath, token)
                            .then(payload =>
                                fetch(url, {
                                    method: "POST",
                                    headers: {
            Severity: Major
            Found in source/web/localFileClient.ts and 1 other location - About 5 hrs to fix
            source/web/localFileClient.ts on lines 41..62

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

            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

                        encrypt(remotePath, token)
                            .then(payload =>
                                fetch(url, {
                                    method: "POST",
                                    headers: {
            Severity: Major
            Found in source/web/localFileClient.ts and 1 other location - About 5 hrs to fix
            source/web/localFileClient.ts on lines 12..31

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

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

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

                  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);
                      return Promise.resolve()
              Severity: Major
              Found in source/io/VaultFormatA.ts and 1 other location - About 4 hrs to fix
              source/io/VaultFormatB.ts on lines 40..49

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

              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

                  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);
                      return Promise.resolve()
              Severity: Major
              Found in source/io/VaultFormatB.ts and 1 other location - About 4 hrs to fix
              source/io/VaultFormatA.ts on lines 93..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 127.

              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

              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

                      Severity
                      Category
                      Status
                      Source
                      Language