fixhunt

biome complexity/noAdjacentSpacesInRegex: fix changes program behavior

fix-changes-behaviorlabelled safeintrospection-only · lowduplicate
Findings / 2026-10-17T20-03-48-850Z-01ch-biome-complexity_noAdjacentSpacesInRegex / r1-p008biome 2.5.152 → 2 lines2026-10-17 20:03 UTC

Hypothesis Nemotron 3 Super predicted to fire fired 1×

Interferes with source inspection or debugging where the original literal's space count is logged or compared.

Program

before
1const re = /a b c/;
2console.log(re.source.split(' ').length - 1);
after
1const re = /a {2}b {2}c/;
2console.log(re.source.split(' ').length - 1);

Output

stdout beforeexit 0
4
stdout afterexit 0
2
fired
1 before · 0 after
runs
each version twice, same file name, no network

Judge Nemotron 3 Ultra advisory introspection-only · low

The fix rewrites the regex literal from /a b c/ to /a {2}b {2}c/, which changes the value of RegExp.prototype.source. The program only inspects this source text by splitting on spaces and counting them, so the behavioral difference is purely introspection of the rewritten literal itself.

Explanation Nemotron 3 Super unverified

The original regex literal `/a b c/` contains two spaces between each letter; its `.source` property returns the exact string `"a b c"`. Splitting this on single spaces yields `["a", "", "b", "", "c"]`, length 5, minus 1 gives 4. The rewritten regex `/a {2}b {2}c/` uses the quantifier `{2}` to match exactly two spaces, but its `.source` is `"a {2}b {2}c"`. Splitting that on spaces produces `["a", "{2}b", "{2}c"]`, length 3, minus 1 equals 2. Thus the change alters the literal text of the regex source, affecting the subsequent string operation and output.

Reproduce

file
prog.js (the before program)
minimized program
r1-p008.js
evidence sheet
r1-p008.md
regression fixture
r1-p008.js the minimized program with a header stating the observed change, for the tool's test suite
node prog.js
bunx @biomejs/biome lint --only=complexity/noAdjacentSpacesInRegex --write prog.js
node prog.js

Upstream search GitHub issues Tavily Nemotron 3 Super + Ultra

noAdjacentSpacesInRegex fix · complexity noAdjacentSpacesInRegex regex literal · regex adjacent spaces curly braces replacement · Biome lint rule spacing in pattern

  • duplicate biomejs/biome/issues/11419 same rule noAdjacentSpacesInRegex corrupting regex by replacing spaces with quantifiers, same defect class
  • related biomejs/biome/issues/6670 lists complexity/noAdjacentSpacesInRegex among many rules but no specific defect

Details

program
Source Inspection or Debugging Interference
hazard
Interferes with source inspection or debugging where the original literal's space count is logged or compared.
oracle
stdout before: 4 stdout after: 2
run
2026-10-17T20-03-48-850Z-01ch-biome-complexity_noAdjacentSpacesInRegex
generated program (2 lines) and the fix's diff
1const re = /a b c/;
2console.log(re.source.split(' ').length - 1);
--- orig.js	2026-10-17 16:03:58.947281645 -0400
+++ fixed.js	2026-10-17 16:03:59.213263777 -0400
@@ -1,2 +1,2 @@
-const re = /a  b  c/;
+const re = /a {2}b {2}c/;
 console.log(re.source.split(' ').length - 1);
rule documentation given to the models
Summary

- Name: noAdjacentSpacesInRegex
- Fix: safe
- Default severity: warn
- Available from version: 1.0.0
- Diagnostic category: lint/complexity/noAdjacentSpacesInRegex
- This rule is recommended

Description

 Disallow unclear usage of consecutive space characters in regular expression literals

Examples

Invalid

 ```js,expect_diagnostic
 /   /
 ```

 ```js,expect_diagnostic
 /foo  */
 ```

 ```js,expect_diagnostic
 /foo  {2,}bar   {3,5}baz/
 ```

 ```js,expect_diagnostic
 /foo [ba]r  b(a|z)/
 ```

Valid

 ```js
 /foo {2}bar/
```

 ```js
 / foo bar baz /
```

 ```js
 /foo bar	baz/
```