Write Clean Code From Now On
Static analysis consists in analyzing the code without executing it. NDepend is a static analyzer for .NET code. The main problem with all static analyzers is that when it analyzes a large code base, hundreds if not thousands of issues are found. This avalanche of issues overwhelms the user.
This is why NDepend proposes to define a baseline. In the NDepend Dashboard Issues section, found in both Visual Studio extension and in the Azure DevOps extension, the tool shows:
- All issues (in black)
- New issues added since the baseline (in red). Those new issues are the ones to fix first.. This way newly written code and refactored code remain clean code. Also when fixing these new issues on fresh code, developers naturally learn from the NDepend rule set.
- Issues fixed (in green)
Each of this number in the Dashboard can be clicked to list concerned issues and then jump in the code and fix it.
If you prefer from the Dashboard Issue panel you can change the issues grouping options to group them by rules, assemblies, namespaces or classes.
Typically the baseline is the analysis result of the last version of the code base in production. When a new NDepend project is created, the first analysis result obtained becomes automatically the baseline. This baseline will be compared against further analysis results.
After a few days you might want to update the baseline because the first analysis result might miss some data (like code coverage data for example). The baseline can be defined from: NDepend > NDepend Project Properties > Analysis > Baseline for Comparison
The NDepend Dashboard contains a Choose Baseline row that proposes recent analysis results available. Just click an N days ago link to compare against the corresponding analysis result. All rules are then re-executed within a few seconds to update the target set new issues added since the baseline. Note that changing the baseline is a temporary action and doesn't update the baseline settings in the NDepend project.