Skip to content

fix: restrict UOI mutations to identifier primaries only#127

Merged
scolladon merged 9 commits into
mainfrom
fix/uoi-non-id-primaries-126
Jun 1, 2026
Merged

fix: restrict UOI mutations to identifier primaries only#127
scolladon merged 9 commits into
mainfrom
fix/uoi-non-id-primaries-126

Conversation

@SamanAttar
Copy link
Copy Markdown
Collaborator

@SamanAttar SamanAttar commented Jun 1, 2026

Explain Your Changes


The UOI mutator was generating mutations for primary expressions that are not valid assignment targets. Specifically literals (42, 'hello', true, null), this, super, SOQL/SOSL queries, type references, void, and expressions used as the receiver of a dot or safe-navigation expression (e.g. foo.bar).

Instead of maintaining an ad-hoc denylist of non-assignable text patterns, this will help simplify the mutator but using an allowlist: it only generates mutations when the primary child is an IdPrimaryContext (a plain identifier like x or myVar). All other primary types are rejected by construction.

The DotExpressionContext parent check is added to guard against dot-receiver positions that would also produce invalid mutations as an early exit.

The isLiteral private helper has been removed as it is no longer needed.


closes #126

  • Unit tests added to cover the fix.
  • NUT tests added to cover the fix.
  • E2E tests added to cover the fix.

Any particular element that can be tested locally


Any other comments


@SamanAttar SamanAttar requested a review from scolladon as a code owner June 1, 2026 02:51
@SamanAttar SamanAttar changed the title Fix: restrict UOI mutations to identifier primaries only fix: restrict UOI mutations to identifier primaries only Jun 1, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Performance Comparison (same runner)

Regressions

Benchmark Base PR Ratio Change
antlr-parse-small 123 84 1.46 -46.4%
antlr-parse-medium 26 17 1.53 -52.9%
antlr-parse-medium (mean) 37.9428ms 59.8873ms 1.58 +57.8%

Stable

Benchmark Base PR Ratio Change
antlr-lex-small 6927 6817 1.02 -1.6%
antlr-lex-medium 1464 1426 1.03 -2.7%
antlr-lex-large 461 449 1.03 -2.7%
antlr-parse-large 9 9 1.00 +0%
pipeline-small-compute-mutations 117 101 1.16 -15.8%
pipeline-small-type-discovery 172 157 1.10 -9.6%
pipeline-medium-compute-mutations 29 26 1.12 -11.5%
pipeline-medium-type-discovery 36 33 1.09 -9.1%
pipeline-large-compute-mutations 10 9 1.11 -11.1%
pipeline-large-type-discovery 12 11 1.09 -9.1%
pipeline-apply-all-mutations 3 3 1.00 +0%
antlr-lex-small (mean) 0.1444ms 0.1467ms 1.02 +1.6%
antlr-parse-small (mean) 8.1599ms 11.9096ms 1.46 +46.0%
antlr-lex-medium (mean) 0.6829ms 0.701ms 1.03 +2.7%
antlr-lex-large (mean) 2.1697ms 2.2251ms 1.03 +2.6%
antlr-parse-large (mean) 108.7301ms 116.0726ms 1.07 +6.8%
pipeline-small-compute-mutations (mean) 8.5776ms 9.859ms 1.15 +14.9%
pipeline-small-type-discovery (mean) 5.8024ms 6.3627ms 1.10 +9.7%
pipeline-medium-compute-mutations (mean) 34.7654ms 38.1791ms 1.10 +9.8%
pipeline-medium-type-discovery (mean) 27.5057ms 30.2796ms 1.10 +10.1%
pipeline-large-compute-mutations (mean) 100.6786ms 108.8506ms 1.08 +8.1%
pipeline-large-type-discovery (mean) 81.82ms 88.1229ms 1.08 +7.7%
pipeline-apply-all-mutations (mean) 332.731ms 321.2675ms 0.97 -3.4%

@scolladon scolladon force-pushed the fix/uoi-non-id-primaries-126 branch from b8f6a61 to 446a74b Compare June 1, 2026 08:25
scolladon
scolladon previously approved these changes Jun 1, 2026
Copy link
Copy Markdown
Owner

@scolladon scolladon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Nice finding, thanks

Comment thread src/mutator/unaryOperatorInsertionMutator.ts
Copy link
Copy Markdown
Owner

@scolladon scolladon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Published under dev-pr-127 draft release.

sf plugins install https://github.com/scolladon/apex-mutation-testing/releases/download/dev-pr-127/apex-mutation-testing-dev-pr-127.tgz

@scolladon scolladon merged commit a6fb2b7 into main Jun 1, 2026
10 checks passed
@scolladon scolladon deleted the fix/uoi-non-id-primaries-126 branch June 1, 2026 12:48
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

Shipped in release v1.7.1.
Version v1.7.1 will be assigned to the latest npm channel soon
Install it using either v1.7.1 or the latest-rc npm channel

$ sf plugins install apex-mutation-testing@latest-rc
# Or
$ sf plugins install apex-mutation-testing@v1.7.1

💡 Enjoying apex-mutation-testing?
Your contribution helps us provide fast support 🚀 and high quality features 🔥
Become a sponsor 💙
Happy zombies detection!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UOI emits invalid mutations on Type names and SOQL statements

2 participants