-
Notifications
You must be signed in to change notification settings - Fork 7
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
Detect usages of Received like methods in Received.InOrder block #135
Comments
From review comments, suggestion for error doc: NS5001
CauseUsage of received-like method in Rule descriptionA violation of this rule occurs when any of the following are used inside a
Calls within How to fix violationsTo fix a violation of this rule, remove received-like method calls from For example: // Incorrect:
Received.InOrder(() =>
{
sub.Received().Baz();
sub.Received().Bar();
})
// Correct:
Received.InOrder(() =>
{
sub.Baz();
sub.Bar();
}) Alternatively, move any received-like methods outside of // Incorrect:
Received.InOrder(() =>
{
sub.Baz();
sub.Zap();
sub.DidNotReceive().Bar();
})
// Correct:
Received.InOrder(() =>
{
sub.Baz();
sub.Zap();
})
sub.DidNotReceive().Bar(); How to suppress violationsThis warning can be suppressed by disabling the warning in the ruleset file for the project. [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Usage", "NS5001:Received-like method used in Received.InOrder block.", Justification = "Reviewed")] Or for a specific code block: #pragma warning disable NS5001 // Received-like method used in Received.InOrder block.
// the code which produces warning
#pragma warning restore NS5001 // Received-like method used in Received.InOrder block. |
Sorry it took me so long to get to this ☝️ . 😞 |
As discussed nsubstitute/NSubstitute#604 (comment)
The text was updated successfully, but these errors were encountered: