cozy-labs/cozy-desktop

View on GitHub

Showing 615 of 615 total issues

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

  for (const field of fields) {
    if (remoteFile[field]) {
      doc[field] = _.cloneDeep(remoteFile[field])
    }
  }
Severity: Minor
Found in core/metadata.js and 1 other location - About 35 mins to fix
core/metadata.js on lines 284..288

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

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

  for (const field of fields) {
    if (remoteDir[field]) {
      doc[field] = _.cloneDeep(remoteDir[field])
    }
  }
Severity: Minor
Found in core/metadata.js and 1 other location - About 35 mins to fix
core/metadata.js on lines 318..322

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

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

  (session /*: Session */) => async (reqUrl /*: string */) => {
    log.info('getProxyForUrl', { reqUrl })
    const proxy = await session.resolveProxy(reqUrl)
    if (!proxy) {
      return ''
Severity: Minor
Found in gui/js/network/agent.js - About 35 mins 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 showRevokedCozyError has a Cognitive Complexity of 7 (exceeds 5 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 35 mins 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 addFileAsync has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async addFileAsync(side /*: SideName */, doc /*: Metadata */) {
    log.debug('addFileAsync', { path: doc.path })
    const file /*: ?SavedMetadata */ = await this.pouch.bySyncedPath(doc.path)

    if (file) {
Severity: Minor
Found in core/merge.js - About 35 mins 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 invariants has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function invariants /*:: <T: Metadata|SavedMetadata> */(doc /*: T */) {
  // If the record is meant to be erased we don't care about invariants
  if (doc._deleted) return doc

  let err
Severity: Minor
Found in core/metadata.js - About 35 mins 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 default has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

exports.default = async function (configuration) {
  if (process.env.SKIP_CODE_SIGNING === 'True') {
    // eslint-disable-next-line no-console
    console.log('Skipping code signing')
    return
Severity: Minor
Found in build/windows/customSign.js - About 35 mins 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 detectSingleSide has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function detectSingleSide(doc /*: Metadata */) /*: ?SideName */ {
  if (doc.sides) {
    for (const sideName of SIDE_NAMES) {
      if (doc.sides[sideName] && !doc.sides[otherSide(sideName)]) {
        return sideName
Severity: Minor
Found in core/metadata.js - About 35 mins 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 fileMoveFromUnlinkAdd has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function fileMoveFromUnlinkAdd(
  sameInodeChange /*: ?LocalChange */,
  e /*: LocalFileAdded */
) /*: * */ {
  const unlinkChange /*: ?LocalFileDeletion */ =
Severity: Minor
Found in core/local/chokidar/local_change.js - About 35 mins 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 put has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  put(c /*: LocalChange */, updated /*: ?boolean */) {
    if (updated) {
      for (const [k, v] of this.changesByPath) {
        if (v == c) {
          this.changesByPath.delete(k)
Severity: Minor
Found in core/local/chokidar/analysis.js - About 35 mins 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 squashMoves has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const squashMoves = (
  doc /*: Metadata */,
  was /*: SavedMetadata */,
  previousChanges /*: RemoteChange[] */,
  encounteredMoves /*: Array<RemoteDirMove|RemoteDescendantChange> */
Severity: Minor
Found in core/remote/watcher/squashMoves.js - About 35 mins 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 requestRun has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async requestRun() {
    if (!this.running) {
      log.debug('Watcher stopped: skipping remote watcher run request')
      return
    }
Severity: Minor
Found in core/remote/watcher/index.js - About 35 mins 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 detectOfflineUnlinkEvents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const detectOfflineUnlinkEvents = async (
  initialScanParams /*: InitialScanParams */,
  pouch /*: Pouch */
) /*: Promise<{offlineEvents: Array<ChokidarEvent>, unappliedMoves: string[], emptySyncDir: boolean}> */ => {
  // Try to detect removed files & folders
Severity: Minor
Found in core/local/chokidar/initial_scan.js - About 35 mins 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 findChildrenMoves has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const findChildrenMoves = (
  change /*: RemoteDirMove|RemoteDescendantChange */,
  originalChange /*: ?RemoteDirMove|RemoteDescendantChange */,
  previousChanges /*: RemoteChange[] */
) /*: Array<RemoteFileMove|RemoteDirMove> */ => {
Severity: Minor
Found in core/remote/watcher/squashMoves.js - About 35 mins 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 runMigrations has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function runMigrations(
  migrations /*: Migration[] */,
  { pouch, remote } /*: InjectedDependencies */
) {
  log.info('Running migrations...')
Severity: Minor
Found in core/migrations/index.js - About 35 mins 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 aggregateEvents has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function aggregateEvents(oldEvent, recentEvent) {
  if (recentEvent.action === 'deleted') {
    if (oldEvent.action === 'created') {
      // It's just a temporary file that we can ignore
      log.debug(
Severity: Minor
Found in core/local/channel_watcher/await_write_finish.js - About 35 mins 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 getNextChanges has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  async getNextChanges(seq /*: number */) /*: Promise<Change[]> */ {
    const stopMeasure = measureTime('Sync#getNextChanges')
    const opts = {
      ...this.baseChangeOptions(seq),
      include_docs: true,
Severity: Minor
Found in core/sync/index.js - About 35 mins 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 begin has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

  begin(endState /*: 'start' | 'stop' */) {
    switch (endState) {
      case 'start':
        if (this.canTransitionTo('will-start')) {
          this.transitionTo('will-start')
Severity: Minor
Found in core/utils/lifecycle.js - About 35 mins 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 findDeletedEvent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const findDeletedEvent = (path, state) => {
  if (state.deletedEventsByPath.has(path)) {
    return state.deletedEventsByPath.get(path)
  } else {
    for (const pending of state.pendingBatches) {
Severity: Minor
Found in core/local/channel_watcher/overwrite.js - About 35 mins 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 7 (exceeds 5 allowed). Consider refactoring.
Open

const wrapError = (
  err /*: ErrnoError|FetchError|Error */,
  sideName /*: SideName */,
  { doc } /*: { doc: SavedMetadata } */ = {}
) => {
Severity: Minor
Found in core/sync/errors.js - About 35 mins 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