LoginSignup
4
2

More than 5 years have passed since last update.

Windows環境で静的解析Inferを動かす

Last updated at Posted at 2017-06-09

facebookのOSS静的解析ツール「infer」
http://fbinfer.com/
javaではぬるぽが発生する(する可能性のある)箇所とメモリリークについて解析してくれる。
ぬるぽの解析ではfindbugsとかより断然つよそうだから入れてみたい感があったのだけど、いかんせんWindows非対応。
とりあえずdockerがあったのでdocker-toolboxで何とか動かしてみたっていうあれです。

前提

  • javaでしか動確してない
  • 2017/6/9現在

docker-toolboxの導入

https://www.docker.com/products/docker-toolbox
ここから取得

Dockerfileの取得

C直下にinferディレクトリを作っておく(別にどこでもOK)

Docker Quickstart Terminalを起動する。

Dockerfileと起動シェルを取得する。

$ curl https://raw.githubusercontent.com/facebook/infer/master/docker/Dockerfile > /c/infer/Dockerfile
$ curl https://raw.githubusercontent.com/facebook/infer/master/docker/run.sh > /c/infer/run.sh

そのままシェルを叩くとDockerfileがバグってて?(2017/6/9現在)失敗するのでDockerfileにちょっと手を入れる。
下記のように修正

# Base image
FROM buildpack-deps:xenial-curl

MAINTAINER I2

# Debian config
RUN apt-get update && \
    apt-get install -y --no-install-recommends \
            aspcud \
            autoconf \
            automake \
            gcc \
            g++ \
            git \
            groff-base \
            libc6-dev \
            libgmp-dev \
            libmpc-dev \
            libmpfr-dev \
            m4 \
            make \
            ncurses-dev \
            ocaml \
            opam \
            openjdk-8-jdk-headless \
            pkg-config \
            python2.7 \
            rsync \
            unzip \
            zlib1g-dev && \
    rm -rf /var/lib/apt/lists/*

# Download the latest Infer release
RUN git clone https://github.com/facebook/infer.git

RUN cd infer && ./build-infer.sh java

ENV PATH $PATH:/infer/infer/bin

docker-imageの作成・起動

シェルを叩く

$ cd /c/infer
$ ./run.sh

かなり待つ。動くようになる。

exampleに通すのもいいけどgitからクローンしてくれば既存プロジェクトに対しても解析できる。

これからやること

ぬるぽの解析がどうすごいのか別記事で書きたい

4
2
0

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
2