redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

Remove unused components transitively

Open fb55 opened this issue 11 months ago • 1 comments

What/Why/How?

Removes components if their parent paths were removed. Loops until no more changes were made.

Reference

Fixes https://github.com/Redocly/redocly-cli/issues/874

Testing

Couldn't run tests in a GitHub Codespace, so opening a draft here for CI.

Check yourself

  • [ ] Code changed? - Tested with redoc/reference-docs/workflows (internal)
  • [ ] All new/updated code is covered with tests
  • [ ] New package installed? - Tested in different environments (browser/node)

Security

  • [ ] Security impact of change has been considered
  • [ ] Code follows company security practices and guidelines

fb55 avatar Mar 05 '24 18:03 fb55

🦋 Changeset detected

Latest commit: def381eb2db9c1250148c008608766b8d4f00410

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@redocly/openapi-core Patch
@redocly/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Mar 05 '24 18:03 changeset-bot[bot]

@tatomyr Please have a look! Tests are green, please let me know if anything else needs to happen to get this over the finish line.

fb55 avatar Mar 19 '24 13:03 fb55

@fb55 sure thing, will take a look!

tatomyr avatar Mar 19 '24 13:03 tatomyr

Thanks for the review, addressed all comments!

And one more thing. Whatever changes here should also apply to the corresponding rule no-unused-components.

Do you mean introducing the additional data structures for tracking where a component is used?

fb55 avatar Mar 22 '24 10:03 fb55

Do you mean introducing the additional data structures for tracking where a component is used?

Actually, at a second glance, I'm not sure we should apply the same logic in the rule itself... We're not removing transitive components but rather checking the current state.

Let me have another look.

tatomyr avatar Mar 22 '24 11:03 tatomyr

WIth the latest changes it doesn't seem to remove transitive references anymore 😅

Tests are passing, and the codebase I am looking at (~1000 auto-generated components with ~20% unused) is not showing any unused component errors after processing. But the reported number of removed components has gone down from ~220 to ~160 — not quite sure about what happened here.

fb55 avatar Mar 22 '24 12:03 fb55

Tests are passing

Indeed they are. Sorry, mixed up with different errors 🙂.

tatomyr avatar Mar 22 '24 12:03 tatomyr

@tatomyr Anything I can help with to make this move forward?

fb55 avatar Apr 02 '24 20:04 fb55

Realised there was a comment I had not addressed, just did so!

fb55 avatar Apr 02 '24 20:04 fb55

@tatomyr Thanks for shepherding this to the finish line!

fb55 avatar Apr 03 '24 07:04 fb55