bcherny / tslint-no-circular-imports

TSLint plugin to detect and warn about circular imports
MIT License
86 stars 12 forks source link

Prevent memory overflow on too heavily interconnected structures #32

Open richard-ejem opened 5 years ago

richard-ejem commented 5 years ago

Today I stumbled upon a problem when adding this rule to a quite large project with many circular imports. As number of possible cycles in a full graph grows exponentially, it is not difficult to get millions of cycles even on a graph with tens of nodes.

This PR adds a limit of analyzed cycles after which the linter stops and adds another failure message that there are too many potential cycles and some might've been omitted.

It shouldn't be a concern of usability, as if you get a bunch of lint errors, you fix some of them and then run the linter again, without that complex circular structure.

biolauri commented 5 years ago

I run into the same problem if I upgrade to any version greater than ^0.4.0, so this might also fix that regression.
With ^0.4.0, the lint rule runs smooth without any problems. After updating it (tested with 0.5.0, 0.6.2 and 0.7.0), it always fails with the same message as mention in https://github.com/bcherny/tslint-no-circular-imports/issues/33#issuecomment-472392988 (reproducible).