facebook / zstd

Zstandard - Fast real-time compression algorithm
http://www.zstd.net
Other
22.76k stars 2.03k forks source link

Enable LGTM for code analysis (Semmle) (and Facebook Infer) #2042

Open XVilka opened 4 years ago

XVilka commented 4 years ago

Using these tools will help to eliminate obvious errors. For zstd it is important from the security point of view, and C/C++ are supported. See:

Another tool (from your company, haha) with similar capabilities is Infer, it works with both C and C++, helping to find some bugs that are not overlapping with Coverity or LGTM (Semmle) due to the theory used. It's open source at GitHub too, but please be sure to use the version from master - there are some important bugs for C/C++ code were fixed recently and din't made into the release yet. There are docker images as well, to simplify the installation.

image

Cyan4973 commented 4 years ago

Hi @XVilka

Thanks for the suggestion. We already use a static analyzer as part of our Continuous Integration suite.

While it can be useful to look at additional static analyzers once in a while (and we do), it's not a good idea to multiply the nb of analyzers that are run continuously at each commit and PR. The reasons for this are :

This is different from running a static analyzer once in a while, looking at the output, and cherry picking the warnings that seem to help, either because they detected a genuine risk of bug (rare) or because it helps expressing the code in a way which is more readable or safer (harder to break).

These kind of reports can be useful, and we do accept them from time to time.

luben commented 4 years ago

@Cyan4973 , totally agree with you. But I think @XVilka didn't express them right. The LGTM static analysis work asynchronously so it does not interfere with the workflow. You can consult the reports when you decide. BTW, it's already running on the Zstd releases code base in my repo and you can look at the report: https://lgtm.com/projects/g/luben/zstd-jni/alerts

I personally have not found any bug through it but have fixed some obvious code smells.

Cyan4973 commented 4 years ago

That's a good point @luben , we could certainly have a look at https://lgtm.com/projects/g/facebook/zstd/?mode=list from time to time, since it's already listed there, and cherry pick a few warnings worth exploring.