private-dreamnet/dreamtime

View on GitHub
src/electron/src/modules/tools/fs.js

Summary

Maintainability
D
1 day
Test Coverage

File fs.js has 321 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import {
  attempt, startsWith, merge, endsWith, toNumber,
} from 'lodash'
import { join } from 'path'
import fs from 'fs-extra'
Severity: Minor
Found in src/electron/src/modules/tools/fs.js - About 3 hrs to fix

    Function downloadFromIPFS has 78 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    export async function downloadFromIPFS(cid, options, events, writeStream) {
      /** @type {import('ipfsd-ctl/src/ipfsd-daemon')} */
      let node
      let stats
      let readStream
    Severity: Major
    Found in src/electron/src/modules/tools/fs.js - About 3 hrs to fix

      Function download has 60 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function download(url, options = {}) {
        const events = new EventEmitter()
      
        let cancelled = false
      
      
      Severity: Major
      Found in src/electron/src/modules/tools/fs.js - About 2 hrs to fix

        Function downloadFromTorrent has 48 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function downloadFromTorrent(magnetURI, options, events, writeStream) {
          let client
          let torrent
        
          // Error handler
        Severity: Minor
        Found in src/electron/src/modules/tools/fs.js - About 1 hr to fix

          Function downloadFromHttp has 34 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export async function downloadFromHttp(url, options, events, writeStream) {
            let readStream
            let headers
          
            try {
          Severity: Minor
          Found in src/electron/src/modules/tools/fs.js - About 1 hr to fix

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

            export function extractSeven(path, destinationPath) {
              const { is, platform } = require('electron-util')
              const { extractFull } = require('node-7z')
            
              const def = deferred()
            Severity: Minor
            Found in src/electron/src/modules/tools/fs.js - About 1 hr to fix

              Function download has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

              export function download(url, options = {}) {
                const events = new EventEmitter()
              
                let cancelled = false
              
              
              Severity: Minor
              Found in src/electron/src/modules/tools/fs.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 downloadFromIPFS has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export async function downloadFromIPFS(cid, options, events, writeStream) {
                /** @type {import('ipfsd-ctl/src/ipfsd-daemon')} */
                let node
                let stats
                let readStream
              Severity: Minor
              Found in src/electron/src/modules/tools/fs.js - About 25 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

              There are no issues that match your filters.

              Category
              Status