cozy-labs/cozy-desktop

View on GitHub

Showing 610 of 610 total issues

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

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

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

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

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

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 298.

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

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

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

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

    Refactorings

    Further Reading

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

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

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 298.

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

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

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

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

    Refactorings

    Further Reading

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

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

      File local_change.js has 621 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      /** A local change as to be fed to Prep/Merge.
       *
       * Ended up being specific to ChokidarWatcher.
       *
       * @module core/local/chokidar/local_change
      Severity: Major
      Found in core/local/chokidar/local_change.js - About 1 day to fix

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

          if (data.component === 'ChokidarWatcher') {
            if (data.msg === 'FileAddition' || data.msg === 'DirAddition') {
              console.log(`${ts}|Local|A|${path}`)
            } else if (data.msg === 'FileMove' || data.msg === 'DirMove') {
              console.log(`${ts}|Local|D|${data.oldpath}`)
        Severity: Major
        Found in dev/log2gource.js and 1 other location - About 1 day to fix
        dev/log2gource.js on lines 46..57

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

        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 (data.component === 'RemoteWatcher') {
            if (data.msg === 'FileAddition' || data.msg === 'DirAddition') {
              console.log(`${ts}|Remote|A|${path}`)
            } else if (data.msg === 'FileMove' || data.msg === 'DirMove') {
              console.log(`${ts}|Remote|D|${data.oldpath}`)
        Severity: Major
        Found in dev/log2gource.js and 1 other location - About 1 day to fix
        dev/log2gource.js on lines 33..44

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

        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

        File metadata.js has 589 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        /** Metadata of synchronized files & directories.
         *
         * ### File
         *
         * - `_rev`: from PouchDB
        Severity: Major
        Found in core/metadata.js - About 1 day to fix

          File main.js has 571 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          'use strict'
          
          require('../core/globals')
          
          // Initialize `remote` module so that renderer processes can use it.
          Severity: Major
          Found in gui/main.js - About 1 day 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 debounce has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
            Open

            function debounce(waiting /*: WaitingItem[] */, events /*: ChannelEvent[] */) {
              for (let i = 0; i < events.length; i++) {
                const event = events[i]
            
                if (event.incomplete) {
            Severity: Minor
            Found in core/local/channel_watcher/await_write_finish.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 initialDiff has a Cognitive Complexity of 59 (exceeds 5 allowed). Consider refactoring.
            Open

            async function initialDiff(
              channel /*: Channel */,
              out /*: Channel */,
              { config, state } /*: { config: Config, state: InitialDiffState } */
            ) /*: Promise<void> */ {
            Severity: Minor
            Found in core/local/channel_watcher/initial_diff.js - About 1 day to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

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

            /**
             * @module core/remote/watcher
             * @flow
             */
            
            
            Severity: Major
            Found in core/remote/watcher/index.js - About 1 day to fix

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

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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 203.

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

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

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

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

              Refactorings

              Further Reading

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

                try {
                  const verifyCommand = `.\\build\\windows\\verify.ps1`
                  const fingerprint = `"${process.env.SM_CERTIFICATE_FINGERPRINT}"`
                  const verify = [
                    `pwsh`,
              Severity: Major
              Found in build/windows/customSign.js and 1 other location - About 1 day to fix
              build/windows/customSign.js on lines 21..44

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 203.

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

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

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

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

              Refactorings

              Further Reading

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

                try {
                  const signCommand = `.\\build\\windows\\sign.ps1`
                  const keyPairAlias = `"${process.env.KEYPAIR_ALIAS}"`
                  const sign = [
                    `pwsh`,
              Severity: Major
              Found in build/windows/customSign.js and 1 other location - About 1 day to fix
              build/windows/customSign.js on lines 47..70

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 203.

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

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

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

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

              Refactorings

              Further Reading

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

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

              Duplicated Code

              Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

              Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

              When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

              Tuning

              This issue has a mass of 203.

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

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

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

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

              Refactorings

              Further Reading

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

                  if (!was) {
                    if (await docWasAlreadyMoved(event.oldPath, event.path, pouch)) {
                      log.debug({ event }, 'Assuming file already moved')
                      return
                    }
              Severity: Major
              Found in core/local/channel_watcher/dispatch.js and 1 other location - About 7 hrs to fix
              core/local/channel_watcher/dispatch.js on lines 213..234

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

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

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

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

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

              Refactorings

              Further Reading

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

                  if (!was) {
                    if (await docWasAlreadyMoved(event.oldPath, event.path, pouch)) {
                      log.debug({ event }, 'Assuming dir already moved')
                      return
                    }
              Severity: Major
              Found in core/local/channel_watcher/dispatch.js and 1 other location - About 7 hrs to fix
              core/local/channel_watcher/dispatch.js on lines 181..198

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

              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