Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Dialyzer plugin option to save raw output to the dialyzer warnings file #2524

Closed
srijan opened this issue Apr 11, 2021 · 5 comments
Labels
enhancement new behaviour or additional functionality

Comments

@srijan
Copy link
Contributor

srijan commented Apr 11, 2021

Dialyzer supports the --raw flag to:

... output the raw analysis results (Erlang terms) instead of the formatted result. The raw format is easier to post-process (for example, to filter warnings or to output HTML pages).

This will let us process the result file using Erlang code to output an HTML page.

Suggested option name: output_format, with possible values: formatted and raw, with default as formatted.

If people are okay with this, I can raise a PR with a cleaned up version of greyorange@9e65394

@srijan srijan changed the title [Feature] Dialyzer plugin option for saving raw output to the dialyzer warnings file [Feature] Dialyzer plugin option to save raw output to the dialyzer warnings file Apr 11, 2021
@ferd
Copy link
Collaborator

ferd commented Apr 11, 2021

yeah that sounds like something that would require an absolute minimal amount of code and should be no problem to support by just dropping the format_warnings internal call to just go for the default format. One thing you'll probably find annoying is that the file paths require custom formatting to be in the format you expect, and that is done based on the Opts term we have internally since we use paths in _build/ when analyzing.

@ferd ferd added the enhancement new behaviour or additional functionality label Apr 14, 2021
@srijan
Copy link
Contributor Author

srijan commented Apr 15, 2021

I found that the Source reported in the raw data has the actual source path, not _build/* (except for deps).

But, I still wanted paths relative to project root, and also wanted to extract app names (for multi-app projects). So, went with a custom rebar plugin approach to generate the HTML.

Another benefit of running as a plugin: I can use the rebar_dialyzer_format:format_warnings/2 function. I used a frontend JS library to convert the ansi color codes to HTML span definitions.

Report looks like this:
image

Will raise the PR for raw output format.

@paulo-ferraz-oliveira
Copy link
Contributor

Oh, that's nice.

@srijan, if you share details on what JS lib. you used I/we could work on a plugin for this - what say you?
(sorry for hijacking the issue - feel free to hit me up on the Erlanger Slack)

@srijan
Copy link
Contributor Author

srijan commented Apr 16, 2021

@paulo-ferraz-oliveira - this is the plugin: https://github.com/srijan/rebar3_dialyzer_html (still work in progress, so ignore the bad code).

I'm using ansi_up to convert the warning text after page load.

One potential improvement is to actually do the conversion in Erlang side to remove the dependency on JS.

@paulo-ferraz-oliveira
Copy link
Contributor

Ah, it's already a plugin. Good 😄 Don't forget to announce when 0.1.0 (or whatever you choose comes out) on Slack. Will take a look. Great stuff, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement new behaviour or additional functionality
Projects
None yet
Development

No branches or pull requests

3 participants