Feature: Store hank output in json file#184
Conversation
|
Brujo Benavides seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
elbrujohalcon
left a comment
There was a problem hiding this comment.
This is a good idea, but (besides the changes that I suggest in the current code), what I would like to see is…
- That this would also be available as a
rebar.configoption with thenhanksection. - Documentation about this added to the
README.md. - Some tests that ensure that we don't go down on code coverage.
Thanks :)
elbrujohalcon
left a comment
There was a problem hiding this comment.
A few grammatical/syntactical/consistency-related amendments.
| Usage: rebar3 hank [-u <unused_ignores>] [-o <output_json_file>] | ||
|
|
||
| -u, --unused_ignores Warn on unused ignores (default: true). | ||
| -o, --output_json_file Emit output (in JSON format) to a file (default: empty string - meaning: donot emit output |
There was a problem hiding this comment.
| -o, --output_json_file Emit output (in JSON format) to a file (default: empty string - meaning: donot emit output | |
| -o, --output_json_file Emit output (in JSON format) to a file (default: empty string - meaning: do not emit output). |
|
|
||
| It's worth noting that, even when those warnings are printed, that doesn't affect the overall result of the command. That is, if Hank can't find any instances of oxbow code, it will return successfully (i.e. `exit code: 0`) even when it may print these warnings. | ||
|
|
||
| By default, if hank detect issues in your code, it will print those issue on the console. But you can save this result in JSON format, |
There was a problem hiding this comment.
| By default, if hank detect issues in your code, it will print those issue on the console. But you can save this result in JSON format, | |
| By default, if Hank detects issues in your code, it will print those issues on the console. But you can save this result in a file (in JSON format), |
| unused_callbacks -> | ||
| <<"Unused callback functions">>; | ||
| unnecessary_function_arguments -> | ||
| <<"Unused function arguments found">>; |
There was a problem hiding this comment.
| <<"Unused function arguments found">>; | |
| <<"Unused function arguments">>; |
| unnecessary_function_arguments -> | ||
| <<"Unused function arguments found">>; | ||
| single_use_hrls -> | ||
| <<"Hrl is only used once">> |
There was a problem hiding this comment.
| <<"Hrl is only used once">> | |
| <<"Hrl file only used once">> |
| unused_macros -> | ||
| <<"Unused Macros">>; | ||
| single_use_hrl_attrs -> | ||
| <<"Macro is only used once">>; |
There was a problem hiding this comment.
| <<"Macro is only used once">>; | |
| <<"Macro only used once">>; |
| single_use_hrl_attrs -> | ||
| <<"Macro is only used once">>; | ||
| unused_record_fields -> | ||
| <<"Field in the record is unused">>; |
There was a problem hiding this comment.
| <<"Field in the record is unused">>; | |
| <<"Unused field in record">>; |
| $o, | ||
| "output_json_file", | ||
| string, | ||
| "Emit output (in JSON format) to a file (default: empty string - meaning: donot emit output"} |
There was a problem hiding this comment.
| "Emit output (in JSON format) to a file (default: empty string - meaning: donot emit output"} | |
| "Emit output (in JSON format) to a file (default: empty string - meaning: do not emit output)"} |
|
@naman070 You should run So, at this stage, what's still missing is:
Thanks again :) |
|
@elbrujohalcon |
Yeah, I want users to be able to include this in their {hank, [{output_json_file, "/the/file/to/put/the/output.json"}]}.And have Hank pick it up every time they run |
|
|
@elbrujohalcon Does the output of rebar3 test supposed to look like this? |
It's telling you that Sheldon (the spell checker) doesn't know the word "JSON". |
| ConvertedResult = convert_data_to_binary(Result), | ||
| EncodedResult = jsx:encode(ConvertedResult), |
There was a problem hiding this comment.
It's not terribly wrong, but I would prefer to only do this if we're going to use it (i.e. First try to come up with the name of the output file, if it's not empty,... Only then convert, encode, and emit the output).
There was a problem hiding this comment.
And please document the rebar.config option in the README.md
| end | ||
| end. | ||
|
|
||
| -spec convert_data_to_binary([hank_rules:result()]) -> list(). |
There was a problem hiding this comment.
This function doesn't return binaries. Therefore, its name is wrong. A better name would be results_to_json.
Provided an argument based option where if command is run like:
rebar3 hank -o "output.json"
then it stores the generated output of hank in the json file.
This json file can further be used for better analysis of dead code.
Sample Json: