buttercup-pw/buttercup-core

View on GitHub

Showing 67 of 185 total issues

Function findGroupContainingEntryID has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

export function findGroupContainingEntryID(groups: Array<FormatAGroup>, id: EntryID) {
    for (let i = 0, groupsLen = groups.length; i < groupsLen; i += 1) {
        const group = groups[i];
        if (group.entries) {
            for (var j = 0, entriesLen = group.entries.length; j < entriesLen; j += 1) {
Severity: Minor
Found in source/io/formatA/tools.ts - About 2 hrs to fix

Cognitive Complexity

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

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

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

Further reading

Function searchByURL has 49 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    searchByURL(url: string): Array<SearchResult> {
        const incomingDomain = extractDomain(url);
        if (!incomingDomain) {
            this._results = [];
            return this._results;
Severity: Minor
Found in source/search/BaseSearch.ts - About 1 hr to fix

    Function calculateCommonRecentCommand has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

    function calculateCommonRecentCommand(historyA: History, historyB: History): CommonRecentCommandResult | null {
        const getCommandType = fullCommand => (fullCommand && fullCommand.length >= 3 ? fullCommand.substr(0, 3) : "");
        const getPaddingID = command => command.split(" ")[1];
        for (let a = historyA.length - 1; a >= 9; a -= 1) {
            if (getCommandType(historyA[a]) === "pad") {
    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 changeMasterPassword has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        async changeMasterPassword(oldPassword: string, newPassword: string, meta: { [key: string]: any } = {}) {
            if (oldPassword === newPassword) {
                throw new Error("New password cannot be the same as the previous one");
            } else if (!newPassword) {
                throw new Error("New password must be specified");
    Severity: Minor
    Found in source/core/VaultSource.ts - About 1 hr to fix

      Function setAttachment has 36 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          async setAttachment(
              entry: Entry,
              attachmentID: string,
              attachmentData: Buffer | ArrayBuffer,
              name: string,
      Severity: Minor
      Found in source/attachments/AttachmentManager.ts - About 1 hr to fix

        Function mergeRawVaults has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function mergeRawVaults(base: FormatBVault, incoming: FormatBVault): FormatBVault {
            const newVault: FormatBVault = {
                id: base.id,
                a: mergeProperties(base.a, incoming.a, EntryPropertyType.Attribute),
                g: [],
        Severity: Minor
        Found in source/io/formatB/merge.ts - About 1 hr to fix

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

          export function createEntryFacade(entry?: Entry, options: CreateEntryFacadeOptions = {}): EntryFacade {
              if (entry && entry instanceof Entry !== true) {
                  throw new Error("Failed creating entry facade: Provided item is not an Entry");
              }
              const { type } = options;
          Severity: Minor
          Found in source/facades/entry.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 consumeVaultFacade has a Cognitive Complexity of 11 (exceeds 5 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: 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 } = {}) {
                      if (oldPassword === newPassword) {
                          throw new Error("New password cannot be the same as the previous one");
                      } else if (!newPassword) {
                          throw new Error("New password must be specified");
              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

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

                  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 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 _executeCommand has 28 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 = /^\$([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/.exec(currentCommand);
                      Severity: Minor
                      Found in source/io/VaultFormatA.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 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 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 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
                              Severity
                              Category
                              Status
                              Source
                              Language