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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extend collection assertions with
ContainInConsecutiveOrder
andNotContainInConsecutiveOrder
#1963Extend collection assertions with
ContainInConsecutiveOrder
andNotContainInConsecutiveOrder
#1963Changes from 12 commits
f4a8c68
4fad081
46a4135
356f7c7
fafd108
f3e97c1
9587001
54790a0
7eef1ba
23e8059
2a940fe
a5be6cb
9313fe7
b560ef6
e58610e
23c02fa
89c9100
745cb81
76de1b1
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
♻️ You can move the declaration in the
for
loop. It'll helps to make the method less long (and noisy).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean here, the declarations here need to be outside of the for loop to work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why? It's only needed within the block scope created by the
for
loop.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compiler error AV1530 - if you declare the index variable in the loop you cannot update it in the loop itself. Which we need to do to reset it should we have to start searching from the start of the unexpected items again.
(Of course, that does raise the question of if the loop is the right way to solve the problem 🤔 - but I think that it is the cleanest)
The 'subjectIndex
and
highestIndex` need to be outside of the loop as they shouldn't be recreated/reset each loop.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that wasn't obvious at all. Updating a loop variable is quite ugly indeed. But I see now how it works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you rather that this is really obvious?
We could declare the index in the loop and disable VS1530 for the loop itself... I see that is done elsewhere for other reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would make it clearer that you're doing that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having that code to disable the rule annoyed me so I spent some time thinking about it and figured out how to rewrite it to remove the index manipulation. I'm on the fence as to which is easier to read, let me know which you prefer (I'll revert if you want 😅)