facebookarchive / pfff

Tools for code analysis, visualizations, or style-preserving source transformation.
http://github.com/facebook/pfff/wiki/Main
Other
2.44k stars 204 forks source link

[sgrep] Support for parseable reports #141

Closed aik099 closed 8 years ago

aik099 commented 8 years ago

Right now sgrep outputs data in human readable, but not machine parseable format. Are there any changes to add support for different formats e.g. xml or json?

For now I'll search for text:number lines (where text must be full path to a file) to identify file lines and all following lines till next such occurrence will be used as matched code fragment.

What I wanted to have is a way to use sgrep on a Build Server to fail a build, when problematic code was found.

aryx commented 8 years ago

You can use the -oneline option, it outputs matches in a normalized form: one line per match. It's not Json but it's very easy to parse. There is actually also a -gen_layer foo.json option, to generate a JSON file containing the list of matches, but the format of this JSON is oriented towards code visualization (see https://github.com/facebook/pfff/blob/master/h_program-lang/layer_code.ml )

aik099 commented 8 years ago

The -online option is perfect. It also does join matched multi-line statements into 1 line.