Skip to content
| Marketplace
Sign in
Visual Studio>Tools>CodeMaintainability 2022

CodeMaintainability 2022

Ognjen Babić

|
1,750 installs
| (2) | Free
Extension for tracking code maintainability of your methods. Instead of often performing report driven code analysis tools, you can use this extension to view in real-time maintainability score.

Introduction

Extension for tracking code maintainability of your methods, integrated into CodeLens. Instead of often performing report driven code analysis tools, you can use this extension to view in real-time maintainability score. This score is calculated only based on syntax parsing and has no logical implications, thus results should not be followed strictly. Instead, you should use this extension as a guide for discovering potential problems in your code. By default, Maintainability score is tracked and it ranges from 0 -100. Lower score means the method is harder to maintain. Calculations are done based on the formula found on the MSDN blog here. Based on the score value we can distinguish three categories (threshold limits for each category can be adjusted in options):

  • 0-9 = Bad
  • 10-19 = Moderate
  • 20-100 = Good

You can also change main metric to track in options. Other available metrics are:

  • Cyclomatic complexity
  • Halstead volume
  • Lines of executable code

Metric calculation is triggered on document save.

Usage

After installing extension you can view maintainability score next to the method declaration:

image__1.png

Clicking on the CodeLens score will provide you more info about additional metrics used in computing maintainability index:

image__2.png

Options

In the Visual Studio options menu you can find a new entry called Code Maintainability. Here you can select default metric to track, if status icon should be displayed in CodeLens and in Details pane. Also, you can adjust threshold limits for each metric (status icon will change colors based on value and range set) and if metric should be visible at all in details pane.

image__3.png

Planned upcoming features

  1. Support for Cognitive complexity
  2. Adding option to display multiple metrics above methods
  3. Adding option to display info, warning or error messages in the console if a method score is bad

Contact

If you have any feedback or requests, please contact me here or via email: babicognjen.oggy@hotmail.com.

  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft