cozy-labs/cozy-desktop

View on GitHub

Showing 610 of 610 total issues

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

    if (doc.path === was.path) {
      log.warn({ path, doc, was }, 'Invalid move. Updating file')
      return this.updateFileAsync(side, doc)
    } else if (!was._rev) {
      const msg = 'Missing rev'
Severity: Major
Found in core/prep.js and 1 other location - About 4 hrs to fix
core/prep.js on lines 151..158

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

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 (doc.path === was.path) {
      log.warn({ path, doc, was }, 'Invalid move. Updating folder')
      return this.putFolderAsync(side, doc)
    } else if (!was._rev) {
      const msg = 'Missing rev'
Severity: Major
Found in core/prep.js and 1 other location - About 4 hrs to fix
core/prep.js on lines 111..118

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

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 errors.js has 325 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @module core/remote/errors
 * @flow
 */

Severity: Minor
Found in core/remote/errors.js - About 3 hrs to fix

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

        if (process.platform === 'darwin') {
          this.app.dock.show()
          const showTime = Date.now()
          this.win.on('closed', () => {
            const hideTime = Date.now()
    Severity: Major
    Found in gui/js/cozy-web.window.js and 1 other location - About 3 hrs to fix
    gui/js/window_manager.js on lines 228..237

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

    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

      async updateFileAsync(side /*: SideName */, doc /*: Metadata */) {
        log.debug({ path: doc.path }, 'updateFileAsync')
        metadata.ensureValidPath(doc)
        metadata.ensureValidChecksum(doc)
    
    
    Severity: Major
    Found in core/prep.js and 1 other location - About 3 hrs to fix
    core/prep.js on lines 54..64

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

    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

      async addFileAsync(side /*: SideName */, doc /*: Metadata */) {
        log.debug({ path: doc.path }, 'addFileAsync')
        metadata.ensureValidPath(doc)
        metadata.ensureValidChecksum(doc)
    
    
    Severity: Major
    Found in core/prep.js and 1 other location - About 3 hrs to fix
    core/prep.js on lines 69..79

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

    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 (process.platform === 'darwin' && this.makesAppVisible()) {
          this.app.dock.show()
          const showTime = Date.now()
          this.win.on('closed', () => {
            const hideTime = Date.now()
    Severity: Major
    Found in gui/js/window_manager.js and 1 other location - About 3 hrs to fix
    gui/js/cozy-web.window.js on lines 60..69

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

    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

    Config has 30 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class Config {
      /*::
      configPath: string
      dbPath: string
      fileConfig: FileConfig
    Severity: Minor
    Found in core/config.js - About 3 hrs to fix

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

        async addByLocalPathView() {
          const sep = JSON.stringify(path.sep)
          let normalized
          switch (process.platform) {
            case 'darwin':
      Severity: Major
      Found in core/pouch/index.js and 1 other location - About 3 hrs to fix
      core/pouch/index.js on lines 421..445

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

      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

        async addByPathView() {
          const sep = JSON.stringify(path.sep)
          let normalized
          switch (process.platform) {
            case 'darwin':
      Severity: Major
      Found in core/pouch/index.js and 1 other location - About 3 hrs to fix
      core/pouch/index.js on lines 456..480

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

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

      const updateState = async ({ newState, data }) => {
        const { status, filename, userAlerts, errors } = data || {}
      
        if (newState === 'sync-state') {
          if (status === 'uptodate') tray.setStatus('online')
      Severity: Minor
      Found in gui/main.js - About 3 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 defaultSorter has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
      Open

      const defaultSorter = (a /*: LocalChange */, b /*: LocalChange */) => {
        if (a.wip && !b.wip) return aFirst
        if (b.wip && !a.wip) return bFirst
      
        // b is deleting something which is a children of what a adds
      Severity: Minor
      Found in core/local/chokidar/analysis.js - About 3 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 identifyExistingDocChange has 89 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        identifyExistingDocChange(
          remoteDoc /*: CouchDBDoc|FullRemoteFile|RemoteDir */,
          was /*: ?SavedMetadata */,
          previousChanges /*: Array<RemoteChange> */,
          originalMoves /*: Array<RemoteDirMove|RemoteDescendantChange> */,
      Severity: Major
      Found in core/remote/watcher/index.js - About 3 hrs to fix

        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 buildAppMenu has 87 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          module.exports.buildAppMenu = app => {
            const template = [
              {
                label: translate('AppMenu Edit'),
                submenu: [
          Severity: Major
          Found in gui/js/appmenu.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

              Function deleteFolderAsync has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
              Open

                async deleteFolderAsync(side /*: SideName */, doc /*: SavedMetadata */) {
                  log.debug({ path: doc.path }, 'deleteFolderAsync')
                  const folder /*: ?SavedMetadata */ = await this.pouch.byIdMaybe(doc._id)
              
                  if (!folder) {
              Severity: Minor
              Found in core/merge.js - About 3 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

              File app.js has 306 lines of code (exceeds 250 allowed). Consider refactoring.
              Open

              /** Entry point of the synchronization core.
               *
               * @module core/app
               * @flow
               */
              Severity: Minor
              Found in core/app.js - About 3 hrs to fix

                File tray.window.js has 305 lines of code (exceeds 250 allowed). Consider refactoring.
                Open

                /* @flow */
                
                const electron = require('electron')
                const { dialog, shell } = electron
                const path = require('path')
                Severity: Minor
                Found in gui/js/tray.window.js - About 3 hrs to fix

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

                  /** The Local side read/write interface.
                   *
                   * @module core/local
                   * @flow
                   */
                  Severity: Minor
                  Found in core/local/index.js - About 3 hrs to fix
                    Severity
                    Category
                    Status
                    Source
                    Language