pylint
pylint copied to clipboard
Exporting to JSON does not honor score option
Steps to reproduce
- Run pylint on some random Python file or module:
pylint ~/Desktop/pylint_test.py
As you can see this outputs some warnings/scoring:
************* Module pylint_test
/home/administrator/Desktop/pylint_test.py:1:0: C0111: Missing module docstring (missing-docstring)
/home/administrator/Desktop/pylint_test.py:1:0: W0611: Unused import requests (unused-import)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
- Now run the same command but with
-f jsonto export it to JSON:
pylint ~/Desktop/pylint_test.py -f json
The output doesn't contain the scores now anymore:
[
{
"type": "convention",
"module": "pylint_test",
"obj": "",
"line": 1,
"column": 0,
"path": "/home/administrator/Desktop/pylint_test.py",
"symbol": "missing-docstring",
"message": "Missing module docstring",
"message-id": "C0111"
},
{
"type": "warning",
"module": "pylint_test",
"obj": "",
"line": 1,
"column": 0,
"path": "/home/administrator/Desktop/pylint_test.py",
"symbol": "unused-import",
"message": "Unused import requests",
"message-id": "W0611"
}
]
- Now execute it with
-f jsonagain but also supply the--score=yoption:
[
{
"type": "convention",
"module": "pylint_test",
"obj": "",
"line": 1,
"column": 0,
"path": "/home/administrator/Desktop/pylint_test.py",
"symbol": "missing-docstring",
"message": "Missing module docstring",
"message-id": "C0111"
},
{
"type": "warning",
"module": "pylint_test",
"obj": "",
"line": 1,
"column": 0,
"path": "/home/administrator/Desktop/pylint_test.py",
"symbol": "unused-import",
"message": "Unused import requests",
"message-id": "W0611"
}
]
Current behavior
The score is not outputted when exporting to JSON, not even when --score=y is activated.
Expected behavior
The score is added to the JSON, at least when --score=y is activated.
pylint --version output
pylint 2.3.0
astroid 2.2.0
Python 3.7.5 (default, Nov 20 2019, 09:21:52)
[GCC 9.2.1 20191008]
Thank you for the report, I can reproduce this bug.
I have a fix, but I think this has the potential to break countless continuous integration and annoy a lot of persons, so I'm going to wait for a review by someone else before merging.
The fix is not going to be merged before a major version see https://github.com/PyCQA/pylint/pull/3514#issuecomment-619834791
Ahh that's a pity that it won't come in a minor release :( Is there an estimate on when 3.0 more or less lands?
Yeah, sorry about that. I don't think there is a release date for 3.0.0 yet, @PCManticore might want to correct me though.
Shouldn't you have a branch for your next major release so things like this won't bitrot?
I created a 3.0.0.alpha branch, where it's fixed. Will close if we release alpha version 3.0.0a0.
Released in 3.0.0a0.
🥳 thanks a lot @Pierre-Sassoulas!
Reopening because the change was reverted in the 3.0 alpha branch. We can also simply add a new reporter for json directly in 2.x branch and deprecate the other json reporter.