dependency-cruiser 10.3.1-beta-2 → 10.3.1-beta-3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dependency-cruiser",
3
- "version": "10.3.1-beta-2",
3
+ "version": "10.3.1-beta-3",
4
4
  "description": "Validate and visualize dependencies. With your rules. JavaScript, TypeScript, CoffeeScript. ES6, CommonJS, AMD.",
5
5
  "keywords": [
6
6
  "static analysis",
@@ -1,5 +1,6 @@
1
1
  const bus = require("../utl/bus");
2
2
  const busLogLevels = require("../utl/bus-log-levels");
3
+ const isSameViolation = require("./summarize/is-same-violation");
3
4
 
4
5
  function softenModuleViolation(
5
6
  pRule,
@@ -19,25 +20,6 @@ function softenModuleViolation(
19
20
  };
20
21
  }
21
22
 
22
- function knownErrorMatchesViolation(pKnownError, pViolationKey) {
23
- if (pKnownError.rule.name === pViolationKey.rule.name) {
24
- if (pViolationKey.cycle && pKnownError.cycle) {
25
- return (
26
- pKnownError.cycle.length === pViolationKey.cycle.length &&
27
- pKnownError.cycle.every((pModule) =>
28
- pViolationKey.cycle.includes(pModule)
29
- )
30
- );
31
- } else {
32
- return (
33
- pKnownError.from === pViolationKey.from &&
34
- pKnownError.to === pViolationKey.to
35
- );
36
- }
37
- }
38
- return false;
39
- }
40
-
41
23
  function softenDependencyViolation(
42
24
  pViolationKey,
43
25
  pKnownDependencyViolations,
@@ -46,7 +28,7 @@ function softenDependencyViolation(
46
28
  return {
47
29
  ...pViolationKey.rule,
48
30
  severity: pKnownDependencyViolations.some((pKnownError) =>
49
- knownErrorMatchesViolation(pKnownError, pViolationKey)
31
+ isSameViolation(pKnownError, pViolationKey)
50
32
  )
51
33
  ? pSoftenedSeverity
52
34
  : pViolationKey.rule.severity,
@@ -0,0 +1,18 @@
1
+ module.exports = function isSameViolation(pLeftViolation, pRightViolation) {
2
+ let lReturnValue = false;
3
+
4
+ if (pLeftViolation.rule.name === pRightViolation.rule.name) {
5
+ if (pRightViolation.cycle && pLeftViolation.cycle) {
6
+ lReturnValue =
7
+ pLeftViolation.cycle.length === pRightViolation.cycle.length &&
8
+ pLeftViolation.cycle.every((pModule) =>
9
+ pRightViolation.cycle.includes(pModule)
10
+ );
11
+ } else {
12
+ lReturnValue =
13
+ pLeftViolation.from === pRightViolation.from &&
14
+ pLeftViolation.to === pRightViolation.to;
15
+ }
16
+ }
17
+ return lReturnValue;
18
+ };
@@ -1,8 +1,9 @@
1
1
  const _flattenDeep = require("lodash/flattenDeep");
2
2
  const _get = require("lodash/get");
3
+ const _uniqWith = require("lodash/uniqWith");
3
4
  const { findRuleByName } = require("../../graph-utl/rule-set");
4
5
  const compare = require("../../graph-utl/compare");
5
- const deDuplicateViolations = require("./de-duplicate-violations");
6
+ const isSameViolation = require("./is-same-violation");
6
7
 
7
8
  function cutNonTransgressions(pSourceEntry) {
8
9
  return {
@@ -129,10 +130,11 @@ function extractModuleViolations(pModules, pRuleSet) {
129
130
  }
130
131
 
131
132
  module.exports = function summarizeModules(pModules, pRuleSet) {
132
- const lViolations = deDuplicateViolations(
133
+ const lViolations = _uniqWith(
133
134
  extractDependencyViolations(pModules, pRuleSet)
134
135
  .concat(extractModuleViolations(pModules, pRuleSet))
135
- .sort(compare.violations)
136
+ .sort(compare.violations),
137
+ isSameViolation
136
138
  );
137
139
 
138
140
  return {
package/src/meta.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /* generated - don't edit */
2
2
 
3
3
  module.exports = {
4
- version: "10.3.1-beta-2",
4
+ version: "10.3.1-beta-3",
5
5
  engines: {
6
6
  node: "^12.20||^14||>=16",
7
7
  },
@@ -1,20 +0,0 @@
1
- const _uniqWith = require("lodash/uniqWith");
2
-
3
- function violationIsEqual(pLeftViolation, pRightViolation) {
4
- let lReturnValue = false;
5
- if (
6
- pLeftViolation.rule.name === pRightViolation.rule.name &&
7
- pLeftViolation.cycle
8
- ) {
9
- lReturnValue =
10
- pLeftViolation.cycle.length === pRightViolation.cycle.length &&
11
- pLeftViolation.cycle.every((pModuleName) =>
12
- pRightViolation.cycle.includes(pModuleName)
13
- );
14
- }
15
- return lReturnValue;
16
- }
17
-
18
- module.exports = function deDuplicateViolations(pViolations) {
19
- return _uniqWith(pViolations, violationIsEqual);
20
- };