cozy-labs/cozy-desktop

View on GitHub

Showing 610 of 610 total issues

Function sortForMove has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

const sortForMove = (move, b, moveFirst) => {
  if (isMove(b)) {
    if (isDescendant(move) && isDescendant(b)) {
      if (areParentChild(deletedPath(move), deletedPath(b))) return moveFirst
      if (areParentChild(deletedPath(b), deletedPath(move))) return -moveFirst
Severity: Minor
Found in core/remote/change.js - About 7 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 putFolderAsync has a Cognitive Complexity of 49 (exceeds 5 allowed). Consider refactoring.
Open

  async putFolderAsync(side /*: SideName */, doc /*: Metadata */) {
    log.debug({ path: doc.path }, 'putFolderAsync')

    const folder /*: ?SavedMetadata */ = await this.pouch.bySyncedPath(doc.path)
    if (!folder) {
Severity: Minor
Found in core/merge.js - About 7 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 cozy.js has 461 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * @module core/remote/cozy
 * @flow
 */

Severity: Minor
Found in core/remote/cozy.js - About 7 hrs to fix

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

    /**
     * @module core/pouch
     * @flow
     */
    
    
    Severity: Minor
    Found in core/pouch/index.js - About 6 hrs to fix

      Function Details has 171 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const Details = props => {
        const { translate, interpolate } = props
      
        return e('div', { className: 'details' }, [
          e('header', { className: 'details__header' }, [
      Severity: Major
      Found in gui/details.js - About 6 hrs to fix

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

          {
            baseSchemaVersion: 4,
            targetSchemaVersion: 5,
            description: 'Removing moveFrom attribute of synced documents',
            affectedDocs: (docs /*: SavedMetadata[] */) /*: SavedMetadata[] */ => {
        Severity: Major
        Found in core/migrations/migrations.js and 1 other location - About 6 hrs to fix
        core/migrations/migrations.js on lines 44..65

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

        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

          {
            baseSchemaVersion: 1,
            targetSchemaVersion: 2,
            description: 'Removing overwrite attribute of synced documents',
            affectedDocs: (docs /*: SavedMetadata[] */) /*: SavedMetadata[] */ => {
        Severity: Major
        Found in core/migrations/migrations.js and 1 other location - About 6 hrs to fix
        core/migrations/migrations.js on lines 121..142

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

        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

        function fileUpdate(e /*: LocalFileUpdated */) /*: LocalFileUpdate */ {
          const change /*: LocalFileUpdate */ = {
            sideName,
            type: 'FileUpdate',
            path: e.path,
        Severity: Major
        Found in core/local/chokidar/local_change.js and 1 other location - About 6 hrs to fix
        core/local/chokidar/local_change.js on lines 330..348

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

        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

        function fileAddition(e /*: LocalFileAdded */) /*: LocalFileAddition */ {
          const change /*: LocalFileAddition */ = {
            sideName,
            type: 'FileAddition',
            path: e.path,
        Severity: Major
        Found in core/local/chokidar/local_change.js and 1 other location - About 6 hrs to fix
        core/local/chokidar/local_change.js on lines 365..383

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

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

          async applyDoc(
            doc /*: SavedMetadata */,
            side /*: Writer */
          ) /*: Promise<*> */ {
            if (doc.incompatibilities && side.name === 'local') {
        Severity: Minor
        Found in core/sync/index.js - About 6 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 wrapError has 148 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        const wrapError = (
          err /*: FetchError |  Error */,
          doc /*: ?SavedMetadata */
        ) /*: RemoteError */ => {
          if (isNetworkError(err)) {
        Severity: Major
        Found in core/remote/errors.js - About 5 hrs to fix

          Function makeComparator has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
          Open

          const makeComparator = (
            name /*: string */,
            { attributes } /*: { attributes?: Array<string> } */ = {}
          ) => {
            const interestingPaths = attributes && attributes.map(f => f.split('.'))
          Severity: Minor
          Found in core/metadata.js - About 5 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

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

              case 'unlinkDir':
                {
                  const moveChange /*: ?LocalDirMove */ =
                    localChange.maybeMoveFolder(sameInodeChange)
                  if (moveChange && !moveChange.wip) {
          Severity: Major
          Found in core/local/chokidar/analysis.js and 1 other location - About 5 hrs to fix
          core/local/chokidar/analysis.js on lines 222..244

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

          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

          function fileDeletion(e /*: LocalFileUnlinked */) /*: ?LocalFileDeletion */ {
            if (!getInode(e)) return
            const change /*: LocalFileDeletion */ = {
              sideName,
              type: 'FileDeletion',
          Severity: Major
          Found in core/local/chokidar/local_change.js and 1 other location - About 5 hrs to fix
          core/local/chokidar/local_change.js on lines 315..328

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

          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 'unlink':
                {
                  const moveChange /*: ?LocalFileMove */ =
                    localChange.maybeMoveFile(sameInodeChange)
                  if (moveChange && !moveChange.wip) {
          Severity: Major
          Found in core/local/chokidar/analysis.js and 1 other location - About 5 hrs to fix
          core/local/chokidar/analysis.js on lines 245..267

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

          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

          function dirDeletion(e /*: LocalDirUnlinked */) /*: ?LocalDirDeletion */ {
            if (!getInode(e)) return
            const change /*: LocalDirDeletion */ = {
              sideName,
              type: 'DirDeletion',
          Severity: Major
          Found in core/local/chokidar/local_change.js and 1 other location - About 5 hrs to fix
          core/local/chokidar/local_change.js on lines 350..363

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

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

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

          const wrapError = (
            err /*: FetchError |  Error */,
            doc /*: ?SavedMetadata */
          ) /*: RemoteError */ => {
            if (isNetworkError(err)) {
          Severity: Minor
          Found in core/remote/errors.js - About 5 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 syncBatch has 136 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            async syncBatch() /*: Promise<void> */ {
              let change /*: Change */ = {}
              while (!this.lifecycle.willStop()) {
                await this.lifecycle.ready()
          
          
          Severity: Major
          Found in core/sync/index.js - About 5 hrs to fix

            Pouch has 39 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class Pouch {
              /*::
              config: Config
              db: PouchDB
              updater: any
            Severity: Minor
            Found in core/pouch/index.js - About 5 hrs to fix
              Severity
              Category
              Status
              Source
              Language