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

Add Mock.Of<T> and MockRepository support to ConstructorArgumentsShouldMatchAnalyzer #140

Merged
merged 44 commits into from
Jul 14, 2024

Conversation

rjmurillo
Copy link
Owner

@rjmurillo rjmurillo commented Jul 5, 2024

The majority of this change is mechanical (moving code from one location to another, replacing magic strings with constants, etc.). There is a functional update that completely changes the ConstructorArgumentsShouldMatchAnalyzer:

  • consolidating two constructor analyzers now into a single shared source
  • improving the performance of the constructor analyzer
  • adding support for checking delegate
  • adding support for Mock.Of<T> and MockRepository features of Moq

image
Baseline is an empty analyzer, control is the old interface constructor parameter analyzer, treatment is the new combined analyzer.

Changes

Misc:

Documentation:

  • Fixed links to documentation for shipped analyzers
  • In analyzer rule help, link to commit id so documentation snaps to the version of the analyzer

Analyzers:

  • Moved rule ID to constants file
  • Added extension factory methods to help create Diagnostic
  • Consolidated two constructor parameter analyzers (Moq1001 and Moq1002) into a single analyzer with 30% better performance
  • ConstructorArgumentsShouldMatchAnalyzer now supports Mock.Of<T> syntax and MockRepository patterns

Benchmarks:

  • Add the ability to have a control and treatment as well as "baseline", allowing A/B performance benchmarking of implementations
  • Added benchmark for ConstructorArgumentsShouldMatchAnalyzer

Test:

  • Added extension methods to include all Moq versions under test or just the latest
  • Organized the ConstructorArgumentsShouldMatchAnalyzer test collateral (it's the highest volume) into partial files
  • Added Live Unit Test configuration when running in Visual Studio
  • Added code coverage filter for benchmark code if using ReSharper or Rider

Note: while code coverage is improved, it's still below 95%. This is due to some guard cases that need coverage. For example, #141

Resolves #122
For Moq1001 and Moq1002, #85

@rjmurillo rjmurillo added this to the v0.2.0 milestone Jul 5, 2024
@rjmurillo rjmurillo added documentation analyzers Change that impacts an analyzer behavior releasable feature labels Jul 5, 2024
@rjmurillo rjmurillo marked this pull request as ready for review July 5, 2024 23:13
@rjmurillo rjmurillo requested a review from MattKotsenas July 5, 2024 23:13
@rjmurillo rjmurillo enabled auto-merge (squash) July 6, 2024 18:53
@rjmurillo rjmurillo requested a review from MattKotsenas July 8, 2024 21:45
Copy link

codeclimate bot commented Jul 8, 2024

Code Climate has analyzed commit 70cd7a8 and detected 37 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 15
Duplication 2
Style 20

View more on Code Climate.

@rjmurillo rjmurillo disabled auto-merge July 14, 2024 22:58
@rjmurillo rjmurillo merged commit 1d1533a into main Jul 14, 2024
6 of 8 checks passed
@rjmurillo rjmurillo deleted the feature/simplify-ctor-analyzer branch July 14, 2024 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzers Change that impacts an analyzer behavior documentation feature releasable
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend analyzers to cover MockRepository
2 participants