Add machine-readable JSON report (00BiocCheck.json) - #258
Open
seandavi wants to merge 2 commits into
Open
Conversation
Write '00BiocCheck.json' alongside '00BiocCheck.log' in the
'<PackageName>.BiocCheck' folder. The report carries the full text output
plus structured fields so that CI jobs, editors, and other tools can act on
BiocCheck results without parsing text:
* 'summary' with the error, warning, and note counts and an overall
'status' ('error', 'warning', 'note', or 'ok')
* 'entries', one record per condition raised, with the originating check
function ('checkFun') as the stable identifier, the check title, the
message, the reported files, and parsed file 'locations'
* 'text', the plain report line by line
The check function name and the check title were already recorded; they are
now exposed rather than being flattened into the text log. Also fix the
doubly encoded 'toJSON'/'fromJSON' methods, have 'toJSON' return the JSON
when no file is given, and report package-relative file paths in the coding
practice checks so that locations resolve consistently.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0153nSC2TGmUwxcXt8iCvweV
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## devel #258 +/- ##
==========================================
+ Coverage 69.17% 70.06% +0.89%
==========================================
Files 15 15
Lines 3046 3117 +71
==========================================
+ Hits 2107 2184 +77
+ Misses 939 933 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The added roxygen prose and vignette example exceeded 80 characters once expanded into Rd, which BiocCheck flags on its own source. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0153nSC2TGmUwxcXt8iCvweV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
BiocCheckresults are currently only available as text. Anything that wantsto act on them — a CI gate, an editor, a bot that triages submissions — has to
parse
00BiocCheck.log, which is fragile and breaks whenever a message isreworded.
Nearly everything needed is already collected internally:
handleCondition()records the originating check function via
sys.call,handleCheck()recordsthe check title, and
add()knows the severity. They are just flattened intotext at render time. This PR exposes them.
What this adds
Every run now writes
00BiocCheck.jsonnext to00BiocCheck.login the<PackageName>.BiocCheckfolder:{ "metadata": { "Package": "MyPackage", "PackageVersion": "0.99.0", "...": "" }, "summary": { "error": 1, "warning": 2, "note": 5 }, "status": "error", "entries": [ { "severity": "warning", "checkFun": "checkFormatting", "check": "Checking formatting of DESCRIPTION, NAMESPACE, ...", "message": "Consider shorter lines; 3 lines (1%) are > 80 characters long.", "help_text": "First few lines:", "details": ["R/foo.R#L12 x <- some_very_long_call( ..."], "locations": [ { "file": "R/foo.R", "line": 12 } ] } ], "text": ["* Checking formatting of DESCRIPTION, NAMESPACE, ...", "..."] }summary/statusgive the tallies and the most severe condition(
error,warning,note, orok), so a gate is one line:jq -e '.summary.error == 0' MyPackage.BiocCheck/00BiocCheck.jsonentrieshas one record per condition raised.checkFunis the stableidentifier to key on;
checkis the human-readable title, which is free tochange between releases.
locationsare parsed insideBiocCheckfrom the two location formats thechecks already emit (
.lineReportandsprintf("%s (line %d, column %d)"), with or without a leading symbolname), so consumers never parse them. Chunk-relative vignette locations are
deliberately omitted rather than reported as file lines.
textis the log file, line for line — the JSON is a superset of the textreport, nothing to cross-reference.
The same data is on the returned object:
bc$getStatus(),bc$entries, andbc$toJSON()(returns the JSON string when nofileis given).Implementation notes
entriesfield on theBiocCheckclass, appended inadd()andfiltered in
zero(). The existinglog/composeReport/reporttextpath is untouched, so there is no change to
00BiocCheck.log.toJSON/fromJSONwere doubly encoding the payload (toJSON()to astring, then
write_json()of that string) and are rewritten. They were notcalled anywhere in the package, so no on-disk format was in use.
detailsis always an array,help_textandlocationsarenullwhen absent,metadatais always an object.jsonlitemoves fromSuggeststoImports. The alternative — an opt-inflag — would need to be set correctly in every CI job to be useful, and it
is a small, dependency-free package. Happy to switch it to a dot-option if
you would rather keep it optional.
Two judgment calls worth your review
bad_coding.R) whileevery other check reports package-relative paths (
R/bad_coding.R). Theynow use
.getDirFiles()solocations.fileresolves consistently. Thischanges existing text output, so it is easy to drop if you consider it
out of scope.
Checklist
short README section)
inst/tinytest/test_json.R, 36 assertions covering theschema,
summary/status, both location formats, the round trip, and thefiles written by
report()R CMD build&R CMD check— full local suite passes (221assertions); an end-to-end run on
testpkg0yields 49 entries matching13 errors / 17 warnings / 19 notes with 113 parsed locations
@LiNk-NY @lshep for review.
🤖 Generated with Claude Code
https://claude.ai/code/session_0153nSC2TGmUwxcXt8iCvweV