-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔧 separates circularity algorithm better
- the algorithm is now in a module without the stuff that adds its results to the dependency tree - this means it's easier to unit test & hence safely refactor - adds unit tests
- Loading branch information
Showing
11 changed files
with
241 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
instrumentation: | ||
excludes: ["test/**/*", "src/cli/index.js", "coverage/**/*", "tmp*", "utl/**/*"] | ||
excludes: ["test/**/*", "src/cli/index.js", "src/report/*.template.js", "coverage/**/*", "tmp*", "utl/**/*"] | ||
include-all-sources: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
-201 Bytes
(100%)
doc/real-world-samples/dependency-cruiser-without-node_modules.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Returns true if the graph behind pTo contains pFrom. | ||
* Returns false in all other cases | ||
* | ||
* @param {object} pGraph The graph in which to test this condition | ||
* @param {string} pFrom The 'source' attribute of the node to be tested | ||
* (source uniquely identifying a node) | ||
* @param {string} pTo The 'source' attribute of the 'to' node to | ||
* be traversed | ||
* @param {Set} pVisited The set of nodes visited hithereto (optional | ||
* attribute - there's no need to pass it when | ||
* calling it; it's used by the algorithm to | ||
* determine the stop condition) | ||
* @return {boolean} see description above | ||
*/ | ||
function dependencyEndsUpAtFrom(pGraph, pFrom, pTo, pVisited) { | ||
pVisited = pVisited || new Set(); | ||
|
||
const lToNode = pGraph.filter(pNode => pNode.source === pTo)[0]; | ||
|
||
/* about the absence of checks whether attributes/ objects actually | ||
* exist: | ||
* - it saves CPU cycles to the effect of being ~30% faster than with the | ||
* checks | ||
* - lToNode: is guaranteed to be there by the extract/ complete in index.js | ||
* - lToNode.dependencies is a mandatory attribute (as per json schema) | ||
* - pToToNode.resolved is a mandatory attribute (as per json schema) | ||
*/ | ||
return lToNode.dependencies.filter( | ||
pToToNode => !pVisited.has(pToToNode.resolved) | ||
).some( | ||
pToToNode => | ||
pToToNode.resolved === pFrom | ||
? true | ||
: dependencyEndsUpAtFrom( | ||
pGraph, | ||
pFrom, | ||
pToToNode.resolved, | ||
pVisited.add(pToToNode.resolved) | ||
) | ||
); | ||
} | ||
|
||
module.exports = dependencyEndsUpAtFrom; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.