cozy-labs/cozy-desktop

View on GitHub
core/sync/index.js

Summary

Maintainability
F
1 wk
Test Coverage

File index.js has 883 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @module core/sync
 * @flow
 */

Severity: Major
Found in core/sync/index.js - About 2 days to fix

    Function syncBatch has a Cognitive Complexity of 60 (exceeds 5 allowed). Consider refactoring.
    Open

      async syncBatch() /*: Promise<void> */ {
        let change /*: Change */ = {}
        while (!this.lifecycle.willStop()) {
          await this.lifecycle.ready()
    
    
    Severity: Minor
    Found in core/sync/index.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

    Function applyDoc has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
    Open

      async applyDoc(
        doc /*: SavedMetadata */,
        side /*: Writer */
      ) /*: Promise<*> */ {
        if (doc.incompatibilities && side.name === 'local') {
    Severity: Minor
    Found in core/sync/index.js - About 6 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 syncBatch has 136 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async syncBatch() /*: Promise<void> */ {
        let change /*: Change */ = {}
        while (!this.lifecycle.willStop()) {
          await this.lifecycle.ready()
    
    
    Severity: Major
    Found in core/sync/index.js - About 5 hrs to fix

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

      const compareChanges = (
        { operation: opA, doc: docA } /*: Change */,
        { operation: opB, doc: docB } /*: Change */
      ) => {
        // Operations on different sides don't have dependencies for now. This will
      Severity: Minor
      Found in core/sync/index.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 applyDoc has 88 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async applyDoc(
          doc /*: SavedMetadata */,
          side /*: Writer */
        ) /*: Promise<*> */ {
          if (doc.incompatibilities && side.name === 'local') {
      Severity: Major
      Found in core/sync/index.js - About 3 hrs to fix

        Function blockSyncFor has 87 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          blockSyncFor(
            cause
            /*: {| err: RemoteError |} | {| err: SyncError, change: Change |} */
          ) {
            log.debug(cause, 'blocking sync for error')
        Severity: Major
        Found in core/sync/index.js - About 3 hrs to fix

          Sync has 27 functions (exceeds 20 allowed). Consider refactoring.
          Open

          class Sync {
            /*::
            changes: any
            events: EventEmitter
            ignore: Ignore
          Severity: Minor
          Found in core/sync/index.js - About 3 hrs to fix

            Function detectOperation has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
            Open

            const detectOperation = async (
              change /*: PouchDBFeedData */,
              sync /*: Sync */
            ) /*: Promise<SyncOperation> */ => {
              const outdatedSide = sync.selectSide(change)
            Severity: Minor
            Found in core/sync/index.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 getNextChanges has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async getNextChanges(seq /*: number */) /*: Promise<Change[]> */ {
                const stopMeasure = measureTime('Sync#getNextChanges')
                const opts = {
                  ...this.baseChangeOptions(seq),
                  include_docs: true,
            Severity: Major
            Found in core/sync/index.js - About 2 hrs to fix

              Function p has 47 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  const p = new Promise((resolve, reject) => {
                    let feedObserver
                    const done = (data = [], err) => {
                      this.lifecycle.off('will-stop', done)
              
              
              Severity: Minor
              Found in core/sync/index.js - About 1 hr to fix

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

                  async waitForNewChangeOn(seq /*: number */, expectedPath /*: string */) {
                    log.debug({ path: expectedPath }, 'Waiting for new change to be merged')
                
                    return new Promise((resolve, reject) => {
                      const opts = {
                Severity: Minor
                Found in core/sync/index.js - About 1 hr to fix

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

                    async trashWithParentOrByItself(
                      doc /*: SavedMetadata */,
                      side /*: Writer */
                    ) /*: Promise<void> */ {
                      const parentPath = dirname(doc.path)
                  Severity: Minor
                  Found in core/sync/index.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 detectOperation has 43 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const detectOperation = async (
                    change /*: PouchDBFeedData */,
                    sync /*: Sync */
                  ) /*: Promise<SyncOperation> */ => {
                    const outdatedSide = sync.selectSide(change)
                  Severity: Minor
                  Found in core/sync/index.js - About 1 hr to fix

                    Function apply has 41 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                      async apply(change /*: Change */) /*: Promise<void> */ {
                        let stopMeasure = () => {}
                        try {
                          this.events.emit('sync-current', change.seq)
                    
                    
                    Severity: Minor
                    Found in core/sync/index.js - About 1 hr to fix

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

                        async trashWithParentOrByItself(
                          doc /*: SavedMetadata */,
                          side /*: Writer */
                        ) /*: Promise<void> */ {
                          const parentPath = dirname(doc.path)
                      Severity: Minor
                      Found in core/sync/index.js - About 1 hr to fix

                        Function blockSyncFor has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                        Open

                          blockSyncFor(
                            cause
                            /*: {| err: RemoteError |} | {| err: SyncError, change: Change |} */
                          ) {
                            log.debug(cause, 'blocking sync for error')
                        Severity: Minor
                        Found in core/sync/index.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 start has 35 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async start() /*: Promise<void> */ {
                            if (this.lifecycle.willStop()) {
                              await this.lifecycle.stopped()
                            } else {
                              return
                        Severity: Minor
                        Found in core/sync/index.js - About 1 hr to fix

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

                            async apply(change /*: Change */) /*: Promise<void> */ {
                              let stopMeasure = () => {}
                              try {
                                this.events.emit('sync-current', change.seq)
                          
                          
                          Severity: Minor
                          Found in core/sync/index.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

                          Avoid deeply nested control flow statements.
                          Open

                                  if (
                                    (side.name === 'local' && metadata.equivalentLocal(outdated, doc)) ||
                                    (side.name === 'remote' && metadata.equivalentRemote(outdated, doc))
                                  ) {
                                    log.debug({ path: doc.path }, 'Ignoring timestamp-only change')
                          Severity: Major
                          Found in core/sync/index.js - About 45 mins to fix

                            Avoid deeply nested control flow statements.
                            Open

                                            if (change.doc.docType === metadata.FILE) {
                                              this.events.emit('delete-file', change.doc)
                                            }
                            Severity: Major
                            Found in core/sync/index.js - About 45 mins to fix

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

                                async getNextChanges(seq /*: number */) /*: Promise<Change[]> */ {
                                  const stopMeasure = measureTime('Sync#getNextChanges')
                                  const opts = {
                                    ...this.baseChangeOptions(seq),
                                    include_docs: true,
                              Severity: Minor
                              Found in core/sync/index.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 { type: 'MOVE', side: outdatedSide.name } // XXX: can be move with update but we don't care for now
                              Severity: Major
                              Found in core/sync/index.js - About 30 mins to fix

                                Avoid too many return statements within this function.
                                Open

                                          return { type: 'NULL' }
                                Severity: Major
                                Found in core/sync/index.js - About 30 mins to fix

                                  Avoid too many return statements within this function.
                                  Open

                                            return { type: 'EDIT', side: outdatedSide.name }
                                  Severity: Major
                                  Found in core/sync/index.js - About 30 mins to fix

                                    Avoid too many return statements within this function.
                                    Open

                                            return { type: 'ADD', side: outdatedSide.name }
                                    Severity: Major
                                    Found in core/sync/index.js - About 30 mins to fix

                                      Avoid too many return statements within this function.
                                      Open

                                            if (docA.path.startsWith(docB.path + sep)) return 1
                                      Severity: Major
                                      Found in core/sync/index.js - About 30 mins to fix

                                        Avoid too many return statements within this function.
                                        Open

                                              if (docA.path.startsWith(docB.path + sep)) return 1
                                        Severity: Major
                                        Found in core/sync/index.js - About 30 mins to fix

                                          Avoid too many return statements within this function.
                                          Open

                                                if (docB.path.startsWith(docA.path + sep)) return -1
                                          Severity: Major
                                          Found in core/sync/index.js - About 30 mins to fix

                                            Avoid too many return statements within this function.
                                            Open

                                                return { type: 'DEL', side: outdatedSide.name }
                                            Severity: Major
                                            Found in core/sync/index.js - About 30 mins to fix

                                              Avoid too many return statements within this function.
                                              Open

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

                                                Avoid too many return statements within this function.
                                                Open

                                                      return { type: 'EDIT', side: outdatedSide.name }
                                                Severity: Major
                                                Found in core/sync/index.js - About 30 mins to fix

                                                  Avoid too many return statements within this function.
                                                  Open

                                                      return { type: 'ADD', side: outdatedSide.name }
                                                  Severity: Major
                                                  Found in core/sync/index.js - About 30 mins to fix

                                                    Avoid too many return statements within this function.
                                                    Open

                                                          if (docB.path.startsWith(docA.path + sep)) return -1
                                                    Severity: Major
                                                    Found in core/sync/index.js - About 30 mins to fix

                                                      Avoid too many return statements within this function.
                                                      Open

                                                                return { type: 'NULL' }
                                                      Severity: Major
                                                      Found in core/sync/index.js - About 30 mins to fix

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

                                                          async start() /*: Promise<void> */ {
                                                            if (this.lifecycle.willStop()) {
                                                              await this.lifecycle.stopped()
                                                            } else {
                                                              return
                                                        Severity: Minor
                                                        Found in core/sync/index.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.isFile(doc)) {
                                                              this.events.emit('transfer-started', doc)
                                                              try {
                                                                await side.addFileAsync(doc, ({ transferred }) => {
                                                                  // XXX: progress will never be emitted when we copy the content from
                                                        Severity: Major
                                                        Found in core/sync/index.js and 1 other location - About 4 hrs to fix
                                                        core/sync/index.js on lines 943..956

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

                                                        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

                                                          ) /*: Promise<void> */ {
                                                            this.events.emit('transfer-started', doc)
                                                            try {
                                                              await side.overwriteFileAsync(doc, ({ transferred }) => {
                                                                // XXX: progress will never be emitted when we copy the content from
                                                        Severity: Major
                                                        Found in core/sync/index.js and 1 other location - About 4 hrs to fix
                                                        core/sync/index.js on lines 922..935

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

                                                        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

                                                              const done = (data = [], err) => {
                                                                this.lifecycle.off('will-stop', done)
                                                        
                                                                if (feedObserver) {
                                                                  feedObserver.cancel()
                                                        Severity: Major
                                                        Found in core/sync/index.js and 1 other location - About 1 hr to fix
                                                        core/sync/index.js on lines 606..618

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

                                                        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

                                                              const done = (data, err) => {
                                                                this.lifecycle.off('will-stop', done)
                                                        
                                                                if (feedObserver) {
                                                                  feedObserver.cancel()
                                                        Severity: Major
                                                        Found in core/sync/index.js and 1 other location - About 1 hr to fix
                                                        core/sync/index.js on lines 639..651

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

                                                        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

                                                            } else if (!metadata.wasSynced(doc)) {
                                                              log.debug({ path: doc.path }, `Applying ${doc.docType} addition`)
                                                              await this.doAdd(side, doc)
                                                            } else {
                                                              log.debug({ path: doc.path }, `Applying else for ${doc.docType} change`)
                                                        Severity: Minor
                                                        Found in core/sync/index.js and 1 other location - About 55 mins to fix
                                                        core/sync/index.js on lines 880..915

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

                                                        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

                                                            } else if (isMarkedForDeletion(doc)) {
                                                              log.debug({ path: doc.path }, `Applying ${doc.docType} deletion`)
                                                              await this.trashWithParentOrByItself(doc, side)
                                                            } else if (!metadata.wasSynced(doc)) {
                                                              log.debug({ path: doc.path }, `Applying ${doc.docType} addition`)
                                                        Severity: Minor
                                                        Found in core/sync/index.js and 1 other location - About 55 mins to fix
                                                        core/sync/index.js on lines 883..915

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

                                                        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 (doc.docType === metadata.FILE) {
                                                              this.events.emit('transfer-move', _.clone(doc), _.clone(from))
                                                            }
                                                        Severity: Minor
                                                        Found in core/sync/index.js and 1 other location - About 50 mins to fix
                                                        core/sync/index.js on lines 984..986

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

                                                        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 (
                                                                docB.moveFrom.path.startsWith(docA.path + sep) &&
                                                                !docB.path.startsWith(docA.path + sep)
                                                              ) {
                                                                return 1
                                                        Severity: Minor
                                                        Found in core/sync/index.js and 1 other location - About 50 mins to fix
                                                        core/sync/index.js on lines 177..181

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

                                                        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 (
                                                                docA.moveFrom.path.startsWith(docB.path + sep) &&
                                                                !docA.path.startsWith(docB.path + sep)
                                                              )
                                                                return -1
                                                        Severity: Minor
                                                        Found in core/sync/index.js and 1 other location - About 50 mins to fix
                                                        core/sync/index.js on lines 168..173

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

                                                        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 (doc.docType === metadata.FILE) {
                                                              this.events.emit('transfer-move', _.clone(doc), _.clone(from))
                                                            }
                                                        Severity: Minor
                                                        Found in core/sync/index.js and 1 other location - About 50 mins to fix
                                                        core/sync/index.js on lines 964..966

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

                                                        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