Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting to JSON does not honor score option #3504

Closed
Yenthe666 opened this issue Apr 21, 2020 · 10 comments · Fixed by #3514 or #8929
Closed

Exporting to JSON does not honor score option #3504

Yenthe666 opened this issue Apr 21, 2020 · 10 comments · Fixed by #3514 or #8929
Assignees
Labels
Milestone

Comments

@Yenthe666
Copy link

Steps to reproduce

  1. 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)
  1. Now run the same command but with -f json to 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"
    }
]
  1. Now execute it with -f json again but also supply the --score=y option:
[
    {
        "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]
@Pierre-Sassoulas
Copy link
Member

Thank you for the report, I can reproduce this bug.

Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Apr 26, 2020
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Apr 26, 2020
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Apr 26, 2020
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Apr 26, 2020
@Pierre-Sassoulas
Copy link
Member

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.

Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Apr 26, 2020
@Pierre-Sassoulas
Copy link
Member

The fix is not going to be merged before a major version see #3514 (comment)

@Pierre-Sassoulas Pierre-Sassoulas added this to the 3.0 milestone Apr 27, 2020
@Yenthe666
Copy link
Author

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?

@Pierre-Sassoulas
Copy link
Member

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.

@doctormo
Copy link

Shouldn't you have a branch for your next major release so things like this won't bitrot?

Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Sep 23, 2020
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Nov 8, 2020
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Jan 24, 2021
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Mar 6, 2021
Pierre-Sassoulas added a commit to Pierre-Sassoulas/pylint that referenced this issue Mar 7, 2021
This is a fix but I wonder... This looks like the fabled bug that will
break countless integration by being fixed. `--score=y` is the default setting,
and json is probably a prime candidate for automation. Is it reasonable to fix
it and ask everyone to change their option to `-s n`? I'm pretty sure no one
read the pylint's changelog unless we break their build.
Pierre-Sassoulas added a commit that referenced this issue Mar 7, 2021
This is a fix but I wonder... This looks like the fabled bug that will
break countless integration by being fixed. `--score=y` is the default setting,
and json is probably a prime candidate for automation. Is it reasonable to fix
it and ask everyone to change their option to `-s n`? I'm pretty sure no one
read the pylint's changelog unless we break their build.
@Pierre-Sassoulas
Copy link
Member

I created a 3.0.0.alpha branch, where it's fixed. Will close if we release alpha version 3.0.0a0.

@Pierre-Sassoulas Pierre-Sassoulas modified the milestones: 3.0, 3.0.0a0 Mar 7, 2021
Pierre-Sassoulas added a commit that referenced this issue Mar 28, 2021
This is a fix but I wonder... This looks like the fabled bug that will
break countless integration by being fixed. `--score=y` is the default setting,
and json is probably a prime candidate for automation. Is it reasonable to fix
it and ask everyone to change their option to `-s n`? I'm pretty sure no one
read the pylint's changelog unless we break their build.
Pierre-Sassoulas added a commit that referenced this issue Mar 29, 2021
This is a fix but I wonder... This looks like the fabled bug that will
break countless integration by being fixed. `--score=y` is the default setting,
and json is probably a prime candidate for automation. Is it reasonable to fix
it and ask everyone to change their option to `-s n`? I'm pretty sure no one
read the pylint's changelog unless we break their build.
@Pierre-Sassoulas
Copy link
Member

Released in 3.0.0a0.

@Yenthe666
Copy link
Author

🥳 thanks a lot @Pierre-Sassoulas!

Pierre-Sassoulas added a commit that referenced this issue Mar 30, 2021
This is a fix but I wonder... This looks like the fabled bug that will
break countless integration by being fixed. `--score=y` is the default setting,
and json is probably a prime candidate for automation. Is it reasonable to fix
it and ask everyone to change their option to `-s n`? I'm pretty sure no one
read the pylint's changelog unless we break their build.
Pierre-Sassoulas added a commit that referenced this issue Apr 9, 2021
This is a fix but I wonder... This looks like the fabled bug that will
break countless integration by being fixed. `--score=y` is the default setting,
and json is probably a prime candidate for automation. Is it reasonable to fix
it and ask everyone to change their option to `-s n`? I'm pretty sure no one
read the pylint's changelog unless we break their build.
Pierre-Sassoulas added a commit that referenced this issue Apr 24, 2021
This is a fix but I wonder... This looks like the fabled bug that will
break countless integration by being fixed. `--score=y` is the default setting,
and json is probably a prime candidate for automation. Is it reasonable to fix
it and ask everyone to change their option to `-s n`? I'm pretty sure no one
read the pylint's changelog unless we break their build.
@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Jul 4, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment