cozy-labs/cozy-desktop

View on GitHub
core/merge.js

Summary

Maintainability
F
2 wks
Test Coverage

Function updateFileAsync has a Cognitive Complexity of 86 (exceeds 5 allowed). Consider refactoring.
Open

  async updateFileAsync(side /*: SideName */, doc /*: Metadata */) {
    log.debug({ path: doc.path }, 'updateFileAsync')

    const file /*: ?SavedMetadata */ = await this.pouch.bySyncedPath(doc.path)
    if (!file) {
Severity: Minor
Found in core/merge.js - About 1 day 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

File merge.js has 702 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @module core/merge
 * @flow
 */

Severity: Major
Found in core/merge.js - About 1 day to fix

    Function putFolderAsync has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
    Open

      async putFolderAsync(side /*: SideName */, doc /*: Metadata */) {
        log.debug({ path: doc.path }, 'putFolderAsync')
    
        const folder /*: ?SavedMetadata */ = await this.pouch.bySyncedPath(doc.path)
        if (!folder) {
    Severity: Minor
    Found in core/merge.js - About 7 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 moveFileAsync has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
    Open

      async moveFileAsync(
        side /*: SideName */,
        doc /*: Metadata */,
        was /*: SavedMetadata */
      ) /*: Promise<*> */ {
    Severity: Minor
    Found in core/merge.js - About 5 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 updateFileAsync has 128 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async updateFileAsync(side /*: SideName */, doc /*: Metadata */) {
        log.debug({ path: doc.path }, 'updateFileAsync')
    
        const file /*: ?SavedMetadata */ = await this.pouch.bySyncedPath(doc.path)
        if (!file) {
    Severity: Major
    Found in core/merge.js - About 5 hrs to fix

      Function moveFolderRecursivelyAsync has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring.
      Open

        async moveFolderRecursivelyAsync(
          side /*: SideName */,
          folder /*: Metadata  */,
          was /*: SavedMetadata */,
          newRemoteRevs /*: ?RemoteRevisionsByID */
      Severity: Minor
      Found in core/merge.js - About 4 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 moveFolderAsync has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        async moveFolderAsync(
          side /*: SideName */,
          doc /*: Metadata */,
          was /*: SavedMetadata */,
          newRemoteRevs /*: ?RemoteRevisionsByID */
      Severity: Minor
      Found in core/merge.js - About 4 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 deleteFolderAsync has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
      Open

        async deleteFolderAsync(side /*: SideName */, doc /*: SavedMetadata */) {
          log.debug({ path: doc.path }, 'deleteFolderAsync')
          const folder /*: ?SavedMetadata */ = await this.pouch.byIdMaybe(doc._id)
      
          if (!folder) {
      Severity: Minor
      Found in core/merge.js - 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

      Function putFolderAsync has 80 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async putFolderAsync(side /*: SideName */, doc /*: Metadata */) {
          log.debug({ path: doc.path }, 'putFolderAsync')
      
          const folder /*: ?SavedMetadata */ = await this.pouch.bySyncedPath(doc.path)
          if (!folder) {
      Severity: Major
      Found in core/merge.js - About 3 hrs to fix

        Function moveFileAsync has 74 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          async moveFileAsync(
            side /*: SideName */,
            doc /*: Metadata */,
            was /*: SavedMetadata */
          ) /*: Promise<*> */ {
        Severity: Major
        Found in core/merge.js - About 2 hrs to fix

          Function moveFolderAsync has 62 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async moveFolderAsync(
              side /*: SideName */,
              doc /*: Metadata */,
              was /*: SavedMetadata */,
              newRemoteRevs /*: ?RemoteRevisionsByID */
          Severity: Major
          Found in core/merge.js - About 2 hrs to fix

            Function moveFolderRecursivelyAsync has 61 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async moveFolderRecursivelyAsync(
                side /*: SideName */,
                folder /*: Metadata  */,
                was /*: SavedMetadata */,
                newRemoteRevs /*: ?RemoteRevisionsByID */
            Severity: Major
            Found in core/merge.js - About 2 hrs to fix

              Function putFolderRecursivelyAsync has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                async putFolderRecursivelyAsync(
                  side /*: SideName */,
                  folder /*: Metadata  */,
                  was /*: SavedMetadata */
                ) {
              Severity: Minor
              Found in core/merge.js - 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 trashFileAsync has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
              Open

                async trashFileAsync(
                  side /*: SideName */,
                  trashed /*: SavedMetadata */,
                  doc /*: Metadata */
                ) /*: Promise<void> */ {
              Severity: Minor
              Found in core/merge.js - 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 deleteFolderAsync has 60 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async deleteFolderAsync(side /*: SideName */, doc /*: SavedMetadata */) {
                  log.debug({ path: doc.path }, 'deleteFolderAsync')
                  const folder /*: ?SavedMetadata */ = await this.pouch.byIdMaybe(doc._id)
              
                  if (!folder) {
              Severity: Major
              Found in core/merge.js - About 2 hrs to fix

                Function doTrash has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async doTrash(
                    side /*: SideName */,
                    was /*: SavedMetadata */,
                    doc /*: Metadata */
                  ) /*: Promise<void> */ {
                Severity: Minor
                Found in core/merge.js - About 1 hr to fix

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

                    async doTrash(
                      side /*: SideName */,
                      was /*: SavedMetadata */,
                      doc /*: Metadata */
                    ) /*: Promise<void> */ {
                  Severity: Minor
                  Found in core/merge.js - 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 trashFileAsync has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async trashFileAsync(
                      side /*: SideName */,
                      trashed /*: SavedMetadata */,
                      doc /*: Metadata */
                    ) /*: Promise<void> */ {
                  Severity: Minor
                  Found in core/merge.js - About 1 hr to fix

                    Function putFolderRecursivelyAsync has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async putFolderRecursivelyAsync(
                        side /*: SideName */,
                        folder /*: Metadata  */,
                        was /*: SavedMetadata */
                      ) {
                    Severity: Minor
                    Found in core/merge.js - About 1 hr to fix

                      Avoid deeply nested control flow statements.
                      Open

                                  if (localWasVersioned) {
                                    // We make sure Sync will overwrite the local update with the remote
                                    // content.
                                    metadata.markSide('remote', file, file)
                                    file.local = doc.local
                      Severity: Major
                      Found in core/merge.js - About 45 mins to fix

                        Avoid deeply nested control flow statements.
                        Open

                                    if (localWasVersioned) {
                                      // We make sure Sync will overwrite the local update with the remote
                                      // content.
                                      metadata.markSide('remote', doc, file)
                                      return this.save(doc)
                        Severity: Major
                        Found in core/merge.js - About 45 mins to fix

                          Avoid deeply nested control flow statements.
                          Open

                                    if (!file.sides.remote) {
                                      // When the updated side is missing on the existing record, it means
                                      // we're simply linking two equivalent existing folders so we can
                                      // mark the record as up-to-date.
                                      metadata.markAsUpToDate(doc)
                          Severity: Major
                          Found in core/merge.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                      if (!folder.sides.remote) {
                                        // When the updated side is missing on the existing record, it means
                                        // we're simply linking two equivalent existing folders so we can
                                        // mark the record as up-to-date.
                                        metadata.markAsUpToDate(doc)
                            Severity: Major
                            Found in core/merge.js - About 45 mins to fix

                              Avoid deeply nested control flow statements.
                              Open

                                          if (outdated) {
                                            // In case a change was merged but not applied, we want to make sure
                                            // Sync will compare the current record version with the correct
                                            // "previous" version (i.e. the one before the actual change was
                                            // merged and not the one before we merged the new local metadata).
                              Severity: Major
                              Found in core/merge.js - About 45 mins to fix

                                Avoid deeply nested control flow statements.
                                Open

                                          if (localWasVersioned) {
                                            doc.overwrite = file.overwrite || file
                                            await this.pouch.eraseDocument(file)
                                            return this.save(doc)
                                          }
                                Severity: Major
                                Found in core/merge.js - About 45 mins to fix

                                  Avoid deeply nested control flow statements.
                                  Open

                                              if (dstChild.overwrite) delete dstChild.overwrite
                                  Severity: Major
                                  Found in core/merge.js - About 45 mins to fix

                                    Avoid deeply nested control flow statements.
                                    Open

                                              if (file.path === doc.path) {
                                                doc.overwrite = file.overwrite || file
                                                await this.pouch.eraseDocument(file)
                                              }
                                    Severity: Major
                                    Found in core/merge.js - About 45 mins to fix

                                      Avoid deeply nested control flow statements.
                                      Open

                                                  if (outdated) {
                                                    // In case a change was merged but not applied, we want to make sure
                                                    // Sync will compare the current record version with the correct
                                                    // "previous" version (i.e. the one before the actual change was
                                                    // merged and not the one before we merged the new local metadata).
                                      Severity: Major
                                      Found in core/merge.js - About 45 mins to fix

                                        Function addFileAsync has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                        Open

                                          async addFileAsync(side /*: SideName */, doc /*: Metadata */) {
                                            log.debug({ path: doc.path }, 'addFileAsync')
                                            const file /*: ?SavedMetadata */ = await this.pouch.bySyncedPath(doc.path)
                                        
                                            if (file) {
                                        Severity: Minor
                                        Found in core/merge.js - About 35 mins 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

                                        Avoid too many return statements within this function.
                                        Open

                                                  return this.save(doc)
                                        Severity: Major
                                        Found in core/merge.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                    return this.save(doc)
                                          Severity: Major
                                          Found in core/merge.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                      return
                                            Severity: Major
                                            Found in core/merge.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

                                                  return this.doTrash(side, was, doc)
                                              Severity: Major
                                              Found in core/merge.js - About 30 mins to fix

                                                Avoid too many return statements within this function.
                                                Open

                                                              return this.save(doc)
                                                Severity: Major
                                                Found in core/merge.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                          return this.moveFolderRecursivelyAsync(side, doc, was, newRemoteRevs)
                                                  Severity: Major
                                                  Found in core/merge.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                          return this.save(doc)
                                                    Severity: Major
                                                    Found in core/merge.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                              return this.save(dst)
                                                      Severity: Major
                                                      Found in core/merge.js - About 30 mins to fix

                                                        Avoid too many return statements within this function.
                                                        Open

                                                                  return this.save(doc)
                                                        Severity: Major
                                                        Found in core/merge.js - About 30 mins to fix

                                                          Avoid too many return statements within this function.
                                                          Open

                                                                  return this.save(doc)
                                                          Severity: Major
                                                          Found in core/merge.js - About 30 mins to fix

                                                            Avoid too many return statements within this function.
                                                            Open

                                                                        return this.save(file)
                                                            Severity: Major
                                                            Found in core/merge.js - About 30 mins to fix

                                                              Avoid too many return statements within this function.
                                                              Open

                                                                    return this.save(doc)
                                                              Severity: Major
                                                              Found in core/merge.js - About 30 mins to fix

                                                                Avoid too many return statements within this function.
                                                                Open

                                                                      return this.addFileAsync(side, doc)
                                                                Severity: Major
                                                                Found in core/merge.js - About 30 mins to fix

                                                                  Avoid too many return statements within this function.
                                                                  Open

                                                                      return this.save(doc)
                                                                  Severity: Major
                                                                  Found in core/merge.js - About 30 mins to fix

                                                                    Avoid too many return statements within this function.
                                                                    Open

                                                                                  return this.save(file)
                                                                    Severity: Major
                                                                    Found in core/merge.js - About 30 mins to fix

                                                                      Avoid too many return statements within this function.
                                                                      Open

                                                                                  return
                                                                      Severity: Major
                                                                      Found in core/merge.js - About 30 mins to fix

                                                                        Avoid too many return statements within this function.
                                                                        Open

                                                                                    return this.save(file)
                                                                        Severity: Major
                                                                        Found in core/merge.js - About 30 mins to fix

                                                                          Avoid too many return statements within this function.
                                                                          Open

                                                                                      return
                                                                          Severity: Major
                                                                          Found in core/merge.js - About 30 mins to fix

                                                                            Avoid too many return statements within this function.
                                                                            Open

                                                                                    return this.save(doc)
                                                                            Severity: Major
                                                                            Found in core/merge.js - About 30 mins to fix

                                                                              Avoid too many return statements within this function.
                                                                              Open

                                                                                          return this.save(doc)
                                                                              Severity: Major
                                                                              Found in core/merge.js - About 30 mins to fix

                                                                                Avoid too many return statements within this function.
                                                                                Open

                                                                                          return this.save(doc)
                                                                                Severity: Major
                                                                                Found in core/merge.js - About 30 mins to fix

                                                                                  Avoid too many return statements within this function.
                                                                                  Open

                                                                                            return
                                                                                  Severity: Major
                                                                                  Found in core/merge.js - About 30 mins to fix

                                                                                    Function deleteFileAsync has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                                                                                    Open

                                                                                      async deleteFileAsync(side /*: SideName */, doc /*: SavedMetadata */) {
                                                                                        log.debug({ path: doc.path }, 'deleteFileAsync')
                                                                                        const file /*: ?SavedMetadata */ = await this.pouch.bySyncedPath(doc.path)
                                                                                    
                                                                                        if (!file) {
                                                                                    Severity: Minor
                                                                                    Found in core/merge.js - About 25 mins 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 (metadata.equivalent(doc, file)) {
                                                                                            log.info({ path: doc.path }, 'up to date')
                                                                                            if (side === 'local' && !metadata.sameLocal(file.local, doc.local)) {
                                                                                              if (!file.sides.local) {
                                                                                                // When the updated side is missing on the existing record, it means
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 1 other location - About 1 day to fix
                                                                                    core/merge.js on lines 397..443

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

                                                                                    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

                                                                                          if (metadata.equivalent(folder, doc)) {
                                                                                            log.info({ path: doc.path }, 'up to date')
                                                                                            if (side === 'local' && !metadata.sameLocal(folder.local, doc.local)) {
                                                                                              if (!folder.sides.local) {
                                                                                                // When the updated side is missing on the existing record, it means
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 1 other location - About 1 day to fix
                                                                                    core/merge.js on lines 190..236

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

                                                                                    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

                                                                                          if (folder.trashed) {
                                                                                            // If the existing record was marked for deletion, we only keep the
                                                                                            // PouchDB attributes that will allow us to overwrite it.
                                                                                            doc._id = folder._id
                                                                                            doc._rev = folder._rev
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 1 other location - About 1 day to fix
                                                                                    core/merge.js on lines 153..172

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

                                                                                    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

                                                                                          if (file.trashed) {
                                                                                            // If the existing record was marked for deletion, we only keep the
                                                                                            // PouchDB attributes that will allow us to overwrite it.
                                                                                            doc._id = file._id
                                                                                            doc._rev = file._rev
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 1 other location - About 1 day to fix
                                                                                    core/merge.js on lines 363..385

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

                                                                                    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

                                                                                        if (!was) {
                                                                                          log.debug(
                                                                                            { path: oldpath },
                                                                                            'moved file missing from PouchDB. Adding at destination'
                                                                                          )
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 1 other location - About 2 hrs to fix
                                                                                    core/merge.js on lines 577..588

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

                                                                                    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

                                                                                        if (!was) {
                                                                                          log.debug(
                                                                                            { path: oldpath },
                                                                                            'moved folder missing from PouchDB. Adding at destination'
                                                                                          )
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 1 other location - About 2 hrs to fix
                                                                                    core/merge.js on lines 460..468

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

                                                                                    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

                                                                                              if (file.remote) {
                                                                                                // In this case we can dissociate the local record from its remote
                                                                                                // counterpart that was just renamed and will be fetched later.
                                                                                                metadata.dissociateRemote(file)
                                                                                                // We make sure Sync will detect and propagate the local update
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 1 other location - About 1 hr to fix
                                                                                    core/merge.js on lines 262..273

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

                                                                                    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

                                                                                              if (file.local) {
                                                                                                // In this case we can dissociate the remote record from its local
                                                                                                // counterpart that was just renamed and will be merged later.
                                                                                                metadata.dissociateLocal(file)
                                                                                                // We make sure Sync will detect and propagate the remote update
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 1 other location - About 1 hr to fix
                                                                                    core/merge.js on lines 300..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 61.

                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                    Refactorings

                                                                                    Further Reading

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

                                                                                              if (movedChild.docType === metadata.FILE) {
                                                                                                await this.updateFileAsync(side, movedChild)
                                                                                              } else {
                                                                                                await this.putFolderAsync(side, movedChild)
                                                                                              }
                                                                                    Severity: Minor
                                                                                    Found in core/merge.js and 1 other location - About 50 mins to fix
                                                                                    core/merge.js on lines 703..707

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

                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                    Refactorings

                                                                                    Further Reading

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

                                                                                              if (movedChild.docType === metadata.FILE) {
                                                                                                await this.updateFileAsync(side, movedChild)
                                                                                              } else {
                                                                                                await this.putFolderAsync(side, movedChild)
                                                                                              }
                                                                                    Severity: Minor
                                                                                    Found in core/merge.js and 1 other location - About 50 mins to fix
                                                                                    core/merge.js on lines 709..713

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

                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                    Refactorings

                                                                                    Further Reading

                                                                                    Identical blocks of code found in 4 locations. Consider refactoring.
                                                                                    Open

                                                                                            if (idConflict) {
                                                                                              log.warn({ idConflict }, IdConflict.description(idConflict))
                                                                                              return this.resolveConflictAsync(side, doc)
                                                                                            }
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 3 other locations - About 30 mins to fix
                                                                                    core/merge.js on lines 107..110
                                                                                    core/merge.js on lines 340..343
                                                                                    core/merge.js on lines 514..517

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

                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                    Refactorings

                                                                                    Further Reading

                                                                                    Identical blocks of code found in 4 locations. Consider refactoring.
                                                                                    Open

                                                                                            if (idConflict) {
                                                                                              log.warn({ idConflict }, IdConflict.description(idConflict))
                                                                                              return this.resolveConflictAsync(side, doc)
                                                                                            }
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 3 other locations - About 30 mins to fix
                                                                                    core/merge.js on lines 107..110
                                                                                    core/merge.js on lines 340..343
                                                                                    core/merge.js on lines 637..640

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

                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                    Refactorings

                                                                                    Further Reading

                                                                                    Identical blocks of code found in 4 locations. Consider refactoring.
                                                                                    Open

                                                                                          if (idConflict) {
                                                                                            log.warn({ idConflict }, IdConflict.description(idConflict))
                                                                                            return this.resolveConflictAsync(side, doc)
                                                                                          }
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 3 other locations - About 30 mins to fix
                                                                                    core/merge.js on lines 107..110
                                                                                    core/merge.js on lines 514..517
                                                                                    core/merge.js on lines 637..640

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

                                                                                    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                                                                                    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                                                                                    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                                                                                    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                                                                                    Refactorings

                                                                                    Further Reading

                                                                                    Identical blocks of code found in 4 locations. Consider refactoring.
                                                                                    Open

                                                                                          if (idConflict) {
                                                                                            log.warn({ idConflict }, IdConflict.description(idConflict))
                                                                                            return this.resolveConflictAsync(side, doc)
                                                                                          }
                                                                                    Severity: Major
                                                                                    Found in core/merge.js and 3 other locations - About 30 mins to fix
                                                                                    core/merge.js on lines 340..343
                                                                                    core/merge.js on lines 514..517
                                                                                    core/merge.js on lines 637..640

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

                                                                                    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

                                                                                    There are no issues that match your filters.

                                                                                    Category
                                                                                    Status