Smart Code Review
- Automate the easy stuff
- Source diff since Baseline
- Smart code review, not just source diff
- Review every facets of the delta since the baseline
- Compare .NET Assemblies
- Keep an eye on Trending
- Related Links
NDepend proposes a wide range of features that can improve your code review gaming.
Automate the easy stuff
Code Review led developers to read code, to discuss and to debate. Developer time is a precious asset. Automating the easily-automated stuff frees humans up to focus on things that require human intervention.
- You should not be wasting code review time with "this method is too complex and error-prone, please refactor it".
- Instead code-review time should be spent on things like requirements misunderstood by the developer or hard to detect bugs.
This is why NDepend provides many code rules out-of-the-box. However any code rule tools will certainly detect hundreds if not thousands of issues on your code. Pausing development to fix them all is not practicable.
This is why NDepend compares the actual code against a baseline snapshot and thus, knows about new and fixed issues since the baseline. This feature leads to a tools-set to focus auto-code-validation on new and refactored code.
Every team being different, with NDepend it is easy to capture and automate your peculiars code-review requirements by writing some custom rules.
Checking new issues takes time. This task can also be automated through Quality Gates. A quality gate is an automate that can check facts like Percentage Coverage on New Code, New Blocker / Critical / High Issues, or New Debt since Baseline and return a value within the [ PASS WARN FAIL ] range. NDepend makes it also easy to customize existing Quality Gates and write your own ones.
With rules and Quality Gates, the only point to care about is to check Quality Gates status. This can also be automated by failing the build upon any Quality Gate failure.
To summarize:
- With code rules, a wide range of code smells can be reviewed automatically.
- Issues on new and refactored code since a baseline are prioritized.
- Quality Gates are used to define what is acceptable or not for your team.
- You are informed automatically that something is wrong thanks to build failure upon any Quality Gate failure.
Source diff since Baseline
Having a baseline in Visual Studio is also useful to quickly diff source files. At analysis time NDepend zips all source files. The menu Diff since Baseline is shown when right clicking any Visual Studio Solution Explorer item, or when right clicking anywhere in the source file code editor. This menu is enabled only if NDepend detects a change with the baseline version.
Per default the Visual Studio file diff feature is used to diff sources, but you can plug your preferred diff tool through Options > Source File Compare Tool.
Smart code review, not just source diff
Unlike other tools NDepend makes the difference between a change in the code logic and a minor source format change or a comment change. As a consequence the panel Search > Search by Changes proposes various options:
- Code was changed: Match code elements whose logic has been changed. Somehow the code behaves differently at runtime compared to the baseline version. The menu Diff since Baseline is available on any element right click to immediately diff the source.
- Visibility was Changed: As explained in the use case Detect API Breaking Changes being able to track types methods or fields whose visibility changed since baseline is useful to make sure that changes on your public API won't break your clients.
- Comments were Changed: Review only comment changes, no matter if the code logic has been changed or not.
- Track third-party code changes When reviewing some code changes it is worth inspecting changes in third-party code referenced. For example which method or which class is now used but wasn't used before (or vice-versa). Doing so can often leads to interesting discussions like: why do we now use DOM instead of SAX to parse some JSON (or XML) content?
These conventions are used in the search changes result:
- Underlined font for elements changed since baseline.
- Bold font for elements added since the baseline
- Bold strike font for elements removed since the baseline
Review every facets of the delta since the baseline
The NDepend dashboard shows the delta for each value presented, and also a up/down better/worst indicator. As any value on the dashboard, any delta value can be clicked. A LINQ query is then generated to dig into the delta. For example such generated query lists new issues, new classes or methods newly covered by tests.
Compare .NET Assemblies
On the NDepend start page the link Compare 2 versions of a code base let's select two versions of one or several assemblies.
With the NDepend ILSpy plugin, it is then possible to decompile both versions of an assembly, namespace, class or method. If several classes are decompiled, they are aggregated in the text file with a consitent order, which makes the code review of changes possible.
Keep an eye on Trendings
With NDepend a team can Monitor Code Trend. Pretty much all dimensions of your code can be monitored over time:
- code size
- code complexity
- code coverage
- amount of comment
- dependencies
- number of new and fixed issues
- technical-debt estimation
- third-party libraries usage...
With any given commit, you can see, at a glance, the effect on some facet of the codebase. If the code being reviewed triggers a dip in code coverage or an unusual increase in complexity on new and refactored code, that might be worth a discussion during the review.