Métriques du dépôt
- Stars
- (48 085 stars)
- Métriques de merge PR
- (Merge moyen 11j 1h) (45 PRs mergées en 30 j)
Description
Summary
When rubocop or rspec outputs a minimal JSON response for --version (e.g. {"version":"1.86.2"}), RTK's parser rejects it because it expects a full struct containing files (rubocop) or examples (rspec) fields. The version IS correctly extracted but the parse warning is noisy.
Environment
- OS: Windows 10/11
- Shell: Git Bash (MINGW64) + PowerShell
- RTK version: 0.40.0
- rubocop version: 1.86.2
- rspec version: 3.13.2
Steps to Reproduce
# We created a .cmd wrapper that intercepts --version and outputs clean JSON:
# rubocop wrapper --version → {"version":"1.86.2"}
# rspec wrapper --version → {"version":"3.13.2"}
$ rtk rubocop --version
[rtk] rubocop: JSON parse failed (missing field `files` at line 1 column 20)
[rtk] rubocop (JSON parse error): output format not recognized, showing last 5 lines
{"version":"1.86.2"}
$ rtk rspec --version
[rtk] rspec: JSON parse failed (missing field `examples` at line 1 column 20), using text fallback
[rtk] rspec: output format not recognized, showing last 5 lines
{"version":"3.13.2"}
Root Cause
RTK's rubocop/rspec parsers validate the JSON response against a full struct:
rubocop: Expects output like {"files": [...], "summary": {...}}. The parser rejects a valid {"version":"1.86.2"} object because files is missing.
rspec: Expects output like {"examples": [...], "summary": {...}}. The parser rejects a valid {"version":"3.13.2"} object because examples is missing.
Expected Behavior
When --version is passed as the only argument, RTK should accept a simple {"version":"..."} JSON response. The full struct format only makes sense for lint/test runs, not for version queries.
Workaround
The version IS correctly output (the JSON shows in the "last 5 lines" fallback). This is cosmetic but noisy -- every --version call triggers the warning.
Related
- #1506 (rspec JSON parse on text output -- different symptom, same parser area)