I am working on writing a script that outputs information about my written source code.
So far, I am analysing the code with Python scripts that I have written.
There is a Test.cs class which is used for this analysis.
Now I want to calculate the cyclomatic complexity from Test.cs.
Currently I am working on Visual Studio Code. I am aware that Visual Studio offers such a functionality and there are also packages that I can use for this.
However, I wanted to find out whether it is possible
- a.) to write a Python script which can analyse my
Test.csclass or - b.) to create a C# project to analyse the corresponding
Test.csclass and if so, how can I pass the value for my script?
Because I would like to output and evaluate this value separately for the user.
Also I found this interesting documentation:
But here it is not clear to me how I could build and call up the Metrics.exe accordingly.
Or are there other approaches I could pursue?
I look forward to your feedback.
The easiest method is probably to call and parse the output of
Metrics.exe.If you don't provide
/out, it will print to stdout, so you can capture it in Python.I don't use Windows, so I can't test this, but something along the lines of this should work:
From there, just select the metrics you're looking for.