cozy-labs/cozy-desktop

View on GitHub

Showing 610 of 610 total issues

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

    e('ul', null, [
      e(
        'li',
        { key: 'nameLength' },
        interpolate(
Severity: Major
Found in gui/details.js and 1 other location - About 2 hrs to fix
gui/details.js on lines 153..180

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

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

    e('ul', null, [
      e(
        'li',
        { key: 'nameLength' },
        interpolate(
Severity: Major
Found in gui/details.js and 1 other location - About 2 hrs to fix
gui/details.js on lines 124..151

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

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

  create() {
    this.log.debug('create')
    const opts = {
      ...this.windowOptions(),
      autoHideMenuBar: true,
Severity: Major
Found in gui/js/cozy-web.window.js - About 2 hrs to fix

    Function debounce has 51 lines of code (exceeds 25 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: Major
    Found in core/local/channel_watcher/await_write_finish.js - About 2 hrs to fix

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

      const loop = (channel /*: Channel */, opts /*: OverwriteOptions */) => {
        const out = new Channel()
      
        _loop(channel, out, opts).catch(err => {
          log.warn({ err })
      Severity: Major
      Found in core/local/channel_watcher/overwrite.js and 1 other location - About 2 hrs to fix
      core/local/channel_watcher/win_identical_renaming.js on lines 169..180

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

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

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

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

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

      Refactorings

      Further Reading

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

      const loop = (
        channel /*: Channel */,
        opts /*: WinIdenticalRenamingOptions */
      ) => {
        const out = new Channel()
      Severity: Major
      Found in core/local/channel_watcher/win_identical_renaming.js and 1 other location - About 2 hrs to fix
      core/local/channel_watcher/overwrite.js on lines 174..182

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

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

          const started = new Promise(resolve => {
            this.initialScanParams.resolve = resolve
      
            for (let eventType of [
              'add',
      Severity: Minor
      Found in core/local/chokidar/watcher.js - About 2 hrs to fix

        Function identifyChange has 49 lines of code (exceeds 25 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

          Function selectIcon has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          const selectIcon = info => {
            if (info.path.endsWith('url')) {
              return 'link'
            } else if (!info.mime) {
              return 'file'
          Severity: Minor
          Found in gui/js/fileutils.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 step has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

          const step = async (
            changes /*: LocalChange[] */,
            { pouch, prep } /*: SendToPrepOpts */
          ) => {
            const errors /*: Error[] */ = []
          Severity: Minor
          Found in core/local/chokidar/send_to_prep.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 _withDomainErrors has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
          Open

            async _withDomainErrors /*:: <T: FullRemoteFile|RemoteDir> */(
              data /*: Readable */,
              options /*: Object */,
              fn /*: () => Promise<T> */
            ) /*: Promise<T> */ {
          Severity: Minor
          Found in core/remote/cozy.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 moveAsync has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async moveAsync /*::<T: Metadata|SavedMetadata> */(
              newMetadata /*: T */,
              oldMetadata /*: T */
            ) /*: Promise<void> */ {
              const remoteId = oldMetadata.remote._id
          Severity: Minor
          Found in core/remote/index.js - About 1 hr to fix

            Function p has 47 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                const p = new Promise((resolve, reject) => {
                  let feedObserver
                  const done = (data = [], err) => {
                    this.lifecycle.off('will-stop', done)
            
            
            Severity: Minor
            Found in core/sync/index.js - About 1 hr to fix

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

                          if (event.action === 'modified') {
                            addDebugInfo(event, e)
                            // Preserve the action from the first event (it can be a created file)
                            event.action = e.action
              
              
              Severity: Major
              Found in core/local/channel_watcher/await_write_finish.js and 1 other location - About 1 hr to fix
              core/local/channel_watcher/await_write_finish.js on lines 136..144

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

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

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

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

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

              Refactorings

              Further Reading

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

                if (
                  !addChange ||
                  metadata.id(addChange.path) !== metadata.id(e.path) ||
                  addChange.path.normalize() === e.path.normalize()
                ) {
              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 647..653

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

              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 'trash':
                      debug('- trash', action.path)
                      {
                        const remoteDoc = await cozy.files.statByPath(`/${action.path}`)
                        return cozy.files.trashById(remoteDoc._id)
              Severity: Major
              Found in dev/capture/remote.js and 1 other location - About 1 hr to fix
              dev/capture/remote.js on lines 164..171

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

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

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

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

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

              Refactorings

              Further Reading

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

                if (
                  !addChange ||
                  metadata.id(addChange.path) !== metadata.id(e.path) ||
                  addChange.path.normalize() === e.path.normalize()
                ) {
              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 581..587

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

              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 'restore':
                      debug('- restore .cozy_trash/', action.pathInTrash)
                      {
                        const remoteDoc = await cozy.files.statByPath(
                          `/.cozy_trash/${action.pathInTrash}`
              Severity: Major
              Found in dev/capture/remote.js and 1 other location - About 1 hr to fix
              dev/capture/remote.js on lines 149..154

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

              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 (recentEvent.action === 'modified') {
                  addDebugInfo(recentEvent, oldEvent)
                  // Preserve the action from the first event (it can be a created file)
                  recentEvent.action = oldEvent.action
              
              
              Severity: Major
              Found in core/local/channel_watcher/await_write_finish.js and 1 other location - About 1 hr to fix
              core/local/channel_watcher/await_write_finish.js on lines 207..215

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

              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 (initDoc.trashed) {
                      remoteDocsToTrash.push(remoteDir)
                    } else {
                      await builders
                        .metadir()
              Severity: Major
              Found in dev/capture/remote.js and 1 other location - About 1 hr to fix
              dev/capture/remote.js on lines 87..96

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

              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