Showing 5 of 17 total issues
Function use
has 204 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function use(fsLibrary: any, seedFiles?: string[]): any { //NOSONAR
const { existsSync, lstatSync, chmodSync, renameSync, readFileSync, copySync, removeSync, ensureFileSync, outputFileSync, mkdirpSync, seedFile } = fsLibrary;
if (seedFile !== undefined && seedFiles !== undefined) {
for (const file of seedFiles) {
File fsHelpers.spec.ts
has 475 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import fsh from '../src/index';
import path from 'path';
import { beforeEach, afterEach, describe, it, expect, vi } from 'vitest';
// create all test directories and files inside one root directory for easy cleanup
Function use
has a Cognitive Complexity of 33 (exceeds 5 allowed). Consider refactoring. Open
Open
function use(fsLibrary: any, seedFiles?: string[]): any { //NOSONAR
const { existsSync, lstatSync, chmodSync, renameSync, readFileSync, copySync, removeSync, ensureFileSync, outputFileSync, mkdirpSync, seedFile } = fsLibrary;
if (seedFile !== undefined && seedFiles !== undefined) {
for (const file of seedFiles) {
- 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 lstatSync
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
Open
function lstatSync(filePath: fs.PathLike, _options?: fs.StatOptions & { bigint?: false }): fs.Stats {
const [ type, _data ] = mockFileSystem.get(filePath as string) || ['',''];
const retVal = {
isDirectory: () => filePath === path.resolve(`.`) ? true : type === 'dir',
isFile: () => mockFileSystem.has(filePath as string) && type === 'file',
Function mkdirpSync
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
Open
function mkdirpSync(dir: string): any {
if (lstatSync(dir).isFile()) throw Error('file exists at destination');
let first = undefined;
const dirs = dir.split(path.resolve(`.`)).join('').split(path.sep);
for (let i = 0; i < dirs.length; i++){
- 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"