You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RuboCop now lints every Ruby file under rb/spec/ — several specs had silently escaped it.
🔧 Implementation Notes
Removed the hand-maintained list of test targets, because it wasn't getting updated and it wasn't obvious it needed to be updated.
A single glob can't replace the list: Bazel's glob() stops at package boundaries, and each spec directory with its own BUILD is a separate package, so each such BUILD defines its own recursive-glob filegroup, staged as data since filegroups aren't Ruby libraries and can't be deps.
Because of the glob, any new .rb file added under such a package is linted automatically.
Existing offenses autocorrected; no spec behavior changed.
🤖 AI assistance
No substantial AI assistance used
AI assisted (complete below)
Tool(s): Claude Code (Claude Opus)
What was generated: the //rb/spec:spec filegroup restructure and the RuboCop autocorrections
I reviewed all AI output and can explain the change
💡 Additional Considerations
Coverage of new spec packages isn't enforced: they must include an all_srcs filegroup and be added to //rb/spec:spec's data list.
Bazel: glob all rb/spec sources into //rb/spec:spec for RuboCop
🐞 Bug fix⚙️ Configuration changes🕐 20-40 Minutes
AI Description
• Stage all rb/spec/**.rb sources into //rb/spec:spec so RuboCop lints everything.
• Replace the hand-maintained spec target list with per-package all_srcs filegroups.
• Auto-correct existing RuboCop offenses in integration specs (no behavior changes).
➕ Single top-level glob would cover everything automatically with no per-package list.
➕ Less repetition (no per-directory all_srcs targets).
➖ High blast radius: changes Bazel package boundaries and potentially target labels/visibility.
➖ May require reorganizing existing test rules/macros that currently rely on subpackages.
2. Standardize via a Starlark macro + enforcement
➕ Keeps current package structure but reduces copy/paste for defining all_srcs.
➕ Can add a presubmit/buildifier-style check to ensure new packages define all_srcs and are wired into //rb/spec:spec.
➖ Still cannot eliminate the need to reference each package from the aggregator (Bazel glob boundary limitation).
➖ Requires introducing/maintaining shared macro and enforcement wiring.
Recommendation: The chosen approach (per-package all_srcs + //rb/spec:spec staging them via data) is the lowest-risk way to make RuboCop coverage complete while respecting Bazel package boundaries. If new spec packages are expected to grow, consider a small macro to standardize all_srcs definitions and a presubmit check to prevent forgetting to add the new package to //rb/spec:spec.
BUILD.bazelStage spec sources for RuboCop via all_srcs data+14/-35
Stage spec sources for RuboCop via all_srcs data
• Replaces a large, hand-maintained list of spec rule deps with a 'data' list of per-package ':all_srcs' filegroups. Adds inline documentation explaining Bazel package-boundary limitations and how new packages must be added.
1. Stale RuboCop comment✓ Resolved🐞 Bug⚙ Maintainability
Description
rb/spec/tests.bzl still states that rb_integration_test generates rb_library targets used by
//rb/spec:spec to expose tests to //rb:rubocop, but this PR changes //rb/spec:spec to stage
sources via data filegroups (:all_srcs) instead. This mismatch will mislead maintainers working
on the Bazel/RuboCop integration.
+# RuboCop lints only what Bazel stages for it, so this bundles every spec's+# sources. glob() can't cross package boundaries, so each spec package exposes an+# :all_srcs filegroup; new files in a listed package are covered automatically,+# a new package needs a line added here.
rb_library(
name = "spec",
testonly = True,
+ data = [+ "//rb/spec/integration:all_srcs",+ "//rb/spec/integration/selenium/webdriver:all_srcs",+ "//rb/spec/integration/selenium/webdriver/bidi:all_srcs",+ "//rb/spec/integration/selenium/webdriver/chrome:all_srcs",+ "//rb/spec/integration/selenium/webdriver/edge:all_srcs",+ "//rb/spec/integration/selenium/webdriver/firefox:all_srcs",+ "//rb/spec/integration/selenium/webdriver/remote:all_srcs",+ "//rb/spec/integration/selenium/webdriver/safari:all_srcs",+ ],
Evidence
//rb/spec:spec was changed in this PR to stage spec sources through data filegroups
(:all_srcs), while rb_integration_test still claims its generated rb_library is used by
//rb/spec:spec for RuboCop—this is no longer true after the PR change.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
## Issue description
`rb/spec/tests.bzl` contains a comment describing the old mechanism for exposing spec sources to RuboCop via generated `rb_library` targets and `//rb/spec:spec` deps. After this PR, `//rb/spec:spec` stages spec sources via per-package `:all_srcs` `filegroup`s added to `data`, so the comment is no longer accurate.
## Issue Context
- `//rb/spec:spec` now collects spec sources using `data = ["//rb/spec/...:all_srcs", ...]`.
- `rb_integration_test` still documents that it creates an `rb_library` “used by //rb/spec:spec to expose all tests to //rb:rubocop”, which is now misleading.
## Fix Focus Areas
- rb/spec/tests.bzl[193-198]
- rb/spec/BUILD.bazel[10-26]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
titusfortner
changed the title
[rb] glob spec sources into //rb/spec:spec for rubocop and clear hidden offenses
[rb] ensure ruby tests are properly linted
Jul 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
B-buildIncludes scripting, bazel and CI integrationsB-devtoolsIncludes everything BiDi or Chrome DevTools relatedC-rbRuby Bindings
2 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
💥 What does this PR do?
rb/spec/— several specs had silently escaped it.🔧 Implementation Notes
glob()stops at package boundaries, and each spec directory with its own BUILD is a separate package, so each such BUILD defines its own recursive-glob filegroup, staged asdatasince filegroups aren't Ruby libraries and can't bedeps..rbfile added under such a package is linted automatically.🤖 AI assistance
//rb/spec:specfilegroup restructure and the RuboCop autocorrections💡 Additional Considerations
all_srcsfilegroup and be added to//rb/spec:spec's data list.🔄 Types of changes