cozy-labs/cozy-desktop

View on GitHub

Showing 610 of 610 total issues

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

const chokidarOptions = {
  cwd: syncPath,
  ignored: /(^|[\/\\])\.system-tmp-cozy-drive/, // eslint-disable-line no-useless-escape
  followSymlinks: false,
  alwaysStat: true,
Severity: Major
Found in dev/capture/local.js and 1 other location - About 1 hr to fix
dev/chokidar.js on lines 53..66

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

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

const networkConfig = (argv /*: Array<*> */ = process.argv) => {
  const networkConfig = yargs
    .env('COZY_DRIVE')
    .conflicts('proxy-script', 'proxy-rules')
    .option('proxy-script', {
Severity: Minor
Found in gui/js/network/index.js - About 1 hr to fix

    Function apply has 41 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      async apply(change /*: Change */) /*: Promise<void> */ {
        let stopMeasure = () => {}
        try {
          this.events.emit('sync-current', change.seq)
    
    
    Severity: Minor
    Found in core/sync/index.js - About 1 hr to fix

      Function getDirectoryContent has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      async function getDirectoryContent(context) {
        const { client } = context
        const dir = { _id: ROOT_DIR_ID, path: '/', name: '/' }
        const dirContent = { [dir.name]: {} }
        let resp /*: { next: boolean, bookmark?: string, data: Object[] } */ = {
      Severity: Minor
      Found in dev/remote/change-dir-exclusions.js - About 1 hr to fix

        Function squashMoves has 40 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const squashMoves = (
          doc /*: Metadata */,
          was /*: SavedMetadata */,
          previousChanges /*: RemoteChange[] */,
          encounteredMoves /*: Array<RemoteDirMove|RemoteDescendantChange> */
        Severity: Minor
        Found in core/remote/watcher/squashMoves.js - About 1 hr to fix

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

            const fileMove /*: Object */ = build('FileMove', addChange.path, {
              stats: addChange.stats,
              md5sum: addChange.md5sum,
              old: e.old,
              ino: addChange.ino,
          Severity: Major
          Found in core/local/chokidar/local_change.js and 2 other locations - About 1 hr to fix
          core/local/chokidar/local_change.js on lines 555..561
          core/local/chokidar/local_change.js on lines 589..595

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

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

          function loop(
            channel /*: Channel */,
            opts /*: { config: Config, pouch: Pouch, fatal: Error => any } */
          ) /*: Channel */ {
            const syncPath = opts.config.syncPath
          Severity: Minor
          Found in core/local/channel_watcher/add_infos.js - About 1 hr to fix

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

              const fileMove /*: Object */ = build('FileMove', addChange.path, {
                stats: e.stats,
                md5sum: e.md5sum,
                old: e.old,
                ino: addChange.ino,
            Severity: Major
            Found in core/local/chokidar/local_change.js and 2 other locations - About 1 hr to fix
            core/local/chokidar/local_change.js on lines 461..467
            core/local/chokidar/local_change.js on lines 589..595

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

            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 3 locations. Consider refactoring.
            Open

              const fileMove /*: Object */ = build('FileMove', e.path, {
                stats: addChange.stats,
                old: addChange.old,
                ino: addChange.ino,
                md5sum: e.md5sum,
            Severity: Major
            Found in core/local/chokidar/local_change.js and 2 other locations - About 1 hr to fix
            core/local/chokidar/local_change.js on lines 461..467
            core/local/chokidar/local_change.js on lines 555..561

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

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

              ipcEvents() {
                return {
                  confirm: async (
                    event /*: ElectronEvent */,
                    {
            Severity: Minor
            Found in gui/js/tray.window.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 openNote has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

            const openNote = async (
              filePath /*: string */,
              { desktop } /*: { desktop: App } */
            ) => {
              try {
            Severity: Minor
            Found in gui/utils/notes.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 identifyChange has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              identifyChange(
                remoteDoc /*: CouchDBDoc|CouchDBDeletion|FullRemoteFile|RemoteDir */,
                was /*: ?SavedMetadata */,
                previousChanges /*: Array<RemoteChange> */,
                originalMoves /*: Array<RemoteDirMove|RemoteDescendantChange> */,
            Severity: Minor
            Found in core/remote/watcher/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 buildEvent has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
            Open

              async buildEvent(
                event /*: ParcelEvent */,
                { fromScan = false } /*: { fromScan: boolean } */
              ) /*: Promise<?ChannelEvent> */ {
                // Completely skip events for Desktop's temporary files
            Severity: Minor
            Found in core/local/channel_watcher/parcel_producer.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 runAndRecordChokidarEvents has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            const runAndRecordChokidarEvents = scenario => {
              return new Promise((resolve, reject) => {
                const watcher = chokidar.watch('.', chokidarOptions)
                const cleanCallback = cb =>
                  function () {
            Severity: Minor
            Found in dev/capture/local.js - About 1 hr to fix

              Function detectNameIncompatibilities has 39 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              const detectNameIncompatibilities = (
                name /*: string */,
                type /*: 'file'|'folder' */,
                platform /*: string */
              ) /*: NameIncompatibility[] */ => {
              Severity: Minor
              Found in core/incompatibilities/platform.js - About 1 hr to fix

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

                      const done = (data = [], err) => {
                        this.lifecycle.off('will-stop', done)
                
                        if (feedObserver) {
                          feedObserver.cancel()
                Severity: Major
                Found in core/sync/index.js and 1 other location - About 1 hr to fix
                core/sync/index.js on lines 606..618

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

                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

                  log.debug(
                    {
                      oldpath: dirMove.old && dirMove.old.path,
                      path: dirMove.path,
                      ino: dirMove.ino,
                Severity: Major
                Found in core/local/chokidar/local_change.js and 1 other location - About 1 hr to fix
                core/local/chokidar/local_change.js on lines 469..477

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

                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

                      const done = (data, err) => {
                        this.lifecycle.off('will-stop', done)
                
                        if (feedObserver) {
                          feedObserver.cancel()
                Severity: Major
                Found in core/sync/index.js and 1 other location - About 1 hr to fix
                core/sync/index.js on lines 639..651

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

                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

                  log.debug(
                    {
                      oldpath: fileMove.old && fileMove.old.path,
                      path: fileMove.path,
                      ino: fileMove.ino,
                Severity: Major
                Found in core/local/chokidar/local_change.js and 1 other location - About 1 hr to fix
                core/local/chokidar/local_change.js on lines 442..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 66.

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

                  async watch() /*: Promise<?RemoteError> */ {
                    const release = await this.pouch.lock(this)
                    try {
                      if (!this.running) {
                        log.debug('Watcher stopped: skipping remote watch')
                Severity: Minor
                Found in core/remote/watcher/index.js - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language