bazel-contrib / bazel-contrib/rules_scala

unused_dependency_checker false positives with _suite macros

Open
#617 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

dep-tracking
Dominant language
Starlark
Stars
384
Forks
292
Avg merge
2d 21h
Merged PRs (30d)
46

Description

Unused dependency checker gives false positives when _suite macros are involved. Let's consider:

scala_library_suite(
   name = "foo",
   srcs = ["A.scala", "B.scala"],
   deps = ["dep1", "dep2"],
)

A.scala depends on dep1 and B.scala depends on dep2. In this scenario, both dep1 and dep2 will be reported as unused. It's because _suite is expanded into several targets with deps copied to each of them.

Users' expectation here is that dependency is reported as an unused only when it's not used in all srcs from the suite but now it's reported if it's unused in some source from the suite. Fixing this would require a post-processing step that takes union of deps information from all expanded targets of the suite.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the unused dependency checker and how _suite macros expand into targets with copied deps. Reproduce the scala_library_suite example, then verify that a dependency is reported unused only when it is unused across all sources in the suite, using the union of dependency information from the expanded targets.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.