静态的解析:
iOS: Xcode->Product->Analyze
Android: Lint
複雑度調査:
iOS: hfcca14.py
Android: Metrics
Android: Metrics
Eclipse plug-in:
http://metrics.sourceforge.net
→net.sourceforge.metrics-site-1.3.5.zip
iOS: 実施方法:
①hfcca14.pyとRemoconUIのソースコードを同じファイルパスにコピーしておく。
②MACBOOKのコマンドに下記を実行してください。
./hfcca14.py RemoconUI
iOS: 複雑度調査
説明
ソースコードの複雑度を調査する。
サイクロマチック数を算出し、複雑度高いものに対して、改善・リファクタリングを検討する。
改善策の例:
・関数を分ける
→ 1関数あたり40~50ステップ程度とする。
40~50ステップだと、スクロールなしで関数全体を見渡せるギリギリのサイズ。
・処理を簡略化する
→ 無駄なループはないか? ネストが深くなりすぎていないか?
サイクロマチック数については、下記URLを参照。
日本語: http://ja.wikipedia.org/wiki/%E5%BE%AA%E7%92%B0%E7%9A%84%E8%A4%87%E9%9B%91%E5%BA%A6
中国語: http://zh.wikipedia.org/wiki/%E5%BE%AA%E7%92%B0%E8%A4%87%E9%9B%9C%E5%BA%A6
英語: http://en.wikipedia.org/wiki/Cyclomatic_complexity
Objective-Cに対応しているツールは少ない。
無償だと、
http://code.google.com/p/headerfile-free-cyclomatic-complexity-analyzer/
があるが、完全ではないらしい。
完全ではないにしろ、ある程度の複雑度調査はできるので、こちらを採用する。
動作にはPythonが必要。MacOSであれば、普通に使えるので問題ないだろう。
hfcca14.py - 解析ツール。Pythonが必要。
This tool will calculate the cycolomatic complexity of C/C++/Objective C code without caring about header files and preprocessors. So the tool is actually calculating how complex the code 'looks' rather than how complex the code 'is'.
People will need this tool because it's often very hard to get all the include folders and files right with a similar tool, but we don't really need that kind of accuracy when come to cyclomatic complexity.
Usage: python hfcca.py [options] [PATH or FILE] [PATH] ...
or: python hfcca.py install
Than you can run hfcca.py from any where.
hfcca (verion 1.5) is a simple code complexity counter without caring about
the C/C++ header files. It can deal with C/C++/ObjectiveC & TNSDL code. It count the NLOC
(lines of code without comments), CCN (cyclomatic complexity number) and
token count of functions.
Options:
-h, --help show this help message and exit
-v, --verbose Output in verbose mode (long function name)
-C CCN, --CCN=CCN Threshold for cyclomatic complexity number warning.
functions with CCN bigger than this number will be
shown in warning
-w, --warnings_only Show warnings only
-i NUMBER, --ignore_warnings=NUMBER
If the number of warnings is equal or less than the
number, the tool will exit normally, otherwize it will
generate error. Useful in makefile when improving
legacy code.
-x EXCLUDE, --exclude=EXCLUDE
Exclude data files that match this regular expression
-X, --xml Generate XML in cppncss style instead of the normal
tabular output. Useful to generate report in Hudson
server
-p, --preprocess Use preprocessor, always ignore the #else branch. By
default, source_analyzer just ignore any preprocessor
statement.
-a ARGUMENTS, --arguments=ARGUMENTS
Limit for number of parameters
-P, --no_preprocessor_count
By default, a #if will also increase the complexity.
Adding this option to ignore them
-t WORKING_THREADS, --working_threads=WORKING_THREADS
number of working threads. The default value is 1.
代码覆盖率
//www.greatytc.com/p/9d2234bdacc7
一:代码覆盖率简介 -- iOS真机调试
代码覆盖(英语:Code coverage)是软件测试中的一种度量,描述程序中源代码被测试的比例和程度,所得比例称为代码覆盖率。
二:Xcode (iOS )如何支持代码覆盖率 -- XcodeCoverage
1、下载codeCoverage
下载地址:https://github.com/jonreid/XcodeCoverage
.....
.....