bazel-contrib / SIG-rules-authors

Governance and admin for the rules authors Special Interest Group
https://bazel-contrib.github.io/SIG-rules-authors/
Apache License 2.0
28 stars 12 forks source link

Create bazel-contrib/unused-deps #72

Closed keithl-stripe closed 1 year ago

keithl-stripe commented 1 year ago

(see Slack thread)

We'd like to open-source unused-deps, a command-line tool for finding Bazel dependencies which are not actually used in code. (details) Nick Korostelev from Snapchat suggested we submit it to bazel-contrib, and it seems like a good fit!

Must use an open-source license, preferably Apache-2.0.

We would prefer to use MIT if possible.

Must have wide applicability in the community.

After our BazelCon 2022 talk, about 10 people at various companies have reached out (Snapchat, Roku, etc.) asking us to open-source the tool.

It is useful to most Bazel users who use Java.

Must have a clear point of contact who answers questions from the SIG.

Happy to be that person!

Must be “production quality”: clear README or other documentation outlining the goal of these rules, how to use them etc.

While we don't have a public repo yet, I copied our README into a gist:

https://gist.github.com/keithl-stripe/870c199d9a1267fda0101cf95ec1f3aa

generated API documentation

This is not an API – do we need this?

include examples of use

Our README shows examples.

tests that are running continuously

Any suggestions for this? Stripe doesn't have any contracts with CI providers.

Must reply to issues/PRs in 2-3 weeks (exact service level agreement TBD)

Happy to comply with this. Internally Stripe has 5-day SLO for this :)

Must have more than one person who is committed to review/approve PRs

@keithl-stripe and @murray-stripe, at minimum, are available from our team.

We recommend encoding this as a CODEOWNERS file.

OK!

Must publish semver releases.

We can do this. Initial release will probably just be 0.1.

Must work with LTS Bazel version

It works with Bazel 5.3.2!

jsharpe commented 1 year ago

Immediate thought - unused-deps is a generic name that's doesn't scope the product to just java which I believe is the current scope of this tool. Maybe unused-java-deps is a better name, although appreciate that the name follows from the google tools heritage.

I guess implicit in this is the question of how specific to java is this tooling? Could it have a gazelle like plugin ecosystem to allow it to be expanded to other languages?

murray-stripe commented 1 year ago

The tool does three things (roughly):

  1. collect the bazel dependency graph through some bazel queries
  2. collect the java source graph
  3. compare the two graphs

The first and last step are fairly generic, but the middle step is implemented as a compiler plugin to javac. I'm not sure there would be a ton of value in making this pluggable as the other two parts are rather straight-forward.

keithl-stripe commented 1 year ago

I'm open to a better name, especially because this one is almost identical to Google's unused_deps tool (which is not supported anymore, and is buggy).

However I imagine someone might want to come along and add Scala and/or Kotlin support, in which case unused-java-deps might be too specific.

alexeagle commented 1 year ago

I agree that the name doesn't match the scope. I'd love to see a tool that aspires to remove unused deps in all languages.

Assuming you want to keep the scope... Could this just be a feature that lives in https://github.com/bazel-contrib/rules_jvm ? If it's a standalone repo, maybe unused-jvm-deps is a good name as we already have "rules_jvm_external" and so on.

alexeagle commented 1 year ago

In the SIG meeting we decided to create bazel-contrib/unused_jvm_deps

cgrindel commented 1 year ago

I created unused_jvm_deps as private. I have invited @keithl-stripe and @murray-stripe to the repo. They should be good to proceed with setting up the repository and making it public.

cgrindel commented 1 year ago

I did not realize that unused-jvm-deps had already been created. This is the repo that will be used.