Wikimedia Developer Support

How to make Phan return only relevant errors

I was finally able to configure phan to analyze the PHP files I touched. But I ran into some problems which I can simplify in two questions:

  1. It tooks a lot of memory to run, more memory than any other process on my machine. Is there any way to reduce this memory usage?

  2. If I finally get the result after exhausting my machine, the result is also hard to understand. It returns multitude of irrelevant “errors” and “warnings” from files which I did not touch (and have no intention of touching!). When I decide to just send it for CI check and see the errors there, the result of check by Jenkins actually shows only the specific problem without all those irrelevant errors and warnings that I got locally.
    So my question here is how to configure it to return ONLY relevant error, the same error that would be returned If I decide to pass the work to Jenkins. Thanks.

Static analysis is a memory heavy problem

It should be noted we use two separate phan things. We use normal phan, and seccheck phan. The latter is much more memory heavy than the former, although both are quite memory heavy.

So generally speaking, to make sure you get the same errors, ensure you are running the exact same versio of phan as ci, and using the same config options (e.g. using the .phan directory that ships with mw).

If you really want best reoroducibility, you should use the docker images that the ci server uses. Doing so isnt the most well documented, but might be a helpful starting point.

1 Like