Facebook: Your code sucks, and we don't even have to run it to tell
And if you want to know how we know, here's some code
Facebook has released the source code to Infer, its static analysis tool, under the open source BSD license.
Static analysis tools like Infer are used as a complement to traditional dynamic software testing by scanning the source code of software to spot trouble spots without actually executing the code.
In a Thursday blog post, Facebook's tools team said Infer is used internally at the social network to spot potential bugs in its mobile apps, which are used by more than a billion people.
"Each month, hundreds of potential bugs identified by Facebook Infer are fixed by our developers before they are committed to our codebases and deployed to people's phones," the team said. "This saves our developers many hours finding and fixing bugs, and results in better products for people."
Facebook writes apps for Android and iOS, and thus Infer works on both the Android flavor of Java and Objective-C. But Facebook's engineers think Infer could have value for developers who work in "plain" Java and C, too.
Infer isn't as comprehensive a static analysis tool as those offered by, say, Black Duck or Coverity. At present, it can spot null pointer exceptions and resource leaks in Android and Java code, and memory leak problems in iOS and C code.
Its chief advantage is speed. By applying the mathematical tools of separation logic and bi-abduction, Infer is able to spot problems whenever code is modified in a matter of minutes, even in programs that are built from millions of lines of code.
When it finds problems in code, it not only reports them but it also automatically adds comments to the code to alert developers to the issues.
Facebook says it's releasing Infer as an open source project now in hopes that community participation will help it advance the tool beyond its current state, which its engineers describe as "1 per cent finished."
"In program verification, certainly, a tremendous amount remains to be done," Facebook's dev team said. "But, with continued progress, we believe there is also much more value that can be unlocked for programmers. We look forward to a future in which, with your help, program verification technology can prove more and more useful in helping programmers develop reliable code, fast."
The source code for Infer is available on GitHub, here. ®