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 applyWebConfiguration(appEnv: AppEnv) {
    appEnv.setProperties(getCryptoResources());
    appEnv.setProperties(getV1CompressionResources());
    appEnv.setProperties(getV2CompressionResources());
    appEnv.setProperties(getEnvironmentResources());
Severity: Major
Found in source/env/web/index.ts and 1 other location - About 4 hrs to fix
source/env/native/index.ts on lines 10..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 116.

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

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

          findGroupContainingEntryID(id: EntryID): FormatBGroup {
              const matchingEntry = this.getAllEntries().find(entry => entry.id === id);
              if (matchingEntry) {
                  return this.getAllGroups().find(group => group.id === matchingEntry.g) || null;
              }
      Severity: Major
      Found in source/io/VaultFormatB.ts and 1 other location - About 3 hrs to fix
      source/io/VaultFormatA.ts on lines 305..311

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

      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

          findGroupContainingEntryID(id: EntryID): FormatAGroup {
              const matchingEntry = this.getAllEntries().find(entry => entry.id === id);
              if (matchingEntry) {
                  return this.getAllGroups().find(group => group.id === matchingEntry.parentID) || null;
              }
      Severity: Major
      Found in source/io/VaultFormatA.ts and 1 other location - About 3 hrs to fix
      source/io/VaultFormatB.ts on lines 216..222

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

      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

              this.format.getAllGroups().forEach(rawGroup => {
                  const id = this.format.getItemID(rawGroup);
                  if (!this._groups.find(g => g.id === id)) {
                      this._groups.push(new Group(this, rawGroup));
                  }
      Severity: Major
      Found in source/core/Vault.ts and 1 other location - About 3 hrs to fix
      source/core/Vault.ts on lines 264..269

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

      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

              this.format.getAllEntries().forEach(rawEntry => {
                  const id = this.format.getItemID(rawEntry);
                  if (!this._entries.find(e => e.id === id)) {
                      this._entries.push(new Entry(this, rawEntry));
                  }
      Severity: Major
      Found in source/core/Vault.ts and 1 other location - About 3 hrs to fix
      source/core/Vault.ts on lines 258..263

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

      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 unlock has 75 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async unlock(vaultCredentials: Credentials, config: VaultSourceUnlockOptions = {}) {
              if (!Credentials.isCredentials(vaultCredentials)) {
                  throw new Layerr(`Failed unlocking source: Invalid credentials passed to source: ${this.id}`);
              }
              const { initialiseRemote = false, loadOfflineCopy = false, storeOfflineCopy = true } = config;
      Severity: Major
      Found in source/core/VaultSource.ts - About 3 hrs to fix

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

                Object.keys(properties).forEach(propKey => {
                    const correspondingField = facade.fields.find(
                        ({ propertyType, property }) => propertyType === "property" && property === propKey
                    );
                    if (typeof correspondingField === "undefined") {
        Severity: Major
        Found in source/facades/entry.ts and 1 other location - About 2 hrs to fix
        source/facades/entry.ts on lines 100..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 94.

        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

                Object.keys(attributes).forEach(attrKey => {
                    const correspondingField = facade.fields.find(
                        ({ propertyType, property }) => propertyType === "attribute" && property === attrKey
                    );
                    if (typeof correspondingField === "undefined") {
        Severity: Major
        Found in source/facades/entry.ts and 1 other location - About 2 hrs to fix
        source/facades/entry.ts on lines 91..98

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

        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

        async function decompress(text: string): Promise<string> {
            const compressedData = Buffer.from(text, "base64");
            const decompressedData: Buffer = await new Promise((resolve, reject) => {
                zlib.gunzip(compressedData, (err, res) => {
                    if (err) return reject(err);
        Severity: Major
        Found in source/env/native/compression.v2.ts and 1 other location - About 2 hrs to fix
        source/env/native/compression.v2.ts on lines 8..17

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

        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

        async function compress(text: string): Promise<string> {
            const buff = Buffer.from(text, "utf8");
            const compressed: Buffer = await new Promise((resolve, reject) => {
                zlib.gzip(buff, (err, res) => {
                    if (err) return reject(err);
        Severity: Major
        Found in source/env/native/compression.v2.ts and 1 other location - About 2 hrs to fix
        source/env/native/compression.v2.ts on lines 24..33

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

        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

            deleteEntryProperty(entryID: EntryID, property: string) {
                const entry = this.source.e.find(e => e.id === entryID);
                if (!entry.p[property]) return;
                entry.p[property].deleted = getTimestamp();
            }
        Severity: Major
        Found in source/io/VaultFormatB.ts and 1 other location - About 2 hrs to fix
        source/io/VaultFormatB.ts on lines 174..178

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

        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

            deleteGroupAttribute(groupID: GroupID, attribute: string) {
                const group = this.source.g.find(g => g.id === groupID);
                if (!group.a[attribute]) return;
                group.a[attribute].deleted = getTimestamp();
            }
        Severity: Major
        Found in source/io/VaultFormatB.ts and 1 other location - About 2 hrs to fix
        source/io/VaultFormatB.ts on lines 161..165

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

        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 generateVaultInsights has 68 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function generateVaultInsights(vault: Vault): VaultInsights {
            let groupCount = 0,
                entryCount = 0,
                trashEntryCount = 0,
                trashGroupCount = 0,
        Severity: Major
        Found in source/insight/vault.ts - About 2 hrs to fix

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

              getAllEntries(parentID: GroupID = null): Array<FormatBEntry> {
                  const source = this.source as FormatBVault;
                  return parentID === null ? source.e : source.e.filter(entry => entry.g === parentID);
              }
          Severity: Major
          Found in source/io/VaultFormatB.ts and 1 other location - About 2 hrs to fix
          source/io/VaultFormatB.ts on lines 240..243

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

          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

              getAllGroups(parentID: GroupID = null): Array<FormatBGroup> {
                  const source = this.source as FormatBVault;
                  return parentID === null ? source.g : source.g.filter(group => group.g === parentID);
              }
          Severity: Major
          Found in source/io/VaultFormatB.ts and 1 other location - About 2 hrs to fix
          source/io/VaultFormatB.ts on lines 235..238

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

          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

                  createFieldDescriptor(entry, "Valid From", EntryPropertyType.Property, "valid_from", {
                      formatting: {
                          format: [
                              { char: "[01]", repeat: 1 },
                              { char: DIGIT, repeat: 1 },
          Severity: Major
          Found in source/facades/entryFields.ts and 1 other location - About 2 hrs to fix
          source/facades/entryFields.ts on lines 60..71

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

          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

                  createFieldDescriptor(entry, "Expiry", EntryPropertyType.Property, "expiry", {
                      formatting: {
                          format: [
                              { char: "[01]", repeat: 1 },
                              { char: DIGIT, repeat: 1 },
          Severity: Major
          Found in source/facades/entryFields.ts and 1 other location - About 2 hrs to fix
          source/facades/entryFields.ts on lines 48..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 86.

          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