cozy-labs/cozy-desktop

View on GitHub

Showing 610 of 610 total issues

Function stop has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  async stop(force /*: ?bool */ = false) {
    log.debug('Stopping watcher...')

    if (!this.watcher) return

Severity: Minor
Found in core/local/chokidar/watcher.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 apply has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  async apply(change /*: Change */) /*: Promise<void> */ {
    let stopMeasure = () => {}
    try {
      this.events.emit('sync-current', change.seq)

Severity: Minor
Found in core/sync/index.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 isIgnored has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

  isIgnored(
    { relativePath, isFolder } /*: {relativePath: string, isFolder: boolean} */
  ) /*: boolean */ {
    let result = false
    for (let pattern of Array.from(this.patterns)) {
Severity: Minor
Found in core/ignore.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 retry has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const retry = async (
  cause /*: {| err: RemoteError |} | {| err: SyncError, change: Change |} */,
  sync /*: Sync */
) => {
  log.debug(cause, 'retrying after blocking error')
Severity: Minor
Found in core/sync/errors.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 match has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

function match(
  path /*: string */,
  isFolder /*: boolean */,
  pattern /*: IgnorePattern */
) /*: boolean */ {
Severity: Minor
Found in core/ignore.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 setupInitialState has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const setupInitialState = (scenario /*: Scenario */) => {
  if (scenario.init == null) return
  debug('[init]')
  return Promise.each(scenario.init, opts => {
    let { ino, path: relpath, content } = opts
Severity: Minor
Found in dev/capture/local.js - About 1 hr to fix

    Function getSession has 27 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const getSession = (
      session /*: Session */,
      userAgent /*: string */
    ) /*: Session */ => {
      const syncSession = session.fromPartition(SESSION_PARTITION_NAME, {
    Severity: Minor
    Found in gui/js/network/index.js - About 1 hr to fix

      Function placeWithTray has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        placeWithTray(
          wantedWidth /*: number */,
          wantedHeight /*: number */,
          trayposition /*: Bounds */
        ) {
      Severity: Minor
      Found in gui/js/tray.window.js - About 1 hr to fix

        Function fromRemoteFile has 27 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        function fromRemoteFile(remoteFile /*: MetadataRemoteFile */) /*: Metadata */ {
          const doc /*: Object */ = {
            docType: localDocType(remoteFile.type),
            path: pathUtils.remoteToLocal(remoteFile.path),
            size: parseInt(remoteFile.size, 10),
        Severity: Minor
        Found in core/metadata.js - About 1 hr to fix

          Function includeAddEventInFileMove has 27 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function includeAddEventInFileMove(
            sameInodeChange /*: ?LocalChange */,
            e /*: LocalFileAdded */
          ) {
            const moveChange /*: ?LocalFileMove */ = maybeMoveFile(sameInodeChange)
          Severity: Minor
          Found in core/local/chokidar/local_change.js - About 1 hr to fix

            Function trashAsync has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              async trashAsync(doc /*: SavedMetadata */) /*: Promise<void> */ {
                log.info({ path: doc.path }, 'Moving to the OS trash...')
                const fullpath = path.join(this.syncPath, doc.path)
                try {
                  await this.sendToTrash(fullpath)
            Severity: Minor
            Found in core/local/index.js - About 1 hr to fix

              Function buildPattern has 27 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              function buildPattern(line /*: string */) /*: IgnorePattern */ {
                let folder = false
                let negate = false
                let noslash = line.indexOf('/') === -1
                if (line.indexOf('**') !== -1) {
              Severity: Minor
              Found in core/ignore.js - About 1 hr to fix

                Function moveFileAsync has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                  async moveFileAsync(
                    side /*: SideName */,
                    doc /*: Metadata */,
                    was /*: SavedMetadata */
                  ) {
                Severity: Minor
                Found in core/prep.js - About 1 hr to fix

                  Function init has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  const init = (app, listener) => {
                    tray = new Tray(nativeImage.createEmpty())
                  
                    // XXX: updating the status should always come after the initialization of the
                    // `tray` as we use it.
                  Severity: Minor
                  Found in gui/js/tray.js - About 1 hr to fix

                    Function debounce has 26 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) {
                          continue
                    Severity: Minor
                    Found in core/local/channel_watcher/initial_diff.js - About 1 hr to fix

                      Function rebuildIncompleteEvent has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      async function rebuildIncompleteEvent(
                        previousEvent /*: ChannelEvent */,
                        nextEvent /*: ChannelEvent */,
                        opts /*: { config: Config , checksumer: Checksumer, pouch: Pouch } */
                      ) /*: Promise<Completion> */ {
                      Severity: Minor
                      Found in core/local/channel_watcher/incomplete_fixer.js - About 1 hr to fix

                        Function uploadFileToSupport has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                          async uploadFileToSupport(
                            incident /*: string */,
                            name /*: string */,
                            data /*: string|stream.Readable */
                          ) {
                        Severity: Minor
                        Found in core/app.js - About 1 hr to fix

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

                            if (type === 'folder') {
                              const dirNameMaxBytes = detectDirNameLengthIncompatibility(
                                name,
                                restrictions
                              )
                          Severity: Major
                          Found in core/incompatibilities/platform.js and 1 other location - About 1 hr to fix
                          core/incompatibilities/platform.js on lines 275..280

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

                          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 (order < 0) {
                                  // node should come first
                                  newNode.dependentOn.push(node)
                          
                                  if (createsCycle(newNode)) {
                          Severity: Major
                          Found in core/sync/dependency_graph.js and 1 other location - About 1 hr to fix
                          core/sync/dependency_graph.js on lines 138..152

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

                          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 (e.type === 'unlinkDir' && e.old && e.old.docType === metadata.FILE) {
                                  log.warn(
                                    { event: e, old: e.old, path: e.path },
                                    'chokidar miscategorized event (was file, event unlinkDir)'
                                  )
                          Severity: Major
                          Found in core/local/chokidar/analysis.js and 1 other location - About 1 hr to fix
                          core/local/chokidar/analysis.js on lines 163..170

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

                          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