Skip to content

Commit 667eacf

Browse files
committed
infection.json5 で Str::randomHex の equivalent mutant を ignore
mutation testing (run 25111678546) で MSI 94.95% / 95% 閾値で CI failure。 原因: - Sloop\Support\Str::randomHex 内 `intdiv($length + 1, 2)` で IncrementInteger (+1 → +2) と DecrementInteger (除数 2 → 1) が escape - 両 mutation とも余分 bytes 取得 + substr trim で結果同一の equivalent mutant - \Random\Randomizer は PHP コア内部の final class、state machine の最初の N bytes が決定論的なため、bytes 取得数を増やしても先頭 N hex chars は同一 - テスト追加 / 実装変更 (DI 等) ではいずれも kill 不能と確認 CLAUDE.md「equivalent mutant は ignore で対応、実装を mutation のために 変えない」原則に従い、infection.json5 の mutators で ignore 指定。 理由コメントは既存の Container::resolveBinding / Container::autowire と 同じく英語で記載。
1 parent 173c59a commit 667eacf

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

infection.json5

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,27 @@
4242
"ignore": [
4343
"Sloop\\Container\\Container::autowire"
4444
]
45+
},
46+
"IncrementInteger": {
47+
// Str::randomHex computes the byte count as `intdiv($length + 1, 2)`
48+
// so that odd-length requests round up. Changing the `+ 1` to `+ 2`
49+
// simply asks for one extra byte that substr() then trims off,
50+
// leaving the visible output unchanged (equivalent mutant).
51+
// \Random\Randomizer is a final core class whose state machine
52+
// produces deterministic leading bytes, so a larger getBytes()
53+
// call yields the same hex prefix. No black-box test can observe
54+
// the difference, so the mutation cannot be killed.
55+
"ignore": [
56+
"Sloop\\Support\\Str::randomHex"
57+
]
58+
},
59+
"DecrementInteger": {
60+
// Same root cause as IncrementInteger above. Changing the divisor
61+
// from 2 to 1 just asks for more bytes that are then trimmed by
62+
// substr(), leaving the output unchanged (equivalent mutant).
63+
"ignore": [
64+
"Sloop\\Support\\Str::randomHex"
65+
]
4566
}
4667
},
4768
"testFramework": "phpunit",

0 commit comments

Comments
 (0)