11

I'm using Jenkins for CI on iOS projects and want to collect some software metrics on them. But the only tool I was able to find was CLOC which only counts lines of codes (LOCs). Nevertheless it's better than nothing.

What I really want to count are methods, classes, calls to other classes etc. (to do the fancy cyclomatic complexity stuff).

Perhaps I'm missing some tools, let me know, if I do.

Jens Kohl
  • 5,899
  • 11
  • 48
  • 77

8 Answers8

9

OCLint?

From oclint.org:

OCLint is a static code analysis tool for improving quality and reducing defects by inspecting C, C++ and Objective-C code and looking for potential problems like:

  • Possible bugs - empty if/else/try/catch/finally statements
  • Unused code unused local variables and parameters
  • Complicated code - high cyclomatic complexity, NPath complexity and high NCSS
  • Redundant code - redundant if statement and useless parentheses
  • Code smells - long method and long parameter list
  • Bad practices - inverted logic and parameter reassignment ...
MdaG
  • 2,680
  • 2
  • 34
  • 46
5

Lizard will do it. Check it out at https://github.com/terryyin/lizard.

Phil
  • 1,030
  • 1
  • 16
  • 22
3

You can try XClarify, a pretty complete objective-c code analyzer, and it's free for open source contributors.

John
  • 131
  • 4
2

Beyond lines of code and test coverage, I'm not sure there are any such tools yet for Obj-C. I suspect we'll see some soon given the influx of devs from other platforms who use metrics, but in my 7 years as an Obj-C dev I haven't heard of anyone having a tool for collecting them. Of course it'd be good to be proved wrong :)

Martin Pilkington
  • 3,261
  • 22
  • 16
2

ProjectCodeMeter measures flow complexity (similar to McCabe cyclomatic complexity) on Objective-C code, but it doesn't count methods and classes though..

B.mK
  • 21
  • 1
1

I use few tools for gathering code quality metrics:

I've found recently that it exists free plugin for SonarQube - https://github.com/octo-technology/sonar-objective-c but it's not really feature-rich. Official one is here: http://www.sonarsource.com/products/plugins/languages/objective-c/

Ossir
  • 3,109
  • 1
  • 34
  • 52
0

I just stumbled upon Xcode Statistician (link seems to be dead), but haven't tried it yet. The zip archive can be downloaded directly.

Jens Kohl
  • 5,899
  • 11
  • 48
  • 77
  • 1
    I just tried it. Fairly basic stats: LOC per source file, classes, etc. However, no cyclomatic complexity, no methods per class, or any of the more truly useful stats. More disappointingly, it doesn't automatically traverse subfolders. Although the doc refers to scanning your project, it only works on the source files in the current folder. – Phil Nov 14 '13 at 15:29
  • That link is broken now. – Carlos Macasaet Jan 10 '16 at 23:55
  • 1
    @CarlosMacasaet Yeah, looks like it. But you can still download the zip archive via: http://www.literatureandlatte.com/freestuff/XcodeStatistician.zip – Jens Kohl Jan 11 '16 at 16:29
0

What I really want to count are methods, classes

nnnot rrreallly.... you can parse the xcode indexes or the output of nm -- or run doxygen.

calls to other classes etc

gcov -- or run doxygen

justin
  • 104,054
  • 14
  • 179
  • 226