Site icon NgDeveloper

Facebook Infer: Finding bugs before it goes live

facebook infer

facebook infer static analyzer:

Today facebook released an open-sourcing development tool named facebook infer static analyzer to identify the bugs before you ship. Facebook infer is a tool to identify the bugs before it goes live, meaning we can not write a bug code which million people use/experience. A single bug with this much user base application will create much problem which we can not even imagine. So facebook releasing their own bug finding tool before it comes to live named facebook infer.

They are using this tool to find the bugs on their mobile applications (android and ios) and also for messenger and instagram.

What is facebook infer ?

Facebook infer is a automated static analyzer which scans the complete programs for correctness.

 

Why we need facebook infer ?

Generally a null pointer exception and memory leakage issues are source and major reason for application crashes. At present, facebook infer can find these kind of bugs before making it to live. Almost all the flows to be checked at once using this tool makes really a great sense and reduce the major and high severiorty defects.

facebook infer static analyzer – a great tool for all the developers:

Testing is more difficult and hectic work than the development works. To test the single bug fix, a tester need to test the complete functionality of the application to ensure no other impacts, which is again a tough job for the testers and hence so much resources and time also needed for the repeated cases.

 

So what facebook infer static analyzer can do here ?

Running a facebook infer for the codebase finds many defects which saves the developers many hours finding and fixing the bugs and also results in better products at end user perspective.

You can find complete details about fb infer here

facebook infer static analyzer: finding bugs in Java Sample Program

Sample Java Bug Program:

HelloInfer.java

This is the untested sample java program written just to explain the facebook infer behaviour.

[java]

class HelloInfer.java {
public static void main(String[] args){
HelloInfer hInfer = new HelloInfer();
String strValue = hInfer.testInfer();
System.out.println(strValue);
}

public String testInfer(){
String str = null;
// Which throws null pointer exception.
return str.length();
}
}

[/java]

Running facebook infer for the above program:

[plain]

infer — javac HelloInfer.java

[/plain]

fbinfer response:

[plain]

Starting Analysis
Analysis Done

HelloInfer.java:11: NULL_DEREFERENCE
object str last assigned on line 9 could be null and it is dereferenced at line 11

[/plain]

 

Correction after facebook infer findings:

[java]

public String testInfer(){
String str = null;
return str == null ? "":str.length();
}

[/java]

 

Now Running facebook infer again:

[plain]infer — javac HelloInfer.java[/plain]

[plain]

Starting Analysis
Analysis Done

No issues found

[/plain]

 

Prerequiste:

To run facebook infer you need python (>=2.7).

Downloading facebook infer:

Currently it has been released only for Mac OS and Linux.

For Mac OS: Download facebook infer for Mac OS

For Linux : Download facebook infer for Linux

Since facebook infer windows package is not released, we could not share you the installation guide and real time sample programs. We will be updating this post with the examples once the fb infer windows package released. Bookmark this page or subscribe us to not to miss our tech updates.

Exit mobile version