Skip to content

JavaBuilder changes for unused dependencies checking - #30807

Open
JonathanPerry651 wants to merge 1 commit into
bazelbuild:masterfrom
JonathanPerry651:unused-deps-javabuilder
Open

JavaBuilder changes for unused dependencies checking#30807
JonathanPerry651 wants to merge 1 commit into
bazelbuild:masterfrom
JonathanPerry651:unused-deps-javabuilder

Conversation

@JonathanPerry651

Copy link
Copy Markdown
Contributor

This pull request contains the JavaBuilder-side changes for unused dependencies checking, splitting the functionality as requested by @hvadehra in #29770.

@bazel-docs-pr-commenter

Copy link
Copy Markdown

✅ Bazel docs preview is ready!

Preview URL: https://bazel-pr-30807.mintlify.app/

Updated for 24f2b28b1e503a1ba77ecfd36b42c04392fd5988

@hvadehra
hvadehra requested a review from cushon August 20, 2026 12:41
@@ -204,6 +204,57 @@ public void postAttribute(Env<AttrContext> env) {
public void finish() {
implicitDependencyExtractor.accumulate(context, checkingTreeScanner.getSeenClasses());

if (dependencyModule.getUnusedDeps() != UnusedDepsMode.OFF) {
Optional<String> targetLabel =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nit: Since you're only using this Optional to call isPresent(), why use it?

I'd propose instead moving all of this code into a helper method called checkUnusedDeps, and then in that, if dependencyModule.getTargetLabel() is false, return early. It will reduce the indentation on this code and make it a bit easier to scan the entire finish method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review PR is awaiting review from an assigned reviewer team-Rules-Java Issues for Java rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants