cozy-labs/cozy-desktop

View on GitHub

Showing 610 of 610 total issues

Function createInitialTree has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const createInitialTree = async function (
  scenario /*: * */,
  cozy /*: * */,
  pouch /*: Pouch */
) {
Severity: Major
Found in dev/capture/remote.js - About 2 hrs to fix

    Function putFolderRecursivelyAsync has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      async putFolderRecursivelyAsync(
        side /*: SideName */,
        folder /*: Metadata  */,
        was /*: SavedMetadata */
      ) {
    Severity: Minor
    Found in core/merge.js - About 2 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 trashFileAsync has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

      async trashFileAsync(
        side /*: SideName */,
        trashed /*: SavedMetadata */,
        doc /*: Metadata */
      ) /*: Promise<void> */ {
    Severity: Minor
    Found in core/merge.js - About 2 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 analyseEvents has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    function analyseEvents(
      events /*: LocalEvent[] */,
      pendingChanges /*: LocalChange[] */
    ) /*: LocalChange[] */ {
      const stopMeasure = measureTime('LocalWatcher#analyseEvents')
    Severity: Minor
    Found in core/local/chokidar/analysis.js - About 2 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 initialScanSorter has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
    Open

    const initialScanSorter = (a /*: LocalChange */, b /*: LocalChange */) => {
      if (a.wip && !b.wip) return aFirst
      if (b.wip && !a.wip) return bFirst
    
      if (localChange.isChildAdd(a, b)) return aFirst
    Severity: Minor
    Found in core/local/chokidar/analysis.js - About 2 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 deleteFolderAsync has 60 lines of code (exceeds 25 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: Major
    Found in core/merge.js - About 2 hrs to fix

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

          if (!was) {
            log.debug(
              { path: oldpath },
              'moved file missing from PouchDB. Adding at destination'
            )
      Severity: Major
      Found in core/merge.js and 1 other location - About 2 hrs to fix
      core/merge.js on lines 577..588

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

      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) {
            log.debug(
              { path: oldpath },
              'moved folder missing from PouchDB. Adding at destination'
            )
      Severity: Major
      Found in core/merge.js and 1 other location - About 2 hrs to fix
      core/merge.js on lines 460..468

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

      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

      Consider simplifying this complex logical expression.
      Open

          if (attributes.type === DIR_TYPE) {
            return {
              ...attributes,
              dir_id: attributes.dir_id || '',
              name: attributes.name || '',
      Severity: Critical
      Found in core/remote/document.js - About 2 hrs to fix

        RemoteWatcher has 22 functions (exceeds 20 allowed). Consider refactoring.
        Open

        class RemoteWatcher {
          /*::
          config: Config
          pouch: Pouch
          prep: Prep
        Severity: Minor
        Found in core/remote/watcher/index.js - About 2 hrs to fix

          Function _withDomainErrors has 58 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async _withDomainErrors /*:: <T: FullRemoteFile|RemoteDir> */(
              data /*: Readable */,
              options /*: Object */,
              fn /*: () => Promise<T> */
            ) /*: Promise<T> */ {
          Severity: Major
          Found in core/remote/cozy.js - About 2 hrs to fix

            Function default has 57 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            exports.default = async function (configuration) {
              const { execSync } = require('child_process')
            
              const whoami = 'customSign.js'
            
            
            Severity: Major
            Found in build/windows/customSign.js - About 2 hrs to fix

              Function getNextChanges has 57 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                async getNextChanges(seq /*: number */) /*: Promise<Change[]> */ {
                  const stopMeasure = measureTime('Sync#getNextChanges')
                  const opts = {
                    ...this.baseChangeOptions(seq),
                    include_docs: true,
              Severity: Major
              Found in core/sync/index.js - About 2 hrs to fix

                Function getDirectoryContent has a Cognitive Complexity of 17 (exceeds 5 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 2 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 findNote has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
                Open

                const findNote = async (
                  filePath /*: string */,
                  {
                    config,
                    pouch,
                Severity: Minor
                Found in core/utils/notes.js - About 2 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 55 lines of code (exceeds 25 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: Major
                Found in core/local/chokidar/analysis.js - About 2 hrs to fix

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

                    setRemoteSeq(seq /*: string */) {
                      const task = {
                        _id: '_local/remoteSeq',
                        seq
                      }
                  Severity: Major
                  Found in core/pouch/index.js and 1 other location - About 2 hrs to fix
                  core/pouch/index.js on lines 586..597

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

                  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

                    setLocalSeq(seq /*: number */) {
                      const task = {
                        _id: '_local/localSeq',
                        seq
                      }
                  Severity: Major
                  Found in core/pouch/index.js and 1 other location - About 2 hrs to fix
                  core/pouch/index.js on lines 610..621

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

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

                  /** This step handle the events of the ChannelWatcher initial scan.
                   *
                   * Some files and directories can have been deleted while cozy-desktop was
                   * stopped. So, at the end of the initial scan, we have to do a diff between
                   * what was in pouchdb and the events from the local watcher to find what was
                  Severity: Minor
                  Found in core/local/channel_watcher/initial_diff.js - About 2 hrs to fix

                    Function findParentMoves has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
                    Open

                    const findParentMoves = (
                      change /*: RemoteChange */,
                      previousChanges /*: RemoteChange[] */,
                      encounteredMoves /*: Array<RemoteDirMove|RemoteDescendantChange> */
                    ) => {
                    Severity: Minor
                    Found in core/remote/watcher/squashMoves.js - About 2 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

                    Severity
                    Category
                    Status
                    Source
                    Language