Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find Cyclomatic Complexity of Xcode Project?

I want to know is there any way to find the cyclomatic complexity of the project created in Xcode.

Thanks

like image 868
Baddu Avatar asked Oct 17 '13 10:10

Baddu


1 Answers

CLang Static Analyzer

You can use Static Analyzer for CLang, it can be integrated with Xcode and it'll perform some basic analysis to produce quality indices (such as cyclomatic compexity) and more advanced static analysis (to detect possible bugs, defects, hard to maintain code).

See this tutorial for instruction about integration.

From website:

The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs.

HFCCA

If you don't really need a full static analysis tool you may consider to use a more simple program to just calculate cyclomatic complexity. HFCCA is a simple Phyton script that can be used from command line and produces some very basic indices (lines of code without comments, cyclomatic complexity, token count of functions and parameter count of functions).

It's a command line tool but it can be integrated in XCode (take a start from CLang analyzer to see how).

like image 111
Adriano Repetti Avatar answered Oct 31 '22 16:10

Adriano Repetti