cozy-labs/cozy-desktop

View on GitHub

Showing 610 of 610 total issues

Function overwriteFileAsync has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async overwriteFileAsync(
    doc /*: SavedMetadata */,
    onProgress /*: ?ProgressCallback */
  ) /*: Promise<void> */ {
    const { path } = doc
Severity: Minor
Found in core/remote/index.js - About 1 hr to fix

    Function update has 38 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      update(newState /*: $Shape<State> */) {
        const { state } = this
    
        const syncCurrentSeq = newState.syncCurrentSeq || state.syncCurrentSeq
        const syncTargetSeq = newState.syncTargetSeq || state.syncTargetSeq
    Severity: Minor
    Found in core/syncstate.js - About 1 hr to fix

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

            case 413:
              if (isFileLargerThanAllowed(doc)) {
                return new RemoteError({
                  code: FILE_TOO_LARGE_CODE,
                  message: 'The file is larger than allowed by the remote Cozy',
      Severity: Major
      Found in core/remote/errors.js and 1 other location - About 1 hr to fix
      core/remote/errors.js on lines 229..242

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

      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 404:
              if (hasNoReason(err)) {
                return new RemoteError({
                  code: COZY_NOT_FOUND_CODE,
                  message: 'Remote Cozy could not be found',
      Severity: Major
      Found in core/remote/errors.js and 1 other location - About 1 hr to fix
      core/remote/errors.js on lines 274..287

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

      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

      Function sendMailToSupport has 37 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        async sendMailToSupport(content /*: string */) {
          const incidentID = uuid()
          const zipper = createGzip({
            // TODO tweak this values, low resources for now.
            memLevel: 7,
      Severity: Minor
      Found in core/app.js - About 1 hr to fix

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

                try {
                  stream = await this.other.createReadStreamAsync(doc)
                } catch (err) {
                  if (err.code === 'ENOENT') {
                    log.warn({ path }, 'Local file does not exist anymore.')
        Severity: Major
        Found in core/remote/index.js and 1 other location - About 1 hr to fix
        core/remote/index.js on lines 194..205

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

        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 {
                log.warn({ err, path: filePath }, 'could not reach remote Cozy')
                throw new CozyNoteError({
                  code: 'UnreachableError',
                  cozyURL: config.cozyUrl,
        Severity: Major
        Found in core/utils/notes.js and 1 other location - About 1 hr to fix
        core/utils/notes.js on lines 173..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 64.

        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 (err.status === 403 || err.status === 404) {
                log.warn({ err, path: filePath }, 'could not find remote Note')
                throw new CozyNoteError({
                  code: 'CozyDocumentMissingError',
                  cozyURL: config.cozyUrl,
        Severity: Major
        Found in core/utils/notes.js and 1 other location - About 1 hr to fix
        core/utils/notes.js on lines 181..189

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

        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

                try {
                  stream = await this.other.createReadStreamAsync(doc)
                } catch (err) {
                  if (err.code === 'ENOENT') {
                    log.warn({ path }, 'Local file does not exist anymore.')
        Severity: Major
        Found in core/remote/index.js and 1 other location - About 1 hr to fix
        core/remote/index.js on lines 236..247

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

        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

        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 update has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            update(newState /*: $Shape<State> */) {
              const { state } = this
          
              const syncCurrentSeq = newState.syncCurrentSeq || state.syncCurrentSeq
              const syncTargetSeq = newState.syncTargetSeq || state.syncTargetSeq
          Severity: Minor
          Found in core/syncstate.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 setup has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

            async setup() {
              const clientInfo = this.clientInfo()
              log.info(clientInfo, 'user config')
          
              if (!this.config.isValid()) {
          Severity: Minor
          Found in core/app.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 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 findDocument has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          async function findDocument(
            filePath /*: string */,
            { config, pouch } /*: { config: Config, pouch: Pouch } */
          ) /*: Promise<{ driveWebUrl: string }> */ {
            const { cozyUrl } = config
          Severity: Minor
          Found in core/utils/web.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 fixPathsAfterParentMove has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          function fixPathsAfterParentMove(renamedEvents, event) {
            for (const renamedEvent of renamedEvents) {
              if (
                event.oldPath &&
                areParentChildPaths(renamedEvent.oldPath, event.oldPath)
          Severity: Minor
          Found in core/local/channel_watcher/initial_diff.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 putFolderRecursivelyAsync has 35 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

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

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

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

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

              function dissociateRemote(doc /*: Metadata */) {
                if (doc.sides && doc.sides.remote) delete doc.sides.remote
                if (doc.remote) delete doc.remote
              }
              Severity: Major
              Found in core/metadata.js and 1 other location - About 1 hr to fix
              core/metadata.js on lines 510..513

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

              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

              function dissociateLocal(doc /*: Metadata */) {
                if (doc.sides && doc.sides.local) delete doc.sides.local
                if (doc.local) delete doc.local
              }
              Severity: Major
              Found in core/metadata.js and 1 other location - About 1 hr to fix
              core/metadata.js on lines 505..508

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

              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

              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
                Severity
                Category
                Status
                Source
                Language