buttercup-pw/buttercup-core

View on GitHub

Showing 216 of 216 total issues

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

    getEntries(): Array<Entry> {
        return this.vault._entries.filter((entry) => entry.getGroup() === this);
    }
Severity: Major
Found in source/core/Group.ts and 1 other location - About 1 hr to fix
source/core/Group.ts on lines 201..203

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

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 init(appEnvMapper: AppEnvMapper = (x) => x) {
    if (__hasInitialised) return;
    __hasInitialised = true;
    const appEnv = getSharedAppEnv();
    applyWebConfiguration(appEnv, appEnvMapper);
Severity: Major
Found in source/index.web.ts and 1 other location - About 1 hr to fix
source/index.node.ts on lines 11..16

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

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 init(appEnvMapper: AppEnvMapper = (x) => x) {
    if (__hasInitialised) return;
    __hasInitialised = true;
    const appEnv = getSharedAppEnv();
    applyNativeConfiguration(appEnv, appEnvMapper);
Severity: Major
Found in source/index.node.ts and 1 other location - About 1 hr to fix
source/index.web.ts on lines 12..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 58.

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

    getGroups(): Array<Group> {
        return this.vault._groups.filter((group) => group.getParentGroup() === this);
    }
Severity: Major
Found in source/core/Group.ts and 1 other location - About 1 hr to fix
source/core/Group.ts on lines 192..194

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

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

    const processGroup = (group) => {
        const entries = group.getEntries();
        groupCount += 1;
        entryCount += entries.length;
        entries.forEach((entry) => {
Severity: Minor
Found in source/insight/vault.ts - About 1 hr to fix

    Function addExtraFieldsNonDestructive has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    function addExtraFieldsNonDestructive(entry: Entry, fields: Array<EntryFacadeField>) {
        const exists = (propName: string, fieldType: EntryPropertyType) =>
            fields.find((item) => item.propertyType === fieldType && item.property === propName);
        const properties = entry.getProperty();
        const attributes = entry.getAttribute();
    Severity: Minor
    Found in source/facades/entry.ts - About 1 hr to fix

      Function convertFormatAEntry has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function convertFormatAEntry(entry: FormatAEntry): FormatBEntry {
          const changes = entry.history || [];
          const formatBEntry = {
              id: entry.id,
              a: flatKeyValueObjectToValuesObject(entry.attributes || {}),
      Severity: Minor
      Found in source/io/formatB/conversion.ts - About 1 hr to fix

        Function getEntryChanges has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            getEntryChanges(entrySource: FormatBEntry): Array<EntryChange> {
                return Object.keys(entrySource.p).reduce(
                    (changes, property) => [
                        ...changes,
                        ...entrySource.p[property].history.map((histItem: FormatBValueHistoryItem) => {
        Severity: Minor
        Found in source/io/VaultFormatB.ts - About 1 hr to fix

          Function moveTo has 28 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              moveTo(target: Group | Vault): this {
                  if (this.isTrash()) {
                      throw new Error("Trash group cannot be moved");
                  }
                  let targetVault, targetGroupID;
          Severity: Minor
          Found in source/core/Group.ts - About 1 hr to fix

            Function lock has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                async lock() {
                    if (this.status !== VaultSource.STATUS_UNLOCKED) {
                        throw new Layerr(
                            `Failed locking source: Source in invalid state (${this.status}): ${this.id}`
                        );
            Severity: Minor
            Found in source/core/VaultSource.ts - About 1 hr to fix

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

              (async function run() {
                  try {
                      await build();
                  } catch (err) {
                      console.error(err);
              Severity: Major
              Found in scripts/gen_vault_format_a.js and 1 other location - About 1 hr to fix
              scripts/gen_vault_format_b.js on lines 41..48

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

              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 run() {
                  try {
                      await build();
                  } catch (err) {
                      console.error(err);
              Severity: Major
              Found in scripts/gen_vault_format_b.js and 1 other location - About 1 hr to fix
              scripts/gen_vault_format_a.js on lines 35..42

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

              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) {
                      this.execute(
                          Inigo.create(Inigo.Command.DeleteGroup).addArgument(groupID).generateCommand()
                      );
                  }
              Severity: Major
              Found in source/io/VaultFormatA.ts and 1 other location - About 1 hr to fix
              source/io/VaultFormatA.ts on lines 229..233

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

              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

                  deleteEntry(entryID: EntryID) {
                      this.execute(
                          Inigo.create(Inigo.Command.DeleteEntry).addArgument(entryID).generateCommand()
                      );
                  }
              Severity: Major
              Found in source/io/VaultFormatA.ts and 1 other location - About 1 hr to fix
              source/io/VaultFormatA.ts on lines 253..257

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

              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 moveTo has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

                  moveTo(target: Group | Vault): this {
                      if (this.isTrash()) {
                          throw new Error("Trash group cannot be moved");
                      }
                      let targetVault, targetGroupID;
              Severity: Minor
              Found in source/core/Group.ts - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function different has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
              Open

              function different(object1: Object, object2: Object): boolean {
                  if (Array.isArray(object1) && Array.isArray(object2)) {
                      let differs = object1.some(function (item1) {
                          return !object2.some(function (item2) {
                              return different(item1, item2) === false;
              Severity: Minor
              Found in source/io/formatA/VaultComparator.ts - About 1 hr to fix

              Cognitive Complexity

              Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

              A method's cognitive complexity is based on a few simple rules:

              • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
              • Code is considered more complex for each "break in the linear flow of the code"
              • Code is considered more complex when "flow breaking structures are nested"

              Further reading

              Function readFile has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                      readFile: (remotePath, options, callback) => {
                          const encrypt = getSharedAppEnv().getProperty("crypto/v1/encryptText");
                          const decrypt = getSharedAppEnv().getProperty("crypto/v1/decryptText");
                          const cb = typeof options === "function" ? options : callback;
                          const url = joinURL(BASE_URL, "/get/file");
              Severity: Minor
              Found in source/web/localFileClient.ts - About 1 hr to fix

                Function flatten has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    flatten(force: boolean = false): boolean {
                        const history = this.format.history;
                        const preservedLines = [];
                        const tempFormat = new VaultFormatA();
                        let availableLines = history.length - Flattener.PRESERVE_LINES;
                Severity: Minor
                Found in source/io/formatA/Flattener.ts - About 1 hr to fix

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

                  export class VaultFacadeEntrySearch extends BaseSearch {
                      constructor(
                          facades: Array<VaultFacade>,
                          memory?: StorageInterface,
                          searcherFactory?: SearcherFactory
                  Severity: Major
                  Found in source/search/VaultFacadeEntrySearch.ts and 1 other location - About 1 hr to fix
                  source/search/VaultEntrySearch.ts on lines 40..48

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

                  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): FormatBEntry {
                          return this.source.e.find((entry) => entry.id === id) || null;
                      }
                  Severity: Major
                  Found in source/io/VaultFormatB.ts and 1 other location - About 1 hr to fix
                  source/io/VaultFormatB.ts on lines 230..232

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

                  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