eg/show-paths.cjs.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1.5

Size

Lines of Code 23
Function Count 2

Duplication

Duplicated Lines 23
Ratio 100 %

Importance

Changes 0
Metric Value
wmc 3
eloc 15
mnd 1
bc 1
fnc 2
dl 23
loc 23
rs 10
bpm 0.5
cpm 1.5
noi 1
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A show-paths.cjs.js ➔ objectEntries 9 9 3

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
/* eslint-env es6, node */
2 View Code Duplication
'use strict';
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
3
4
const osPaths = require('../dist/cjs/mod.cjs.js');
5
6
/* eslint-disable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf */
7
8
function objectEntries(obj) {
9
	const map = {};
10
	Object.keys(obj).forEach((key) => {
11
		const value = obj[key];
12
		const val = typeof value === 'function' ? value() : value;
13
		map[key] = val;
14
	});
15
	return map;
16
}
17
18
console.log({ osPaths });
0 ignored issues
show
Debugging Code introduced by
console.log looks like debug code. Are you sure you do not want to remove it?
Loading history...
19
console.log(objectEntries(osPaths));
20
console.log('home() =', osPaths.home());
21
console.log('temp() =', osPaths.temp());
22
23
process.env.TMPDIR = process.env.TEMP = process.env.TMP = 'temp';
24
console.log(objectEntries(osPaths));
25
26
/* eslint-enable no-console, functional/immutable-data , security/detect-object-injection , security-node/detect-crlf */
27