Skip to content

Warn when sources sit under sbt/Maven layout that bleep won't pick up#596

Open
oyvindberg wants to merge 1 commit into
masterfrom
warn-misplaced-sources
Open

Warn when sources sit under sbt/Maven layout that bleep won't pick up#596
oyvindberg wants to merge 1 commit into
masterfrom
warn-misplaced-sources

Conversation

@oyvindberg
Copy link
Copy Markdown
Owner

Summary

  • Best-effort heuristic at bootstrap: for each project without an explicit `sources:` or `sbt-scope:`, scan for the six common sbt/Maven-style source paths (`src/{main,test}/{scala,java,kotlin}`). If any exists, contains at least one source file, and is not already in the project's resolved `sourcesDirs` → emit one `warn` per offender pointing at the file and listing three fixes (move, set `sources:`, or set `sbt-scope:`).
  • Catches the exact footgun that silently neutered `KotlinIT` for months. Until Kotlin formatting via ktfmt; bump scalafmt + GJF defaults #595 lands, `KotlinIT` files at `src/main/kotlin/` are never compiled and the suite passes as a no-op. With this PR, that situation is loud at bootstrap.
  • Cost: at most 6 `Files.isDirectory` probes per project, then one short-circuited `Files.walk(...).anyMatch(...)` per existing suspect dir. Zero false positives on bleep's own multi-project build.

Relationship to #595

This PR catches the layout footgun in general; #595 fixes the specific `KotlinIT` paths that exposed it. They are independent — either can land first. If #595 lands first, the suspect-paths check has nothing in this repo to warn about; if this lands first, `KotlinIT` runs will print warnings until #595 merges (tests still pass; warnings are not errors).

Test plan

  • New `CheckMisplacedSourcesTest` with 8 unit cases (kotlin/java/scala warn; correct layout no-warn; empty dir no-warn; `sources:` override no-warn; `sbt-scope: main` no-warn; `src/test/` also caught). Suite passes in 628ms.
  • Smoke-tested on bleep's own multi-project build — no false positives across the dozens of projects with mixed `sources:` overrides and default layouts.
  • `bleep fmt --check` clean.

🤖 Generated with Claude Code

Bleep's default source layout resolves to src/<lang>/ because sbt-scope
defaults to "". Files placed under src/main/scala, src/main/java, src/main/kotlin,
or the src/test/ equivalents are silently invisible to the build — the project
compiles as a no-op and you only notice via a runtime ClassNotFoundException
(or never, if the no-op project is downstream of nothing). This bit our own
KotlinIT, which was a 4-test silent no-op for months.

Adds a best-effort heuristic at bootstrap: for each project without an
explicit `sources:` or `sbt-scope:`, check whether any of the six suspect
directories exists AND contains at least one matching source file AND is not
already in the project's resolved sourcesDirs. If so, emit one warn per
offender pointing at the file and listing three fixes (move, set sources:,
or set sbt-scope:).

Costs at most 6 Files.isDirectory probes per project and one Files.walk
(short-circuited via anyMatch) per existing suspect dir. Zero false positives
on bleep's own multi-project build.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant