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

Complexity

Total Complexity 3
Complexity/F 1.5

Size

Lines of Code 24
Function Count 2

Duplication

Duplicated Lines 24
Ratio 100 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A show-paths.dynamic.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
// eslint-disable-next-line security-node/detect-non-literal-require-calls , security/detect-non-literal-require
5
const osPaths = require('../' + require('../package.json').main);
6
7
/* eslint-disable no-console , functional/immutable-data , security/detect-object-injection, security-node/detect-crlf */
8
9
function objectEntries(obj) {
10
	const map = {};
11
	Object.keys(obj).forEach((key) => {
12
		const value = obj[key];
13
		const val = typeof value === 'function' ? value() : value;
14
		map[key] = val;
15
	});
16
	return map;
17
}
18
19
console.log({ osPaths });
20
console.log(objectEntries(osPaths));
21
console.log('home() =', osPaths.home());
22
console.log('temp() =', osPaths.temp());
23
24
process.env.TMPDIR = process.env.TEMP = process.env.TMP = 'temp';
25
console.log(objectEntries(osPaths));
26
27
/* eslint-enable no-console, functional/immutable-data , security/detect-object-injection , security-node/detect-crlf */
28