cozy-labs/cozy-desktop

View on GitHub

Showing 610 of 610 total issues

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

      case 'stop':
        if (this.canTransitionTo('will-stop')) {
          this.transitionTo('will-stop')
        } else {
          throw new Error(`Cannot begin ${endState}`)
Severity: Minor
Found in core/utils/lifecycle.js and 1 other location - About 50 mins to fix
core/utils/lifecycle.js on lines 47..53

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

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

const sameLocal = (() => {
  const comparator = makeComparator('sameLocal')

  return (one /*: MetadataLocalInfo */, two /*: MetadataLocalInfo */) =>
    comparator(one, two)
Severity: Minor
Found in core/metadata.js and 1 other location - About 50 mins to fix
core/metadata.js on lines 731..736

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

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

const sameRemote = (() => {
  const comparator = makeComparator('sameRemote')

  return (one /*: MetadataRemoteInfo */, two /*: MetadataRemoteInfo */) =>
    comparator(one, two)
Severity: Minor
Found in core/metadata.js and 1 other location - About 50 mins to fix
core/metadata.js on lines 723..728

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

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

  identifyExistingDocChange(
    remoteDoc /*: CouchDBDoc|FullRemoteFile|RemoteDir */,
    was /*: ?SavedMetadata */,
    previousChanges /*: Array<RemoteChange> */,
    originalMoves /*: Array<RemoteDirMove|RemoteDescendantChange> */,
Severity: Minor
Found in core/remote/watcher/index.js and 1 other location - About 50 mins to fix
core/remote/watcher/index.js on lines 389..450

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

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 (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 (dstChild.overwrite) delete dstChild.overwrite
      Severity: Major
      Found in core/merge.js - About 45 mins to fix

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

        const sortChanges = (a, b) => {
          if (isDelete(a) || isTrash(a)) return sortForDelete(a, b, aFirst)
          if (isDelete(b) || isTrash(b)) return sortForDelete(b, a, bFirst)
        
          if (isMove(a)) return sortForMove(a, b, aFirst)
        Severity: Minor
        Found in core/remote/change.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 sortForDelete has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const sortForDelete = (del, b, delFirst) => {
          if (isDelete(b) || isTrash(b)) {
            if (lower(deletedPath(del), deletedPath(b))) return delFirst
            if (lower(deletedPath(b), deletedPath(del))) return -delFirst
        
        
        Severity: Minor
        Found in core/remote/change.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 sendErrorToMainWindow has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

        const sendErrorToMainWindow = async ({ msg, code }) => {
          if (code === COZY_CLIENT_REVOKED_CODE) {
            return showRevokedCozyError()
          } else if (msg === SYNC_DIR_UNLINKED_MESSAGE) {
            if (notificationsState.syncDirUnlinkedShown) return
        Severity: Minor
        Found in gui/main.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 (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 (!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 (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

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

              const platformIcon = (iconName, { pressed = false } = {}) =>
                nativeImage.createFromPath(
                  isMac
                    ? pressed
                      ? `${imgs}/tray-icon-osx/${iconName}Highlight.png`
              Severity: Minor
              Found in gui/js/tray.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 (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 (!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 (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

                    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

                    Severity
                    Category
                    Status
                    Source
                    Language