# biome complexity/noAdjacentSpacesInRegex: fix changes program behavior

Internal evidence sheet generated by fixhunt. Not an issue text. A human re-verifies, checks the duplicates
below, and writes the upstream report in their own words following the project's AI policy.

- Tool: biome 2.5.15
- Rule: complexity/noAdjacentSpacesInRegex (tool labels the fix: safe, this fix reported as safe)
- Oracle: fix-changes-behavior
- Judge (Nemotron 3 Ultra, advisory): introspection-only, severity low. The fix rewrites the regex literal from `/hello  world/` to `/hello {2}world/`, which changes the value of `RegExp.prototype.source` that the program explicitly reads and logs. The actual matching behavior against the string `'hello  world'` is unchanged; only the source text representation differs, which is expected for any rewrite of a regex literal.
- Program: minimized from 7 to 5 lines

## Reproducer

```js
const obj = {};
Object.defineProperty(obj, 'pattern', {
  get() { return /hello  world/.source; },
});
console.log('Match:', /hello  world/.test(obj.pattern));
```

## Commands

```sh
node prog.js
bunx @biomejs/biome lint --only=complexity/noAdjacentSpacesInRegex --write prog.js
node prog.js
```

## Observed

```
stdout before:
Match: true
stdout after:
Match: false
```

## Diff applied by the fix

```diff
--- orig.js	2026-10-22 13:25:39.699208740 -0400
+++ fixed.js	2026-10-22 13:25:41.791243319 -0400
@@ -1,5 +1,5 @@
 const obj = {};
 Object.defineProperty(obj, 'pattern', {
-  get() { return /hello  world/.source; },
+  get() { return /hello {2}world/.source; },
 });
-console.log('Match:', /hello  world/.test(obj.pattern));
+console.log('Match:', /hello {2}world/.test(obj.pattern));
```

## Why the rewrite is not equivalent (model draft, verify before use)

The original regex `/hello  world/` matches exactly two spaces between "hello" and "world". After rewriting to `/hello {2}world/`, it still requires exactly two spaces—so semantically equivalent in pattern—but `obj.pattern` returns `.source`, which for the first is `"hello  world"` (literal two spaces) and for the second is `"hello {2}world"` (the string `{2}`). When testing `/hello  world/.test(obj.pattern)`, the literal string `"hello  world"` matches, but `"hello {2}world"` does not contain two consecutive spaces—it contains the characters `{`, `2`, `}`—so the test fails. The rewrite altered the source string’s content, breaking the test despite preserving regex meaning.

## Upstream search

Queries: "noAdjacentSpacesInRegex fix", "complexity/noAdjacentSpacesInRegex regex literal spaces", "regex test method pattern property accessor", "Object.defineProperty getter returning regex source"

- related: https://github.com/biomejs/biome/issues/11419
  same rule noAdjacentSpacesInRegex but different construct (character class vs plain regex)
- related: https://github.com/biomejs/biome/issues/1704
  same rule noAdjacentSpacesInRegex but different scenario (lint-on-save vs getter property)

<details><summary>All hits</summary>

- [github, open] 💅 noDuplicateTestHooks: false positive on a local function named `before` called twice in a test — https://github.com/biomejs/biome/issues/12231
- [github, open] 💅 `useSortedProperties` can produce invalid CSS when the final semicolon is omitted — https://github.com/biomejs/biome/issues/12417
- [github, closed] 💅 `noAdjacentSpacesInRegex` safe fix corrupts character classes: `[\s   ]` → `[\s {3}]` — https://github.com/biomejs/biome/issues/11419
- [github, open] 💅 `useSortedProperties` moves Sass variable declarations below their uses — https://github.com/biomejs/biome/issues/12414
- [github, open] 💅 `useSortedProperties` can change behavior when reordering nested CSS rules — https://github.com/biomejs/biome/issues/12413
- [github, open] 💅 `noUnnecessaryConditions`: false positive on an overloaded call with `undefined` as the default argument (Vue `inject`) — https://github.com/biomejs/biome/issues/12040
- [github, open] 💅 `noSkippedTests` conditionally skip fix suggestion — https://github.com/biomejs/biome/issues/9295
- [github, open] 💅 Actually used private method considered unused — https://github.com/biomejs/biome/issues/8185
- [github, open] 💅 cannot detect that the StrictMode component of React is being exported. — https://github.com/biomejs/biome/issues/10609
- [github, open] 💅 noUnnecessaryConditions callback overload false positive — https://github.com/biomejs/biome/issues/11439
- [tavily] 💅 `noThisInStatic` safe fix is not safe · Issue #10011 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/10011
- [tavily] 💅 `useReadonlyClassProperties` want to add readonly on javascript files · Issue #7301 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7301
- [tavily] 💅 Corrupted CLI safe fix for `useConsistentArrowReturn` · Issue #8347 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8347
- [tavily] 💅 Incorrect suspicious/noAssignInExpressions on arrow function · Issue #8790 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8790
- [tavily] 💅 `useSortedClasses` unsafe fix does not apply to expressions in Astro template · Issue #9181 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9181
- [tavily] 🐛 $filename metavariable not set in GritQL plugins · Issue #6670 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6670
- [tavily] Property 'useIterableCallbackReturn' is not allowed, (same for `useUniqueElementIds`) · Issue #7280 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7280
- [tavily] 💅 correctness/noPrecisionLoss incorrectly flags hex literals above or equal to 2^53 even if valid · Issue #8145 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/8145
- [tavily] 💅 Linter: `lint --write` is not idempotent on Astro frontmatter, while `lint` reports no issues · Issue #7912 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7912
- [tavily] 💅 lint/suspicious/noExtraNonNullAssertion triggers for arr[0]! ^= arr[1]! · Issue #7927 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/7927
- [tavily] 💅 useExhaustiveSwitchCases does not work across module boundaries · Issue #6929 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/6929
- [tavily] chore: add regex globals by arendjr · Pull Request #8166 · biomejs/biome · GitHub — https://github.com/biomejs/biome/pull/8166
- [tavily] 📎 Implement rule `useTopLevelRegex` · Issue #2148 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/2148
- [tavily] 🐛 Astro: various things result in frontmatter `parse: Unterminated regex literal` · Issue #9187 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/9187
- [tavily] 💅 Bug when linting on save, when Biome is changing RegEx to literal · Issue #1704 · biomejs/biome · GitHub — https://github.com/biomejs/biome/issues/1704

</details>
