LoginSignup
4
4

More than 5 years have passed since last update.

Infer触ってみたのでメモ

Last updated at Posted at 2015-07-05

Infer

  • Facebook産の静的解析ツール
    • iOSとAndroidをターゲットとしている。
    • メモリリークやNull Dereference等を検出できる。
    • 検出できる項目は infer-bug-types を参照。
  • その他、詳しいことは、facebookのInferに関する投稿を参照。

Download & Install

homebrewでのインストール

コメントにいただきました通り、brew caskから削除されてしまったようです。。。opamを使うしかなさそうです。

brew cask install infer だけで終わり。
見つからなかった場合は brew cask update すれば見つかるはず。

opamでのインストール

INSTALL.mdには、パッケージ管理マネージャであるopamをインストールし、opamを用いて必要なパッケージをインストールする方法が記載されている(2015年7月1日時点)。

  1. $brew install opam
  2. $git clone https://github.com/facebook/infer.git
  3. $opam init --comp=4.01.0
  4. $eval `opam config env`
  5. $opam install sawja.1.5 atdgen.1.5.0 javalib.2.3a extlib.1.5.4
  6. $cd infer
  7. $./update-fcp.sh && ../facebook-clang-plugin/clang/setup.sh && ./compile-fcp.sh
  8. $make -C infer
  9. $export PATH=`pwd`/infer/bin:$PATH

静的解析の実行

inferにxcodebuildを食わせる。
$infer -- xcodebuild -project [project].xcodeproj -configuration Debug -sdk iphoneos

inferコマンドを実行すると、infer-outディレクトリが生成される。
infer-outディレクトリ内には、実行結果や実行ログがテキストファイルで保存されている。
infer-out/bugs.txt に静的解析により検出された項目が記載される。

block構文やdelegeteメソッドでNull Dereferenceを検出してしまう静的解析ツールもあるが、Inferでは検出されなかったのが好印象。

4
4
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4