cozy-labs/cozy-desktop

View on GitHub

Showing 610 of 610 total issues

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

          if (file.remote) {
            // In this case we can dissociate the local record from its remote
            // counterpart that was just renamed and will be fetched later.
            metadata.dissociateRemote(file)
            // We make sure Sync will detect and propagate the local update
Severity: Major
Found in core/merge.js and 1 other location - About 1 hr to fix
core/merge.js on lines 262..273

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

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 isFile(
  doc /*: Metadata|MetadataLocalInfo|MetadataRemoteInfo */
) /*: boolean %checks */ {
  return doc.docType != null
    ? doc.docType === FILE
Severity: Major
Found in core/metadata.js and 1 other location - About 1 hr to fix
core/metadata.js on lines 335..343

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

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

const showRevokedCozyError = async () => {
  // prevent the alert from appearing twice
  if (notificationsState.revokedAlertShown) return
  notificationsState.revokedAlertShown = true

Severity: Minor
Found in gui/main.js - About 1 hr to fix

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

      Function retryDelay has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      const retryDelay = (err /*: RemoteError|SyncError */) /*: number */ => {
        // Speed up tests
        if (process.env.NODE_ENV === 'test') return 500
      
        if (err instanceof remoteErrors.RemoteError) {
      Severity: Minor
      Found in core/sync/errors.js - About 1 hr to fix

        Function captureScenariosEvents has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        const captureScenariosEvents = async (scenarios, sides) => {
          try {
            // eslint-disable-next-line no-console
            console.log('test/scenarios/')
            for (let scenario of scenarios) {
        Severity: Minor
        Found in dev/capture.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 normalizedPath has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        const normalizedPath = (
          newPath /*: string */,
          oldPath /*: ?string */,
          parent /*: ?SavedMetadata */,
          normalizedPaths /*: string[] */
        Severity: Minor
        Found in core/local/chokidar/normalize_paths.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

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

          } else if (workArea.width < display.width && workArea.x === 0) {
            // right bar -> place window on bottom right
            newBounds.x = workArea.x + workArea.width - actualWidth
            newBounds.y = workArea.y + workArea.height - actualHeight
          } else if (workArea.width < display.width) {
        Severity: Major
        Found in gui/js/tray.window.js and 1 other location - About 1 hr to fix
        gui/js/tray.window.js on lines 86..94

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

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

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

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

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

        Refactorings

        Further Reading

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

          async findDirMaybe(id /*: string */) /*: Promise<?RemoteDir> */ {
            try {
              return await this.findDir(id)
            } catch (err) {
              if (err.status === 404) return null
        Severity: Major
        Found in core/remote/cozy.js and 1 other location - About 1 hr to fix
        core/remote/cozy.js on lines 368..377

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

        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

          } else if (workArea.height < display.height && workArea.y === 0) {
            // bottom bar -> place window on bottom right
            newBounds.x = workArea.x + workArea.width - actualWidth
            newBounds.y = workArea.y + workArea.height - actualHeight
          } else {
        Severity: Major
        Found in gui/js/tray.window.js and 1 other location - About 1 hr to fix
        gui/js/tray.window.js on lines 78..94

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

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

        const handleBunyanMessage = msg => {
          const level =
            msg.level >= bunyan.FATAL
              ? 'fatal'
              : msg.level >= bunyan.ERROR
        Severity: Minor
        Found in core/utils/sentry.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 setup has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

        function setup(clientInfos /*: ClientInfo */) {
          if (CI || COZY_NO_SENTRY || isSentryConfigured) {
            log.info(
              { COZY_NO_SENTRY, isSentryConfigured },
              'skipping Sentry configuration'
        Severity: Minor
        Found in core/utils/sentry.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 insert has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
        Open

          insert(change /*: Change */) {
            const newNode = {
              change,
              dependentOn: []
            }
        Severity: Minor
        Found in core/sync/dependency_graph.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

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

          async findMaybe(
            id /*: string */
          ) /*: Promise<?(FullRemoteFile|RemoteDir)> */ {
            try {
              return await this.find(id)
        Severity: Major
        Found in core/remote/cozy.js and 1 other location - About 1 hr to fix
        core/remote/cozy.js on lines 388..395

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

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

        const popoverBounds = (
          wantedWidth,
          wantedHeight,
          trayposition,
          workArea,
        Severity: Minor
        Found in gui/js/tray.window.js - About 1 hr to fix

          Function startSync has 31 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          const startSync = async () => {
            enqueueStateUpdate('syncing')
            desktop.events.on('sync-state', state => {
              enqueueStateUpdate('sync-state', state)
            })
          Severity: Minor
          Found in gui/main.js - About 1 hr to fix

            Function startChokidar has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function startChokidar() {
              const syncPath = process.env.COZY_DESKTOP_DIR || local.syncPath
              open(syncPath)
            
              fse.ensureDirSync(syncPath)
            Severity: Minor
            Found in dev/chokidar.js - About 1 hr to fix

              Function initialScanSorter has 31 lines of code (exceeds 25 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 1 hr to fix

                Function domainError has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    const domainError = async () => {
                      try {
                        const { name, dirID: dir_id, contentLength } = options
                
                        if (name && dir_id && (await this.isNameTaken({ name, dir_id }))) {
                Severity: Minor
                Found in core/remote/cozy.js - About 1 hr to fix

                  Function buildEvent has 31 lines of code (exceeds 25 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
                    Severity
                    Category
                    Status
                    Source
                    Language