"pio check --json-output" may contain extra output of program stdout
#4029 aperta il 11 ago 2021
Metriche repository
- Star
- (7329 star)
- Metriche merge PR
- (Merge medio 109g 16h) (5 PR mergiate in 30 g)
Descrizione
What kind of issue is this?
- [ x ] PlatformIO Core. If you’ve found a bug, please provide an information below.
You can erase any parts of this template not applicable to your Issue.
Configuration
Operating system: Win 10 x64
PlatformIO Version (platformio --version): 5.1.1
Description of problem
When running pio check --json-output > file.json, I expect file.json to contain only the JSON output of the analyzer.
However, if some analyzer tools are not installed, pio will install them and print progress to stdout, which will end up in json file, breaking it completely. There does not seem to be a way to get only JSON.
E.g.:
D:\DATA\Documents\PlatformIO\Projects\rclight>pio check --json-output
Tool Manager: Installing platformio/tool-cppcheck @ ~1.230.0
Downloading [####################################] 100%
Tool Manager: tool-cppcheck @ 1.230.0 has been installed!
[{"env": "stm32", "tool": "cppcheck", "duration": 50.67090845108032, "defects": [{"severity": "medium", "category": "warning", "message": "The function 'loop' is never used.", "file": "D:\\DATA\\Documents\\PlatformIO\\Projects\\rclight\\src\\main.cpp", "line": 76, "column": 0, "callstack": "[D:\\DATA\\Documents\\PlatformIO\\Projects\\rclight\\src\\main.cpp:76]", "id": "unusedFunction", "cwe": "561"}, {"severity": "low", "category": "style", "message": "The function 'setup' is never used.", "file": "D:\\DATA\\Documents\\PlatformIO\\Projects\\rclight\\src\\main.cpp", "line": 52, "column": 0, "callstack": "[D:\\DATA\\Documents\\PlatformIO\\Projects\\rclight\\src\\main.cpp:52]", "id": "unusedFunction", "cwe": "561"}], "succeeded": true, "stats": {"src": {"medium": 1, "low": 1}}}, {"env": "stm32", "tool": "clangtidy", "duration": 2.5736844539642334, "defects": [{"severity": "medium", "category": "warning", "message": "use of a signed integer operand with a binary bitwise operator ", "file": "D:\\DATA\\Documents\\PlatformIO\\Projects\\rclight\\src\\main.cpp", "line": 67, "column": 21, "callstack": null, "id": "hicpp-signed-bitwise", "cwe": null}, {"severity": "medium", "category": "warning", "message": "use of
a signed integer operand with a binary bitwise operator ", "file": "D:\\DATA\\Documents\\PlatformIO\\Projects\\rclight\\src\\main.cpp", "line": 68, "column": 21, "callstack": null, "id": "hicpp-signed-bitwise", "cwe": null}, {"severity": "medium", "category": "warning", "message": "50 is a magic number; consider replacing it with a named constant ", "file": "D:\\DATA\\Documents\\PlatformIO\\Projects\\rclight\\src\\main.cpp", "line": 73, "column": 11, "callstack": null, "id": "cppcoreguidelines-avoid-magic-numbers", "cwe": null}, {"severity": "medium", "category": "warning", "message": "50 is a magic number; consider replacing it with a named constant ", "file": "D:\\DATA\\Documents\\PlatformIO\\Projects\\rclight\\src\\main.cpp", "line": 73, "column": 11,
"callstack": null, "id": "readability-magic-numbers", "cwe": null}], "succeeded": true, "stats": {"src": {"medium": 4}}}]
Steps to Reproduce
- Ensure that you don't have all the tools to run analyzer (e.g. remove
tool-cppcheckfrom pio packages) - run
pio check --json-output
Actual Results
JSON and downloading progress is printed to stdout
Expected Results
Only the JSON output should be printed
If problems with PlatformIO Build System:
The content of platformio.ini:
Example:
[platformio]
default_envs = stm32
[env]
src_build_flags =
-Wall
-Werror
check_tool = cppcheck, clangtidy
[env:stm32]
platform = ststm32
board = bluepill_f103c8
framework = arduino
monitor_speed = 115200
upload_protocol = jlink
Source file to reproduce issue:
// any code will do
Additional info
This might be the cause for https://github.com/platformio/platformio-core/issues/3790