cozy-labs/cozy-desktop

View on GitHub

Showing 615 of 615 total issues

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 (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 (b.type === 'FileMove' && b.update) {
                  changes.push({
                    sideName: 'local',
                    type: 'FileUpdate',
                    path: b.update.path,
      Severity: Major
      Found in core/local/chokidar/analysis.js - About 45 mins to fix

        Function byPath has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        function byPath(
          docA /*: CouchDBDoc|CouchDBDeletion */,
          docB /*: CouchDBDoc|CouchDBDeletion */
        ) {
          if (!docA._deleted && !docB._deleted) {
        Severity: Minor
        Found in core/remote/cozy.js - About 45 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

        Function squashChildren has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const squashChildren = (
          change /*: RemoteDirMove|RemoteDescendantChange */,
          previousChanges /*: RemoteChange[] */,
          encounteredMoves /*: Array<RemoteDirMove|RemoteDescendantChange> */
        ) => {
        Severity: Minor
        Found in core/remote/watcher/squashMoves.js - About 45 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

        Function addRemote has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

          async addRemote(
            cozyUrl /*: string */,
            syncPath /*: string */,
            deviceName /*: string */
          ) {
        Severity: Minor
        Found in core/app.js - About 45 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 deeply nested control flow statements.
        Open

                  if (e.action === 'renamed' && e.path === event.path) {
                    log.debug(`Ignore overlapping ${event.kind} ${event.action}`, {
                      renamedEvent: e,
                      scanEvent: event
                    })
        Severity: Major
        Found in core/local/channel_watcher/initial_diff.js - About 45 mins to fix

          Avoid deeply nested control flow statements.
          Open

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

            Avoid deeply nested control flow statements.
            Open

                      if (kind(was) === event.kind) {
                        // TODO for a directory, maybe we should check the children
                        _.set(event, [STEP_NAME, 'actionConvertedFrom'], event.action)
                        event.action = 'renamed'
                        event.oldPath = was.local.path
            Severity: Major
            Found in core/local/channel_watcher/initial_diff.js - About 45 mins to fix

              Avoid deeply nested control flow statements.
              Open

                      } else if (foundUntouchedFile(event, was, truncateWindowsDates)) {
                        _.set(event, [STEP_NAME, 'md5sumReusedFrom'], was.local.path)
                        event.md5sum = was.local.md5sum
                      }
              Severity: Major
              Found in core/local/channel_watcher/initial_diff.js - About 45 mins to fix

                Avoid deeply nested control flow statements.
                Open

                          if (doc.local) {
                            const deletedEvent /*: ChannelEvent */ = {
                              action: 'deleted',
                              kind: kind(doc),
                              path: doc.local.path,
                Severity: Major
                Found in core/local/channel_watcher/initial_diff.js - About 45 mins to fix

                  Avoid deeply nested control flow statements.
                  Open

                            if (
                              (['created', 'modified'].includes(e.action) ||
                                (e.action === 'renamed' && ino(e) === ino(event))) &&
                              e.path === event.path
                            ) {
                  Severity: Major
                  Found in core/local/channel_watcher/await_write_finish.js - About 45 mins to fix

                    Function fileExistsLocally has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                      async fileExistsLocally(checksum /*: string */) {
                        const docs /*: SavedMetadata[] */ = await this.pouch.byChecksum(checksum)
                        if (docs == null || docs.length === 0) {
                          return false
                        }
                    Severity: Minor
                    Found in core/local/index.js - About 45 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

                    Function retryDelay has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const retryDelay = (err /*: RemoteError|SyncError */) /*: number */ => {
                      // Speed up tests
                      if (process.env.NODE_ENV === 'test') return 500
                    
                      if (err instanceof remoteErrors.RemoteError) {
                    Severity: Minor
                    Found in core/sync/errors.js - About 45 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 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

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

                        get client() /*: OAuthClient */ {
                          if (!this.fileConfig.creds) {
                            throw new Error(`Device not configured`)
                          }
                          return this.fileConfig.creds.client
                      Severity: Minor
                      Found in core/config.js and 1 other location - About 45 mins to fix
                      core/config.js on lines 214..219

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

                      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

                              case 'DirDeletion':
                                if (!c.old) {
                                  c.old = await pouch.bySyncedPath(c.path)
                                }
                                await onUnlinkDir(c, prep)
                      Severity: Minor
                      Found in core/local/chokidar/send_to_prep.js and 1 other location - About 45 mins to fix
                      core/local/chokidar/send_to_prep.js on lines 151..156

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

                      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

                              case 'FileDeletion':
                                if (!c.old) {
                                  c.old = await pouch.bySyncedPath(c.path)
                                }
                                await onUnlinkFile(c, prep)
                      Severity: Minor
                      Found in core/local/chokidar/send_to_prep.js and 1 other location - About 45 mins to fix
                      core/local/chokidar/send_to_prep.js on lines 145..150

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

                      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

                              case 'FileTrashing':
                                log.info('file was trashed remotely', { path })
                                await this.prep.trashFileAsync(sideName, change.was, change.doc)
                                break
                      Severity: Minor
                      Found in core/remote/watcher/index.js and 1 other location - About 45 mins to fix
                      core/remote/watcher/index.js on lines 616..619

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

                      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 (
                          !localChange.addPath(a) &&
                          localChange.childOf(localChange.addPath(b), localChange.delPath(a))
                        )
                          return aFirst
                      Severity: Minor
                      Found in core/local/chokidar/analysis.js and 1 other location - About 45 mins to fix
                      core/local/chokidar/analysis.js on lines 465..469

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

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

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

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

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

                      Refactorings

                      Further Reading

                      Severity
                      Category
                      Status
                      Source
                      Language