src/electron/src/modules/tools/fs.js
File fs.js
has 321 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import {
attempt, startsWith, merge, endsWith, toNumber,
} from 'lodash'
import { join } from 'path'
import fs from 'fs-extra'
Function downloadFromIPFS
has 78 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function downloadFromIPFS(cid, options, events, writeStream) {
/** @type {import('ipfsd-ctl/src/ipfsd-daemon')} */
let node
let stats
let readStream
Function download
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function download(url, options = {}) {
const events = new EventEmitter()
let cancelled = false
Function downloadFromTorrent
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function downloadFromTorrent(magnetURI, options, events, writeStream) {
let client
let torrent
// Error handler
Function downloadFromHttp
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export async function downloadFromHttp(url, options, events, writeStream) {
let readStream
let headers
try {
Function extractSeven
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
export function extractSeven(path, destinationPath) {
const { is, platform } = require('electron-util')
const { extractFull } = require('node-7z')
const def = deferred()
Function download
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
Open
export function download(url, options = {}) {
const events = new EventEmitter()
let cancelled = false
- Read upRead up
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
Open
export async function downloadFromIPFS(cid, options, events, writeStream) {
/** @type {import('ipfsd-ctl/src/ipfsd-daemon')} */
let node
let stats
let readStream
- Read upRead up
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"