buttercup-pw/buttercup-core

View on GitHub

Showing 216 of 216 total issues

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

    Object.keys(existingAttributes)
        .filter((attr) => !attributes.hasOwnProperty(attr))
        .forEach((attr) => {
            // Remove missing
            group.deleteAttribute(attr);
Severity: Major
Found in source/facades/vault.ts and 1 other location - About 1 hr to fix
source/facades/vault.ts on lines 232..237

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

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(currentAttributes)
        .filter((attr) => !attributes.hasOwnProperty(attr))
        .forEach((attr) => {
            // Remove missing
            vault.deleteAttribute(attr);
Severity: Major
Found in source/facades/vault.ts and 1 other location - About 1 hr to fix
source/facades/vault.ts on lines 52..57

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

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

    async save(config: VaultSourceSaveOptions = {}) {
        const { storeOfflineCopy = true } = config;
        await this._enqueueStateChange(async () => {
            if (await this.localDiffersFromRemote()) {
                await this.mergeFromRemote();
Severity: Minor
Found in source/core/VaultSource.ts - About 1 hr to fix

    Function writeFile has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

            writeFile: (remotePath, data, options, callback) => {
                const encrypt = getSharedAppEnv().getProperty("crypto/v1/encryptText");
                const cb = typeof options === "function" ? options : callback;
                if (typeof data !== "string") {
                    throw new Error("Failed writing file: Expected data to be of type string");
    Severity: Minor
    Found in source/web/localFileClient.ts - About 1 hr to fix

      Function localDiffersFromRemote has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          localDiffersFromRemote(): Promise<boolean> {
              if (this.status !== VaultSource.STATUS_UNLOCKED) {
                  return Promise.reject(
                      new Layerr(
                          `Failed diffing source: Source not unlocked (${this.status}): ${this.id}`
      Severity: Minor
      Found in source/core/VaultSource.ts - About 1 hr to fix

        Function consumeVaultFacade has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        export function consumeVaultFacade(
            vault: Vault,
            facade: VaultFacade,
            options: ConsumeVaultFacadeOptions = {}
        ) {
        Severity: Minor
        Found in source/facades/vault.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 changeMasterPassword has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            async changeMasterPassword(
                oldPassword: string,
                newPassword: string,
                meta: { [key: string]: any } = {}
            ) {
        Severity: Minor
        Found in source/core/VaultSource.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

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

                        } else if (preference === EntryURLType.Login) {
                            const login = /login/i;
                            const aVal = login.test(a) ? 1 : 0;
                            const bVal = login.test(b) ? 1 : 0;
                            return bVal - aVal;
        Severity: Major
        Found in source/tools/entry.ts and 1 other location - About 1 hr to fix
        source/tools/entry.ts on lines 50..60

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

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

            findGroupContainingGroupID(id: GroupID): FormatAGroup {
                const searchGroups = (groups: Array<FormatAGroup>): FormatAGroup => {
                    for (const group of groups) {
                        if (group.id === id) return null;
                        const children = group.groups || [];
        Severity: Minor
        Found in source/io/VaultFormatA.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 findEntriesByTag has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

            findEntriesByTag(tag: string, exact: boolean = true): Array<Entry> {
                const tagLower = tag.toLowerCase();
                if (!exact) {
                    const entryIDs = new Set<string>();
                    for (const [currentTag, currentIDs] of this._tagMap.entries()) {
        Severity: Minor
        Found in source/core/Vault.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

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

                        if (preference === EntryURLType.General) {
                            const general = /^ur[li]$/i;
                            const aVal = general.test(a) ? 1 : 0;
                            const bVal = general.test(b) ? 1 : 0;
                            return bVal - aVal;
        Severity: Major
        Found in source/tools/entry.ts and 1 other location - About 1 hr to fix
        source/tools/entry.ts on lines 55..60

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

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

        export function smartStripRemovedAssets(history: History): History {
            const deletedEntries: Set<string> = new Set([]);
            const deletedGroups: Set<string> = new Set([]);
            return history.filter((line) => {
                const [command, ...args] = line.split(/\s/g);
        Severity: Minor
        Found in source/io/formatA/merge.ts - About 1 hr to fix

          Function getEntryURLs has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function getEntryURLs(
              properties: { [key: string]: string },
              preference: EntryURLType = EntryURLType.Any
          ): Array<string> {
              const urlRef = Object.keys(properties)
          Severity: Minor
          Found in source/tools/entry.ts - About 1 hr to fix

            Function _executeCommand has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                _executeCommand(command: string) {
                    let currentCommand = command,
                        shareID = null;
                    if (SHARE_COMMAND_EXP.test(currentCommand)) {
                        const shareMatch =
            Severity: Minor
            Found in source/io/VaultFormatA.ts - About 1 hr to fix

              Function different has 30 lines of code (exceeds 25 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

                Function interruptAutoUpdate has 30 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    interruptAutoUpdate(cb: InterruptedAutoUpdateFunction) {
                        return this.enqueueStateChange(NOOP).then(() =>
                            this._queue.channel("autoUpdateInterrupt").enqueue(() => {
                                const enabled = this._autoUpdateEnabled;
                                const delay = this._autoUpdateDelay;
                Severity: Minor
                Found in source/core/VaultManager.ts - About 1 hr to fix

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

                      findGroupByID(id: GroupID): null | Group {
                          return this._groups.find((group) => group.id === id) || null;
                      }
                  Severity: Major
                  Found in source/core/Vault.ts and 1 other location - About 1 hr to fix
                  source/core/Vault.ts on lines 161..163

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

                  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): null | Entry {
                          return this._entries.find((entry) => entry.id === id) || null;
                      }
                  Severity: Major
                  Found in source/core/Vault.ts and 1 other location - About 1 hr to fix
                  source/core/Vault.ts on lines 207..209

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

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

                  export function consumeEntryFacade(entry: Entry, facade: EntryFacade) {
                      const facadeType = getEntryFacadeType(entry);
                      if (facade && facade.type) {
                          const properties = entry.getProperty();
                          const attributes = entry.getAttribute();
                  Severity: Minor
                  Found in source/facades/entry.ts - About 1 hr to fix

                    Function extractEntries has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    async function extractEntries(
                        facade: VaultFacade,
                        memory: StorageInterface
                    ): Promise<Array<ProcessedSearchEntry>> {
                        // Get scores
                    Severity: Minor
                    Found in source/search/VaultFacadeEntrySearch.ts - About 1 hr to fix
                      Severity
                      Category
                      Status
                      Source
                      Language