-
Notifications
You must be signed in to change notification settings - Fork 256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature request: Do not perform unnecessary analysis #978
Comments
Hi @JavaScriptBach yup - we had this at one point in the history of dependency-cruiser, but decided to remove it for simplicity's sake. Most instance of dependency-cruiser would have configuration that'd include cycles and/ or dependents anyway, and the overhead was manageable in the monorepos I ran this on (granted, 'only' 17k files/ 65k dependencies, but cycle detection takes 2.4s there (6% of the total run time)). That said, it is possible to bring this back. It'll need some thought to ensure this is won't be a breaking change. Let's save some time (and trees). |
Hi again @JavaScriptBach - I've just published [email protected] to npmjs. It implements an option that, when switched to Add |
@sverweij Thanks for the prompt implementation! It's working fine on my simple example and has reduced the runtime from 7m28s to 1m23s. |
## Description - adds a `skipAnalysisNotInRules` option that, when switched to `true` skips all analyses not necessary for checking the current rule set. - Defaults the option to `false` for backwards compatibility of both cli and api. - Add this option with the value `true` to the --init template that scaffolds initial .dependency-cruiser.js configurations - Takes the new option into account in the cache-dirty check - Adds a paragraph in the options reference TODO: - [x] implement for cycle analysis - [x] implement for dependents analysis - [x] implement for orphan check For the _focus_, _metrics_ and _reachables_ analyses this was already in place by default ## Motivation and Context Addresses #978 ## How Has This Been Tested? - [x] green ci - [x] additional and updated automated non-regression tests ## Types of changes - [ ] Bug fix (non-breaking change which fixes an issue) - [ ] Documentation only change - [ ] Refactor (non-breaking change which fixes an issue without changing functionality) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change)
Context
I have a Typescript mono-repo with ~30,000 files and would like to write dependency tests of the form "assert there is no dependency path between file A and file B". e.g. a test like this:
I'm using depcruise 16.8.0. I've also followed some of the performance advice in #590, e.g. I've limited the module systems and the set of extensions to resolve.
Expected Behavior
depcruise
runs quickly and evaluates the rules correctly.Current Behavior
Depcruise takes 7m28s to run on my mono-repo.
Possible Solution
Can we avoid performing unnecessary analysis if the user did not specify any rules that require them? In my use case, I would not expect depcruise to have to analyze "cycles" or "dependents" in order to tell me if a path exists from file A to file B, both of which I provide. This would reduce the runtime by ~80%.
Considered alternatives
N/A
The text was updated successfully, but these errors were encountered: