platformio / platformio/platformio-core

"pio check --json-output" may contain extra output of program stdout

Open
#4,029 1 comment 1 reaction 1 assignee View on GitHub

@valeros is already working on this.

Since Sep 13, 2021.

help wanted static analysis
Dominant language
Python
Stars
9.5k
Forks
905
Avg merge
2d 13h
Merged PRs (30d)
2

Description

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
  1. Ensure that you don't have all the tools to run analyzer (e.g. remove tool-cppcheck from pio packages)
  2. 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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.