Read the two line readers as projections - #376
Merged
Merged
Conversation
Code scanning reported the two loops in ReleaseVersionAgreementTests that map their iteration variable in their first statement, alerts 238 and 239 of the class cs/linq/missed-select. The mapping moves into the sequence in both. In the script reader the comment filter moves with it, because a body that is one test and a continue is the shape the next scan reads as a missed Where, and a sibling board paid for that rewrite with a second class minted at the same sites one scan later. Deleting the comment filter left the suite green, which I found while proving the rewrite. Every refusal pattern is anchored to the start of a line, so a commented-out exit was never read as one, and the assignment pattern is the one unanchored reading that a dropped filter changes. A fixture holds it now: an assignment inside a comment that would otherwise become the compared variable's origin and refuse the route's join for a comment. With the filter deleted that leg is the one that goes red. Signed-off-by: Nils Lehnen <30603423+iderex@users.noreply.github.com>
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.
Refs #373, the class
cs/linq/missed-select: two alerts, both in the readersReleaseVersionAgreementTestswalks a workflow file with.Finishes: #373
The two sites
Read from the platform rather than from the issue, at the head this branch starts from:
The first is
JobLines, the second isScript. Each is aforeachwhose first statement trims the raw line into the variable the rest of the body reads, which is the shape the query asks about.What changed
The mapping moves into the sequence in both, as a
Selectover the split lines, and the loop bodies start where they always did.In
Scriptthe filter that drops blank lines and comments moves with it, into aWhere, and the reason is on a sibling board rather than in this tree: a loop whose body opens with one test and acontinueis whatcs/linq/missed-whereasks about, and the board that rewrote eleven of these sites as projections had six alerts of that class minted at the same sites by the next scan. So the two rewrites are one change here rather than one and its correction a scan later. The loop holds only the join of continuation lines now.What proving it found
The suite is what says the rewrite kept the readers' meaning, and it does, on both lines:
That count is one higher than the mainline's, and the extra leg is the thing worth reading here. A rewrite that moves a filter is a rewrite that can drop it, so I deleted the comment filter and ran the two route classes:
Green. Nothing held it. Every refusal pattern is anchored to the start of a line and a comment never starts with
exit, so the existing legARefusalInsideACommentIsNotARefusalpasses whether or not comments are stripped. The one reading a dropped filter does change is the assignment pattern, which is deliberately unanchored so an assignment after a semicolon or a case pattern is read. A comment such as# want="0.1.1.0"is then an assignment, the compared variable's origin becomes the literal, and the join is refused for a comment.OriginReassignedInACommentis that fixture, the control with one commented-out assignment added after the real one, andAnAssignmentInsideACommentIsNotAnOriginasserts the join still reads as one. With the filter deleted again:The second line is the one-character mistake this rewrite could have made,
TrimforTrimEnd, which loses the indentation every reading of the job depends on.The means
C#, in the file the alerts name, and the fixture in the same shape as the five beside it. It adds no language, runtime or dependency. The alternative was a dismissal, and the sibling boards have taken both routes for this class; here the query read the two sites correctly, the projection is the plainer form, and a dismissal would have left the filter unheld.
What this does not say
The alerts close when the analysis next runs over
master, not on this merge, so #373 stays open until that reading is pasted into it. Whether this class arrives again is operations#2176's question and not this change's.No second reader looked at this. The runs above are the evidence in place of one.