dart-code-checker/dart-code-metrics

[Change request] Holistic project support

oravecz opened this issue · 4 comments

DCM version

v5.5.1

What problem do you want to solve?

DCM currently analyzes a pubspec as standalone, and doesn't consider transitive packages, especially those which are present within a packages folder in the project itself.

This results is metrics surrounding unused code/files etc. to be misleading. Any public APIs or components exposed by the package are regular used by consuming packages, not the package where it is created.

What do you think is the correct solution?

I'd like DCM to navigate packages which are not located in the pub cache, such as following a path dependency or perhaps a github dependency prior to determining if code or a file is unused.

Participation

  • I am willing to submit a pull request for this change.

Additional comments

No response

Have you tried --monorepo flag for unused code / files plus calling the command from the packages/ folder?

In my project I use a packages folder for feature development. This permits me some type of monorepo structure where different teams can be responsible for their own feature sets, but these packages are not intended on being deployed to a public (or internal) pub.dev repository. It's just an code/team-organization concept.

I would like to scan the project as a whole, and identify any widgets, extensions, or functions which are unused across the application as a whole. Not per package.

Edit: Another way of thinking about it is, I would like to know what tree shaking will remove from my project.

So that's exactly what I'm suggesting you to do: if you run check-unused-code packages/ --monorepo it should give you exactly what you're looking for.

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this issue for now. Please don't hesitate to comment on the issue if you have any more information for us; we will reopen it right away! Thanks for your contribution!