Skip to content

Commit 6e91225

Browse files
committed
Revert changes to JSONReporter
1 parent 3c3f141 commit 6e91225

File tree

5 files changed

+17
-73
lines changed

5 files changed

+17
-73
lines changed

ChangeLog

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ Release date: TBA
2020
end of a node to the output of Pylint. If these numbers are unknown, they are represented
2121
by an empty string.
2222

23-
* Add ``end_line`` and ``end_column`` fields to the output of the ``JSONReporter``.
24-
2523
* Fix ``install graphiz`` message which isn't needed for puml output format.
2624

2725
* Fix ``simplify-boolean-expression`` when condition can be inferred as False.

doc/whatsnew/2.12.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,5 +203,3 @@ Other Changes
203203
With the standard ``TextReporter`` this will add the line and column number of the
204204
end of a node to the output of Pylint. If these numbers are unknown, they are represented
205205
by an empty string.
206-
207-
* Add ``end_line`` and ``end_column`` fields to the output of the ``JSONReporter``.

pylint/reporters/json_reporter.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ def display_messages(self, layout: Optional["Section"]) -> None:
3939
"obj": msg.obj,
4040
"line": msg.line,
4141
"column": msg.column,
42-
"end_line": msg.end_line,
43-
"end_column": msg.end_column,
4442
"path": msg.path,
4543
"symbol": msg.symbol,
4644
"message": msg.msg or "",

tests/unittest_reporters_json.py

Lines changed: 17 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -25,69 +25,29 @@
2525
from pylint.reporters.ureports.nodes import EvaluationSection
2626

2727
expected_score_message = "Expected score message"
28-
29-
30-
def test_simple_json_output_no_score() -> None:
31-
"""Test JSON reporter with no score"""
32-
message = {
33-
"msg": "line-too-long",
34-
"line": 1,
35-
"args": (1, 2),
36-
"end_line": None,
37-
"end_column": None,
38-
}
39-
expected = [
40-
[
41-
("column", 0),
42-
("end_column", None),
43-
("end_line", None),
44-
("line", 1),
45-
("message", "Line too long (1/2)"),
46-
("message-id", "C0301"),
47-
("module", "0123"),
48-
("obj", ""),
49-
("path", "0123"),
50-
("symbol", "line-too-long"),
51-
("type", "convention"),
52-
]
28+
expected_result = [
29+
[
30+
("column", 0),
31+
("line", 1),
32+
("message", "Line too long (1/2)"),
33+
("message-id", "C0301"),
34+
("module", "0123"),
35+
("obj", ""),
36+
("path", "0123"),
37+
("symbol", "line-too-long"),
38+
("type", "convention"),
5339
]
54-
report = get_linter_result(score=False, message=message)
55-
assert len(report) == 1
56-
report_result = [sorted(report[0].items(), key=lambda item: item[0])]
57-
assert report_result == expected
40+
]
5841

5942

60-
def test_simple_json_output_no_score_with_end_line() -> None:
61-
"""Test JSON reporter with no score with end_line and end_column"""
62-
message = {
63-
"msg": "line-too-long",
64-
"line": 1,
65-
"args": (1, 2),
66-
"end_line": 1,
67-
"end_column": 4,
68-
}
69-
expected = [
70-
[
71-
("column", 0),
72-
("end_column", 4),
73-
("end_line", 1),
74-
("line", 1),
75-
("message", "Line too long (1/2)"),
76-
("message-id", "C0301"),
77-
("module", "0123"),
78-
("obj", ""),
79-
("path", "0123"),
80-
("symbol", "line-too-long"),
81-
("type", "convention"),
82-
]
83-
]
84-
report = get_linter_result(score=False, message=message)
43+
def test_simple_json_output_no_score() -> None:
44+
report = get_linter_result(score=False)
8545
assert len(report) == 1
8646
report_result = [sorted(report[0].items(), key=lambda item: item[0])]
87-
assert report_result == expected
47+
assert report_result == expected_result
8848

8949

90-
def get_linter_result(score: bool, message: Dict[str, Any]) -> List[Dict[str, Any]]:
50+
def get_linter_result(score: bool) -> List[Dict[str, Any]]:
9151
output = StringIO()
9252
reporter = JSONReporter(output)
9353
linter = PyLinter(reporter=reporter)
@@ -96,13 +56,7 @@ def get_linter_result(score: bool, message: Dict[str, Any]) -> List[Dict[str, An
9656
linter.config.score = score
9757
linter.open()
9858
linter.set_current_module("0123")
99-
linter.add_message(
100-
message["msg"],
101-
line=message["line"],
102-
args=message["args"],
103-
end_lineno=message["end_line"],
104-
end_col_offset=message["end_column"],
105-
)
59+
linter.add_message("line-too-long", line=1, args=(1, 2))
10660
# we call those methods because we didn't actually run the checkers
10761
if score:
10862
reporter.display_reports(EvaluationSection(expected_score_message))

tests/unittest_reporting.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ def test_multi_format_output(tmp_path):
220220
' "obj": "",\n'
221221
' "line": 1,\n'
222222
' "column": 0,\n'
223-
' "end_line": null,\n'
224-
' "end_column": null,\n'
225223
f' "path": {escaped_source_file},\n'
226224
' "symbol": "missing-module-docstring",\n'
227225
' "message": "Missing module docstring",\n'
@@ -233,8 +231,6 @@ def test_multi_format_output(tmp_path):
233231
' "obj": "",\n'
234232
' "line": 1,\n'
235233
' "column": 0,\n'
236-
' "end_line": null,\n'
237-
' "end_column": null,\n'
238234
f' "path": {escaped_source_file},\n'
239235
' "symbol": "line-too-long",\n'
240236
' "message": "Line too long (1/2)",\n'

0 commit comments

Comments
 (0)