Skip to content
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

[GH-159|GH-160] - argument matcher analyzers improvements - handling Arg.Do and When on property level #169

Merged
merged 2 commits into from
Nov 11, 2021

Conversation

tpodolak
Copy link
Member

@tpodolak tpodolak commented Sep 5, 2021

Closes #159 #160

@coveralls
Copy link

coveralls commented Sep 5, 2021

Pull Request Test Coverage Report for Build 439

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 9 unchanged lines in 4 files lost coverage.
  • Overall coverage increased (+0.2%) to 95.789%

Files with Coverage Reduction New Missed Lines %
C/projects/nsubstitute-analyzers/src/NSubstitute.Analyzers.Shared/Extensions/SubstituteSymbolExtensions.cs 1 96.0%
C/projects/nsubstitute-analyzers/src/NSubstitute.Analyzers.VisualBasic/DiagnosticAnalyzers/SubstitutionNodeFinder.cs 1 98.25%
C/projects/nsubstitute-analyzers/src/NSubstitute.Analyzers.Shared/Extensions/SyntaxNodeExtensions.cs 2 86.67%
C/projects/nsubstitute-analyzers/src/NSubstitute.Analyzers.Shared/DiagnosticAnalyzers/AbstractNonSubstitutableMemberArgumentMatcherAnalyzer.cs 5 95.73%
Totals Coverage Status
Change from base Build 438: 0.2%
Covered Lines: 2593
Relevant Lines: 2707

💛 - Coveralls

return;
}

if (IsPrecededByReceivedLikeMethod(syntaxNodeContext, syntaxNode))
Copy link
Member Author

Choose a reason for hiding this comment

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

@dtchepak Considering the fact that NS1004 will be reported for cases when (for instance) Arg.Is is used in following context

 substitute.Type = Arg.Is("sth");

instead of

 substitute.Received().Type = Arg.Is("sth");

even if Type property is virtual, should we change default message

[NS1004] Argument matcher used with a non-virtual member of a class.

to sth else?
Documentation clearly states that
This violation can also be reported if an argument matcher is used for something other than setting return values, checking received calls, or configuring callbacks. See [NSubstitute's argument matcher documentation](https://nsubstitute.github.io/help/argument-matchers/#how_not_to_use_argument_matchers) for more information. but maybe we should "promote" this message (or shorter one) to warning visible during the build?

Copy link
Member

Choose a reason for hiding this comment

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

I think ideally this should be a different error ("5003 Misused argument matcher"?).

The non-virtual cases are very clear in terms of cause and fix. The misuse case is a lot more subtle.

Maybe can tackle that as a separate issue so this fix can be merged first?

Copy link
Member Author

@tpodolak tpodolak Oct 10, 2021

Choose a reason for hiding this comment

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

@dtchepak created #173 to track this. Do you think we can release all the fixes we have without waiting for #173 ?

Copy link
Member

Choose a reason for hiding this comment

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

@tpodolak Yes I think that's fine to do #173 in a separate release. 👍

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.

NS1004 when using Arg.Do()
3 participants