cozy-labs/cozy-desktop

View on GitHub

Showing 415 of 610 total issues

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

    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

      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

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

                  Function openOAuthView has 46 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                    async openOAuthView(url /*: string */) {
                      try {
                        // Open remote OAuth flow in separate view, without Node integration.
                        // This avoids giving access to Node's API to remote code and allows
                        // remote code to load and make use of jQuery since it can't be loaded via
                  Severity: Minor
                  Found in gui/js/onboarding.window.js - About 1 hr to fix

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

                    function squashMoves(changes /*: LocalChange[] */) {
                      log.trace('Squash moves...')
                      const stopMeasure = measureTime('LocalWatcher#squashMoves')
                    
                      for (let i = 0; i < changes.length; i++) {
                    Severity: Minor
                    Found in core/local/chokidar/analysis.js - About 1 hr to fix

                      Function doTrash has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                        async doTrash(
                          side /*: SideName */,
                          was /*: SavedMetadata */,
                          doc /*: Metadata */
                        ) /*: Promise<void> */ {
                      Severity: Minor
                      Found in core/merge.js - About 1 hr to fix

                        Function waitForNewChangeOn has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async waitForNewChangeOn(seq /*: number */, expectedPath /*: string */) {
                            log.debug({ path: expectedPath }, 'Waiting for new change to be merged')
                        
                            return new Promise((resolve, reject) => {
                              const opts = {
                        Severity: Minor
                        Found in core/sync/index.js - About 1 hr to fix

                          Function setup has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                            async setup() {
                              const clientInfo = this.clientInfo()
                              log.info(clientInfo, 'user config')
                          
                              if (!this.config.isValid()) {
                          Severity: Minor
                          Found in core/app.js - About 1 hr to fix

                            Function setupDesktop has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const setupDesktop = async () => {
                              try {
                                // TODO: allow setting desktop up without running migrations (when opening
                                // a cozy-note)?
                                await desktop.setup()
                            Severity: Minor
                            Found in gui/main.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

                            Severity
                            Category
                            Status
                            Source
                            Language