Are there any good tools to collect Objective-C metrics?
-
30-04-2021 - |
質問
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.
解決
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 ...
他のヒント
Lizard will do it. Check it out at https://github.com/terryyin/lizard.
You can try XClarify, a pretty complete objective-c code analyzer, and it's free for open source contributors.
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 :)
ProjectCodeMeter measures flow complexity (similar to McCabe cyclomatic complexity) on Objective-C code, but it doesn't count methods and classes though..
I use few tools for gathering code quality metrics:
- OCLint - Gather some metrics, like cyclomatic complexity, and enforce best practice - http://oclint.org
- Simian - Similarity Analyser - http://www.harukizaemon.com/simian/
- Clang analyzer - Same tool as in Xcode (Product -> Analyze), seems like a bit outdated though useful too. To perform it on CI see that: http://clang-analyzer.llvm.org/scan-build.html
- Coveralls - nice tools for visualization of unit test coverage - https://coveralls.io
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/
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
I just stumbled upon Xcode Statistician (link seems to be dead), but haven't tried it yet. The zip archive can be downloaded directly.