Repository navigation
fix(elements): show the diff of a mutant whose replacement differs at a line break - #4372
Open
mkantautas wants to merge 2 commits into
Open
mkantautas wants to merge 2 commits into
mkantautas wants to merge 2 commits into
Conversation
… a line break
The diff view opens its focus on the offset where the mutated code
starts to differ and closes it on the offset where it stops differing.
Line breaks are never visited. When the difference started at one, the
focus was never opened, so closing it threw "Cannot find corresponding
opening tag for </span>" and the diff wasn't shown. This happens for
ordinary mutants such as an EqualityOperator on `fn({ a: 1 }) === b`,
whose replacement is printed over multiple lines. When the difference
stopped at a line break, the focus wasn't closed there and ran on over
the following lines.
Open and close the focus on the first visited offset at or after each
boundary instead. That offset can be in the indentation of a line,
before the line's active tags are printed again. A tag that a visitor
opens there is now printed once, with the other active tags, and a tag
that it closes there is removed without printing a closing tag. A line
with only whitespace prints no closing tags, because it printed none of
its tags.
Fixes stryker-mutator#3163
Restore the compatibility setting applied by nx migrate so affected projects still build their bundles before Bundlemon runs.
BundleMon (elements)Files updated (3)
Total files change +788B +0.1% Final result: ✅ View report in BundleMon website ➡️ |
Contributor
|
Tick the box to add this pull request to the merge queue (same as
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3163
The diff view opens its focus where the mutated code starts to differ and closes it where it stops differing, but line breaks are never visited:
Cannot find corresponding opening tag for </span>and the mutated code isn't shown. This happens with ordinary mutants. For example, StrykerJS reports an EqualityOperator mutant onfn({ a: 1 }) === bwith the replacementfn({\n a: 1\n}) !== b.The focus now opens and closes on the first visited offset at or after each boundary, like the mutant markers in the file view. That offset can be in the indentation of a line, where
transformHighlightedLineshasn't printed the line's active tags yet, so this also changes how it handles tags there:In the file view, this drops the stray
</span>that was printed at the start of a line after a mutant that ends at the end of the previous line, and on blank lines inside multi-line tokens such as comments. Added indentation is no longer focused in the diff, because the focus starts at the first non-whitespace character of a line. The old and new rows still show the change.Testing:
transformHighlightedLinestests for a tag opened or closed in the indentation and for a line with only whitespace. All five fail on master and pass with this change.CI compatibility:
The Nx 24 upgrade changed affected-task selection. For this PR, CI ran lint and tests but skipped
elements:build, so Bundlemon found nopackages/elements/dist. A separate commit addsaffected.legacy: true, the compatibility setting applied bynx migrate, to preserve the previous project-based behavior. Bundlemon, its thresholds and the workflow are unchanged.On Node 22.23.4 and 26.12.1 with Nx 24.0.0, the published head omits the build and this setting selects it, including when only the original four changed files are supplied. Changing
nx.jsonitself makes all workspace projects affected.The Scala checks require Java 25 and sbt and have not been validated locally for this maintenance commit. The hosted Node 22/26 and Windows/Linux matrix remains required.