Skip to content

Add circular dependency detection to CI #1346

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

Closed

Conversation

mtrezza
Copy link
Member

@mtrezza mtrezza commented Apr 14, 2021

Adds check to CI that fails on circular dependencies.

Analogous to parse-community/parse-server#7316.

Current circular dependencies that need to be fixed to make the test pass:

✖ Found 38 circular dependencies!

1) CoreManager.js > ObjectStateMutations.js > ParseFile.js
2) CoreManager.js > ObjectStateMutations.js > ParseObject.js
3) CoreManager.js > ObjectStateMutations.js > ParseObject.js > EventuallyQueue.js
4) ParseObject.js > EventuallyQueue.js
5) CoreManager.js > ObjectStateMutations.js > ParseObject.js > EventuallyQueue.js > ParseQuery.js
6) CoreManager.js > ObjectStateMutations.js > ParseObject.js > EventuallyQueue.js > ParseQuery.js > LiveQuerySubscription.js
7) ObjectStateMutations.js > ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseRole.js
8) ParseACL.js > ParseRole.js
9) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseRole.js
10) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseRole.js > ParseRelation.js
11) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseRole.js > ParseRelation.js > ParseOp.js
12) ParseRelation.js > ParseOp.js
13) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseRole.js > ParseRelation.js > ParseOp.js > arrayContainsObject.js
14) decode.js > ParseACL.js > ParseRole.js > ParseRelation.js > ParseOp.js
15) ParseACL.js > ParseRole.js > ParseRelation.js > ParseOp.js > encode.js
16) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseRole.js > ParseRelation.js > ParseOp.js > encode.js
17) ParseOp.js > encode.js
18) ParseRelation.js > ParseOp.js > encode.js
19) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseRole.js > ParseRelation.js > ParseOp.js > unique.js
20) ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseRole.js > ParseRelation.js
21) CoreManager.js > ObjectStateMutations.js > ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseUser.js
22) ObjectStateMutations.js > ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseUser.js
23) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseUser.js
24) CoreManager.js > ObjectStateMutations.js > ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseUser.js > ParseSession.js
25) ObjectStateMutations.js > ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseUser.js > ParseSession.js
26) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseUser.js > ParseSession.js
27) ParseUser.js > ParseSession.js
28) CoreManager.js > ObjectStateMutations.js > ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseUser.js > Storage.js
29) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js
30) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > equals.js
31) ParseObject.js > EventuallyQueue.js > ParseQuery.js
32) ObjectStateMutations.js > ParseObject.js
33) ObjectStateMutations.js > ParseObject.js > SingleInstanceStateController.js
34) ObjectStateMutations.js > ParseObject.js > UniqueInstanceStateController.js
35) ParseObject.js > UniqueInstanceStateController.js
36) ParseObject.js > canBeSerialized.js
37) ParseObject.js > unsavedChildren.js
38) CoreManager.js > Push.js

@ghost
Copy link

ghost commented Apr 14, 2021

Warnings
⚠️ Please add a changelog entry for your changes.

Generated by 🚫 dangerJS

@codecov
Copy link

codecov bot commented Apr 14, 2021

Codecov Report

Merging #1346 (a55aa8b) into master (f92e78f) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1346   +/-   ##
=======================================
  Coverage   99.10%   99.10%           
=======================================
  Files          61       61           
  Lines        5933     5933           
  Branches     1347     1347           
=======================================
  Hits         5880     5880           
  Misses         52       52           
  Partials        1        1           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f92e78f...a55aa8b. Read the comment docs.

@mtrezza mtrezza marked this pull request as draft April 14, 2021 15:02
@dplewis
Copy link
Member

dplewis commented May 7, 2021

@mtrezza You can create a .madgerc with the following to ignore the import type from flow. This will show us the real circular dependencies

{
  "detectiveOptions": {
    "ts": {
      "skipTypeImports": true
    }
  }
}

@mtrezza mtrezza force-pushed the add-circular-dependency-ci-check branch from e68dbe0 to f3cfa6b Compare May 10, 2021 19:53
@mtrezza
Copy link
Member Author

mtrezza commented May 10, 2021

@dplewis I added this (for es6, not ts), and it shows 20 circular dep now, which is indeed fewer.

EventuallyQueue seems to cause the majority, so once that is fixed it should be only a handful left.

✖ Found 20 circular dependencies!

1) ParseObject.js > EventuallyQueue.js
2) ParseACL.js > ParseRole.js
3) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js > ParseRole.js
4) ParseUser.js > ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseACL.js
5) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js
6) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseOp.js
7) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseOp.js > ParseRelation.js
8) ParseOp.js > ParseRelation.js
9) ParseQuery.js > OfflineQuery.js > decode.js > ParseOp.js > ParseRelation.js
10) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseOp.js > arrayContainsObject.js
11) decode.js > ParseOp.js
12) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseOp.js > encode.js
13) ParseOp.js > encode.js
14) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > decode.js > ParseOp.js > unique.js
15) ParseObject.js > EventuallyQueue.js > ParseQuery.js > OfflineQuery.js > equals.js
16) ParseObject.js > EventuallyQueue.js > ParseQuery.js
17) ParseObject.js > SingleInstanceStateController.js > ObjectStateMutations.js
18) ParseObject.js > canBeSerialized.js
19) ParseObject.js > unsavedChildren.js
20) ParseUser.js > ParseSession.js

@dplewis
Copy link
Member

dplewis commented May 10, 2021

Any tips / ideas on how to fixed these?

@mtrezza
Copy link
Member Author

mtrezza commented May 11, 2021

The same way I fixed them for Parse Server: think what a sensical dependency tree should look like and refactor accordingly.

You want to identify the foundational building blocks of the SDK, which have (or should have) 0 dependencies on other blocks, and work your way up the branches. Always considering that your want to maintain a hierarchical structure. Any dependency that violates that hierarchy needs to be corrected through refactoring.

However it seems that there are still type references that are incorrectly detected as circular dep, like Op in 13) ParseOp.js > encode.js. This could maybe be solved by simply refactoring the import statement.

@mtrezza mtrezza closed this Oct 26, 2021
@mtrezza mtrezza deleted the add-circular-dependency-ci-check branch October 26, 2021 17:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants