dependency-cruiser 16.10.3 → 16.10.4-beta-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configs/plugins/stats-reporter-plugin.mjs +1 -1
- package/package.json +1 -1
- package/src/enrich/derive/folders/utl.mjs +2 -2
- package/src/enrich/derive/module-utl.mjs +2 -2
- package/src/enrich/soften-known-violations.mjs +13 -10
- package/src/enrich/summarize/get-stats.mjs +2 -2
- package/src/enrich/summarize/is-same-violation.mjs +20 -8
- package/src/graph-utl/consolidate-to-folder.mjs +1 -1
- package/src/graph-utl/consolidate-to-pattern.mjs +3 -3
- package/src/graph-utl/strip-self-transitions.mjs +1 -1
- package/src/meta.cjs +1 -1
- package/src/report/utl/dependency-to-incidence-transformer.mjs +1 -1
- package/src/utl/find-all-files.mjs +4 -4
package/package.json
CHANGED
|
@@ -7,13 +7,13 @@ export function findFolderByName(pAllFolders, pName) {
|
|
|
7
7
|
|
|
8
8
|
export function getAfferentCouplings(pModule, pDirname) {
|
|
9
9
|
return pModule.dependents.filter(
|
|
10
|
-
(pDependent) => !pDependent.startsWith(pDirname.concat(sep))
|
|
10
|
+
(pDependent) => !pDependent.startsWith(pDirname.concat(sep)),
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export function getEfferentCouplings(pModule, pDirname) {
|
|
15
15
|
return pModule.dependencies.filter(
|
|
16
|
-
(pDependency) => !pDependency.resolved.startsWith(pDirname.concat(sep))
|
|
16
|
+
(pDependency) => !pDependency.resolved.startsWith(pDirname.concat(sep)),
|
|
17
17
|
);
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export function isDependent(pResolvedName) {
|
|
2
2
|
return (pModule) =>
|
|
3
3
|
pModule.dependencies.some(
|
|
4
|
-
(pDependency) => pDependency.resolved === pResolvedName
|
|
4
|
+
(pDependency) => pDependency.resolved === pResolvedName,
|
|
5
5
|
);
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -23,7 +23,7 @@ export function metricsAreCalculable(pModule) {
|
|
|
23
23
|
*/
|
|
24
24
|
export function calculateInstability(
|
|
25
25
|
pEfferentCouplingCount,
|
|
26
|
-
pAfferentCouplingCount
|
|
26
|
+
pAfferentCouplingCount,
|
|
27
27
|
) {
|
|
28
28
|
// when both afferentCouplings and efferentCouplings equal 0 instability will
|
|
29
29
|
// yield NaN. Judging Bob Martin's intention, a component with no outgoing
|
|
@@ -59,11 +59,12 @@ function softenDependencyViolations(
|
|
|
59
59
|
}
|
|
60
60
|
return pDependency;
|
|
61
61
|
}
|
|
62
|
+
|
|
62
63
|
/**
|
|
63
64
|
*
|
|
64
65
|
* @param {import("../../types/cruise-result.mjs").IModule} pModule
|
|
65
|
-
* @param {import("../../types/baseline-violations.
|
|
66
|
-
* @param {import("../../types/shared-types.
|
|
66
|
+
* @param {import("../../types/baseline-violations.mjs").IBaselineViolations} pKnownViolations
|
|
67
|
+
* @param {import("../../types/shared-types.mjs").SeverityType} pSoftenedSeverity
|
|
67
68
|
* @returns {import("../../types/cruise-result.mjs").IModule}
|
|
68
69
|
*/
|
|
69
70
|
function softenKnownViolation(pModule, pKnownViolations, pSoftenedSeverity) {
|
|
@@ -76,9 +77,8 @@ function softenKnownViolation(pModule, pKnownViolations, pSoftenedSeverity) {
|
|
|
76
77
|
softenModuleViolation(
|
|
77
78
|
pRule,
|
|
78
79
|
pModule.source,
|
|
79
|
-
pKnownViolations.filter(
|
|
80
|
-
(
|
|
81
|
-
pKnownError.from === pKnownError.to && !pKnownError.cycle,
|
|
80
|
+
pKnownViolations.filter((pKnownViolation) =>
|
|
81
|
+
["module", "reachability"].includes(pKnownViolation.type),
|
|
82
82
|
),
|
|
83
83
|
pSoftenedSeverity,
|
|
84
84
|
),
|
|
@@ -92,23 +92,26 @@ function softenKnownViolation(pModule, pKnownViolations, pSoftenedSeverity) {
|
|
|
92
92
|
softenDependencyViolations(
|
|
93
93
|
pDependency,
|
|
94
94
|
pModule.source,
|
|
95
|
-
pKnownViolations.filter(
|
|
96
|
-
(
|
|
97
|
-
pKnownError.from !== pKnownError.to || pKnownError.cycle,
|
|
95
|
+
pKnownViolations.filter((pKnownViolation) =>
|
|
96
|
+
["dependency", "cycle", "instability"].includes(pKnownViolation.type),
|
|
98
97
|
),
|
|
99
98
|
pSoftenedSeverity,
|
|
100
99
|
),
|
|
101
100
|
),
|
|
102
101
|
};
|
|
103
102
|
|
|
103
|
+
// TODO: folder level violations (e.g. with 'instability' rules - these need
|
|
104
|
+
// to be softened within the "folders" node, which lives next to the "modules"
|
|
105
|
+
// one)
|
|
106
|
+
|
|
104
107
|
return lReturnValue;
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
111
|
*
|
|
109
112
|
* @param {import("../../types/cruise-result.mjs").IModule[]} pModules
|
|
110
|
-
* @param {import("../../types/baseline-violations.
|
|
111
|
-
* @param {import("../../types/shared-types.
|
|
113
|
+
* @param {import("../../types/baseline-violations.mjs").IBaselineViolations} pKnownViolations
|
|
114
|
+
* @param {import("../../types/shared-types.mjs").SeverityType} pSoftenedSeverity
|
|
112
115
|
* @returns {import("../../types/cruise-result.mjs").IModule[]}
|
|
113
116
|
*/
|
|
114
117
|
export default function softenKnownViolations(
|
|
@@ -9,7 +9,7 @@ export function getViolationStats(pViolations) {
|
|
|
9
9
|
warn: 0,
|
|
10
10
|
info: 0,
|
|
11
11
|
ignore: 0,
|
|
12
|
-
}
|
|
12
|
+
},
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -20,6 +20,6 @@ export function getModulesCruised(pModules) {
|
|
|
20
20
|
export function getDependenciesCruised(pModules) {
|
|
21
21
|
return pModules.reduce(
|
|
22
22
|
(pAll, pModule) => pAll + pModule.dependencies.length,
|
|
23
|
-
0
|
|
23
|
+
0,
|
|
24
24
|
);
|
|
25
25
|
}
|
|
@@ -2,23 +2,35 @@ function pluckName({ name }) {
|
|
|
2
2
|
return name;
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
+
// eslint-disable-next-line complexity
|
|
5
6
|
export default function isSameViolation(pLeftViolation, pRightViolation) {
|
|
6
|
-
let lReturnValue = false;
|
|
7
|
-
|
|
8
7
|
if (pLeftViolation.rule.name === pRightViolation.rule.name) {
|
|
9
8
|
if (pRightViolation.cycle && pLeftViolation.cycle) {
|
|
10
|
-
|
|
9
|
+
return (
|
|
11
10
|
pLeftViolation.cycle.length === pRightViolation.cycle.length &&
|
|
12
11
|
pLeftViolation.cycle
|
|
13
12
|
.map(pluckName)
|
|
14
13
|
.every((pModule) =>
|
|
15
14
|
pRightViolation.cycle.map(pluckName).includes(pModule),
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
)
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
if (pRightViolation.via && pLeftViolation.via) {
|
|
19
|
+
return (
|
|
19
20
|
pLeftViolation.from === pRightViolation.from &&
|
|
20
|
-
pLeftViolation.to === pRightViolation.to
|
|
21
|
+
pLeftViolation.to === pRightViolation.to &&
|
|
22
|
+
pLeftViolation.via.length === pRightViolation.via.length &&
|
|
23
|
+
pLeftViolation.via
|
|
24
|
+
.map(pluckName)
|
|
25
|
+
.every((pModule) =>
|
|
26
|
+
pRightViolation.via.map(pluckName).includes(pModule),
|
|
27
|
+
)
|
|
28
|
+
);
|
|
21
29
|
}
|
|
30
|
+
return (
|
|
31
|
+
pLeftViolation.from === pRightViolation.from &&
|
|
32
|
+
pLeftViolation.to === pRightViolation.to
|
|
33
|
+
);
|
|
22
34
|
}
|
|
23
|
-
return
|
|
35
|
+
return false;
|
|
24
36
|
}
|
|
@@ -35,10 +35,10 @@ function squashModuleToPattern(pCollapsePattern) {
|
|
|
35
35
|
consolidated: determineConsolidatedness(
|
|
36
36
|
pModule.consolidated,
|
|
37
37
|
lCollapseMatch,
|
|
38
|
-
pModule.source
|
|
38
|
+
pModule.source,
|
|
39
39
|
),
|
|
40
40
|
dependencies: pModule.dependencies.map(
|
|
41
|
-
squashDependencyToPattern(pCollapsePattern)
|
|
41
|
+
squashDependencyToPattern(pCollapsePattern),
|
|
42
42
|
),
|
|
43
43
|
};
|
|
44
44
|
};
|
|
@@ -46,6 +46,6 @@ function squashModuleToPattern(pCollapsePattern) {
|
|
|
46
46
|
|
|
47
47
|
export default function consolidateToPattern(pModules, pCollapsePattern) {
|
|
48
48
|
return consolidateModules(
|
|
49
|
-
pModules.map(squashModuleToPattern(pCollapsePattern))
|
|
49
|
+
pModules.map(squashModuleToPattern(pCollapsePattern)),
|
|
50
50
|
).map(consolidateModuleDependencies);
|
|
51
51
|
}
|
package/src/meta.cjs
CHANGED
|
@@ -9,7 +9,7 @@ function compareOnSource(pOne, pTwo) {
|
|
|
9
9
|
function determineIncidenceType(pFromListEntry) {
|
|
10
10
|
return (pModule) => {
|
|
11
11
|
let lDependency = pModule.dependencies.find(
|
|
12
|
-
(pDependency) => pDependency.resolved === pFromListEntry.source
|
|
12
|
+
(pDependency) => pDependency.resolved === pFromListEntry.source,
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
if (lDependency) {
|
|
@@ -26,7 +26,7 @@ function fileIsDirectory(pFullPathToFile, pBaseDirectory) {
|
|
|
26
26
|
*/
|
|
27
27
|
function walk(
|
|
28
28
|
pDirectoryName,
|
|
29
|
-
{ baseDir, ignoreFilterFn, excludeFilterFn, includeOnlyFilterFn }
|
|
29
|
+
{ baseDir, ignoreFilterFn, excludeFilterFn, includeOnlyFilterFn },
|
|
30
30
|
) {
|
|
31
31
|
return readdirSync(join(baseDir, pDirectoryName))
|
|
32
32
|
.map((pFileName) => join(pDirectoryName, pFileName))
|
|
@@ -51,12 +51,12 @@ function walk(
|
|
|
51
51
|
ignoreFilterFn,
|
|
52
52
|
excludeFilterFn,
|
|
53
53
|
includeOnlyFilterFn,
|
|
54
|
-
})
|
|
54
|
+
}),
|
|
55
55
|
);
|
|
56
56
|
}
|
|
57
57
|
return pSum.concat(fullPathToFile);
|
|
58
58
|
},
|
|
59
|
-
[]
|
|
59
|
+
[],
|
|
60
60
|
)
|
|
61
61
|
.map((pFullPathToFile) => pathToPosix(pFullPathToFile));
|
|
62
62
|
}
|
|
@@ -90,7 +90,7 @@ export default function findAllFiles(
|
|
|
90
90
|
additionalIgnorePatterns,
|
|
91
91
|
excludeFilterFn,
|
|
92
92
|
includeOnlyFilterFn,
|
|
93
|
-
}
|
|
93
|
+
},
|
|
94
94
|
) {
|
|
95
95
|
const lIgnoreFileContents =
|
|
96
96
|
ignoreFileContents ?? readIgnoreFile(join(baseDir, ".gitignore"));
|