I'm the current owner of a legacy C++ codebase. It's got a few dozen source & header files. The project is typically developed, built, and deployed on linux. In linux, the build system is scons/gcc, and the product is a single executable.
I want to generate Maintainability Index (MI) for various parts of the code, to help show that an update to the architecture in an area of the code is more maintainable than the previous architecture. So, I did some research and found that Visual Studio 2013 (for which I have an Ultimate license) will do this.
I successfully imported all of the source into a new VS2013 "Win32 Console Application." I have also gotten the source to build by making some changes to accomodate differences between gcc & VS2013.
I attempted to run "Analyze | Calculate Code Metrics for [project]" and VS2013 produced this error:
Project: [omitted] Configuration: Debug Scope: None Assembly: [omitted] Maintainability Index: Cyclomatic Complexity: Depth of Inheritance: Class Coupling: Lines of Code: Message: The project target file '[omitted]' contains no managed code.
So I changed the value of "Properties | Configuration Properties | General | Common Language Runtime Support" from "No CLR Support" to "Pure MSIL CLR Support", reran it, and got this in the "Code Metrics Results" window (doing my best to show what was output because I can't post images yet):
Hierarchy Maintainability Index Cyclomatic Complexity ... ---------------------------------------------------------------------------------- * [executable] (Debug) 36 31 * Global 36 31 * main(int, char** const): int 36 31
I can't get more detail than main(), there's just no way to expand main() like there is with [executable] or Global. I thought that I'd be able to get a score on a per file, per-function, or per-class level.
Can anyone tell me:
I want to make minimal changes to the code, but I can easily make changes to project type, project properties, create a new project & re-import the source, change the build product to .dll or .lib, etc.
As noted in my comment, this is happening because my code is unmanaged C++, and I've found documentation that code metrics only runs on managed code. Even adding one of the /clr options is not enough to get the metrics generated at a function level.