-
Notifications
You must be signed in to change notification settings - Fork 5
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
machine readable output #212
Conversation
This commit does several things: 1. Send all the log/debug/error/success messages to stderr This lays the groundwork for making anything we send to stdout machine-parseable (in one way or another) 2. Change mocking strategy under test By mocking logger.writeOut and logger.writeErr under test to supress console output under test (rather than mocking `console.log()` and friends directly), this makes it easier to quickly `console.log()` something while debugging a failing test but still supress most output 3. Explicitly pass AJV `strict: false` or `strict: "log"` based on verbosity level instead of mocking console methods. 4. Only output AJV strict log messages when verbosity >= 2
Codecov Report
@@ Coverage Diff @@
## main #212 +/- ##
==========================================
- Coverage 95.12% 94.24% -0.89%
==========================================
Files 10 11 +1
Lines 657 730 +73
Branches 149 160 +11
==========================================
+ Hits 625 688 +63
- Misses 32 40 +8
- Partials 0 2 +2
Continue to review full report at Codecov.
|
if (config.format === "json") { | ||
logger.log(JSON.stringify({ results }, null, 2)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO:
if (config.format === "sarif") {
...
Assuming I punt SARIF format to another issue, I think the one remaining thing to deal with here is array vs object. i.e:
I think for parsing in programming languages it doesn't make a huge amount of difference. The other likely way to parse this will be piping to |
Doesn't make a huge difference for parsing it with jq. If its an array the query to get all
If its an object, the equivalent is:
To get
For an object it would be:
So.. little from column A. Little from column B/ Another consideration is that something like I probably don't need to paginate this (its not an API), but making it an array works better for that. There's not much to choose here but I think I'm going to go with the object. At least then the internal data structure and output file are the same. |
Well it seemed like a good idea at the time 🙄 Lines 5 to 6 in e3f23b4
|
refs #148
TODO
write some testsdocumentation