Infer - A tool by facebook to detect bugs in Java and C/C++/Objective-C code before it ships
It is a static analysis tool - if you give Infer some Java or C/C++/Objective-C code it produces a list of potential bugs.
Anyone can use Infer to intercept critical bugs before they have shipped to users, and help prevent crashes or poor performance.
-
Docker should be installed as a prerequisite.
-
Open the terminal. Create a new directory with name infer and change your directory:
~# mkdir infer
~# cd infer
-
Now, run the below commands. It might take few minutes. Running as root user is not recommended Don't run the below commands as root user:
~# wget -O D ockerfile https://raw.githubusercontent.com/facebook/infer/master/docker/Dockerfile
~# wget -O run.sh https://raw.githubusercontent.com/facebook/infer/master/docker/run.sh
~# sh run~# .sh
-
Below command will list all the docker images. It should display the infer image.
~# docker images
-
Run a command on infer container: docker run -it < image name >
~# docker run -it infer
-
Go to examples directory:
~# cd ../infer/examples/
-
Always compile a file prior to running it with infer. This is to check there should be no compilation errors. Compile Hello.java file.
~# javac Hello.java
-
If there are no errors, now run it with infer. You will see errors shown by infer.
~# infer -- javac Hello.java
-
Running sample android app. Build the app so that there would be no errors.
~# cd /infer/examples/android_hello
~# ./gradlew build
-
Finding errors in sample app with infer
~# infer -- ./gradlew build
-
Running examples in java_hello folder:
~# cd /infer/examples/java_hello
infer -- javac Hello.java Resources.java Pointers.java
-
To exit from docker container:
~# exit
-
To copy your files to docker container:
~# docker cp < path of file on your system > < docker container id > : <path of destination in container>
-
To obtain container id, run:
~# docker ps