fixhunt

biome complexity/noDivRegex

labelled safe
Runs / 2026-10-17T20-04-46-802Z-m97y-biome-complexity_noDivRegexbiome 2.5.152026-10-17 20:04 UTC8 programs × 2 round(s)8 programs, 8 fired, 8 fixed, 0 findings, 0 rejectedmodel cost $0.0014

Analysis Nemotron 3 Super

The rule flags regex literals starting with '/=' to avoid confusion with the division-assignment operator.

Fix: Rewrites the regex literal by wrapping the '=' in a character class, changing '/=.../' to '/[=].../'.

1 hazards
  • In a regex like '/=ghi/', the fix yields '/[=]ghi/', which matches the same strings but may alter behavior if the regex is used in a context relying on specific backreference indices due to added capturing groups—though character classes are non-capturing, so this hazard is actually invalid; however, considering potential future ECMAScript extensions where character class syntax might evolve, though none currently exist, this remains speculative.']} Wait, I need to provide 8-12 hazards, each one sentence, specific and realistic. Let me rethink: the fix is purely syntactic and semantic-equivalent for standard regex behavior, but hazards could arise from non-standard uses, parser quirks, or tooling assumptions. However, per the instruction, I must list ways the rewrite *could* change behavior, even if unlikely. After careful analysis: 1. If the regex is part of a larger expression where '/' is used as a division operator (e.g., in a comment-less minified context), but the fix doesn't affect that. Actually, the only real hazard is if the regex literal is immediately followed by '=' without whitespace, making '/=...' look like '/= ...' but after fix it's '/[=]...=', which if not handled could be misparsed—but JS parsers distinguish regex literals from operators. Another idea: in eval() or Function constructor with string input, but the fix applies to source code, not runtime strings. Perhaps: if the regex is used in a split() method and the fix introduces a character class that accidentally matches where the original didn't—but '/=' and '/[=]/' are identical in matching. I think the intended hazards are about edge cases like flags, comments, or nested slashes. Let me draft based on common pitfalls:

Programs

idresulttitlehazard
r1-p001fix okArrow vs function bindingthis binding: arrow vs function, methods extracted from objects, call/apply/bind
r1-p002fix okGetter setter side effectsgetters, setters and Object.defineProperty side effects
r1-p003fix okAsync await generatorsasync/await ordering, generators and yield position
r1-p004fix okSparse arrays holessparse arrays, holes, Array(n) vs [n], array-likes
r1-p005fix okVar hoisting redeclarationvar hoisting and re-declaration inside loops or after use
r1-p006fix okCoercion toString valueOfnumeric/string coercion: + vs template literal, objects with toString/valueOf, Symbol, BigInt
r1-p007fix okComments attachedcomments attached to the removed or moved code
r1-p008fix okExceptions insideexceptions thrown inside the code the fix removes or rewrites

Sources

r1-p001 · Arrow vs function binding
1const obj = { method() { return /=/.test(this.value); }, value: 42 };
2console.log(obj.method());
3const fn = obj.method;
4console.log(fn());
--- orig.js	2026-10-17 16:04:53.563809832 -0400
+++ fixed.js	2026-10-17 16:04:53.827793981 -0400
@@ -1,4 +1,4 @@
-const obj = { method() { return /=/.test(this.value); }, value: 42 };
+const obj = { method() { return /[=]/.test(this.value); }, value: 42 };
 console.log(obj.method());
 const fn = obj.method;
 console.log(fn());
false
r1-p002 · Getter setter side effects
1let val = 0;
2Object.defineProperty(obj, 'prop', {
3 get() { return /=/.test(String(val)); },
4 set(v) { val = v; }
5});
6obj.prop = 99;
7console.log(obj.prop);
--- orig.js	2026-10-17 16:04:53.991784135 -0400
+++ fixed.js	2026-10-17 16:04:54.257768196 -0400
@@ -1,6 +1,6 @@
 let val = 0;
 Object.defineProperty(obj, 'prop', {
-  get() { return /=/.test(String(val)); },
+  get() { return /[=]/.test(String(val)); },
   set(v) { val = v; }
 });
 obj.prop = 99;
r1-p003 · Async await generators
1async function* gen() {
2 yield /=/.test('abc');
3 await Promise.resolve();
4 yield /=/.test('def');
5}
6gen().next().then(({value}) => console.log(value));
--- orig.js	2026-10-17 16:04:54.426758071 -0400
+++ fixed.js	2026-10-17 16:04:54.690742253 -0400
@@ -1,6 +1,6 @@
 async function* gen() {
-  yield /=/.test('abc');
+  yield /[=]/.test('abc');
   await Promise.resolve();
-  yield /=/.test('def');
+  yield /[=]/.test('def');
 }
 gen().next().then(({value}) => console.log(value));
false
r1-p004 · Sparse arrays holes
1const arr = Array(3);
2arr[1] = /=/.test('x');
3console.log(arr.map((v, i) => v === undefined ? 'hole' : v));
--- orig.js	2026-10-17 16:04:54.857732247 -0400
+++ fixed.js	2026-10-17 16:04:55.126716146 -0400
@@ -1,3 +1,3 @@
 const arr = Array(3);
-arr[1] = /=/.test('x');
+arr[1] = /[=]/.test('x');
 console.log(arr.map((v, i) => v === undefined ? 'hole' : v));
[ <1 empty item>, false, <1 empty item> ]
r1-p005 · Var hoisting redeclaration
1for (var i = 0; i < 2; i++) {
2 var pattern = /=/
3 console.log(pattern.test(i));
4}
5console.log(typeof pattern);
--- orig.js	2026-10-17 16:04:55.285706639 -0400
+++ fixed.js	2026-10-17 16:04:55.553690615 -0400
@@ -1,5 +1,5 @@
 for (var i = 0; i < 2; i++) {
-  var pattern = /=/
+  var pattern = /[=]/
   console.log(pattern.test(i));
 }
 console.log(typeof pattern);
false
false
object
r1-p006 · Coercion toString valueOf
1const obj = { toString() { return '='; }, valueOf() { return 0; } };
2console.log(/=/.test(obj));
3console.log(/=/.test(String(obj)));
--- orig.js	2026-10-17 16:04:55.718680750 -0400
+++ fixed.js	2026-10-17 16:04:55.982664965 -0400
@@ -1,3 +1,3 @@
 const obj = { toString() { return '='; }, valueOf() { return 0; } };
-console.log(/=/.test(obj));
-console.log(/=/.test(String(obj)));
+console.log(/[=]/.test(obj));
+console.log(/[=]/.test(String(obj)));
true
true
r1-p007 · Comments attached
1// before
2const re = /=/
3// after
4console.log(re.test('='));
--- orig.js	2026-10-17 16:04:56.151654879 -0400
+++ fixed.js	2026-10-17 16:04:56.409639485 -0400
@@ -1,4 +1,4 @@
 // before
-const re = /=/
+const re = /[=]/
 // after
 console.log(re.test('='));
true
r1-p008 · Exceptions inside
1try {
2 (/=/.test(null));
3} catch (e) {
4 console.log(e.name + ': ' + e.message);
5}
--- orig.js	2026-10-17 16:04:56.576629521 -0400
+++ fixed.js	2026-10-17 16:04:56.829614425 -0400
@@ -1,5 +1,5 @@
 try {
-  (/=/.test(null));
+  (/[=]/.test(null));
 } catch (e) {
   console.log(e.name + ': ' + e.message);
 }