diff --git a/ChangeLog b/ChangeLog index 2bdfc4ed88..810de3d491 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,8 +20,6 @@ Release date: TBA end of a node to the output of Pylint. If these numbers are unknown, they are represented by an empty string. -* Add ``end_line`` and ``end_column`` fields to the output of the ``JSONReporter``. - * Fix ``install graphiz`` message which isn't needed for puml output format. * Fix ``simplify-boolean-expression`` when condition can be inferred as False. diff --git a/doc/whatsnew/2.12.rst b/doc/whatsnew/2.12.rst index e6a8ccce9f..0d8affd1d2 100644 --- a/doc/whatsnew/2.12.rst +++ b/doc/whatsnew/2.12.rst @@ -203,5 +203,3 @@ Other Changes With the standard ``TextReporter`` this will add the line and column number of the end of a node to the output of Pylint. If these numbers are unknown, they are represented by an empty string. - -* Add ``end_line`` and ``end_column`` fields to the output of the ``JSONReporter``. diff --git a/pylint/reporters/json_reporter.py b/pylint/reporters/json_reporter.py index 2c7bac45cf..87949c1c44 100644 --- a/pylint/reporters/json_reporter.py +++ b/pylint/reporters/json_reporter.py @@ -39,8 +39,6 @@ def display_messages(self, layout: Optional["Section"]) -> None: "obj": msg.obj, "line": msg.line, "column": msg.column, - "end_line": msg.end_line, - "end_column": msg.end_column, "path": msg.path, "symbol": msg.symbol, "message": msg.msg or "", diff --git a/tests/unittest_reporters_json.py b/tests/unittest_reporters_json.py index fb5598d255..ed6ed74a4d 100644 --- a/tests/unittest_reporters_json.py +++ b/tests/unittest_reporters_json.py @@ -25,69 +25,29 @@ from pylint.reporters.ureports.nodes import EvaluationSection expected_score_message = "Expected score message" - - -def test_simple_json_output_no_score() -> None: - """Test JSON reporter with no score""" - message = { - "msg": "line-too-long", - "line": 1, - "args": (1, 2), - "end_line": None, - "end_column": None, - } - expected = [ - [ - ("column", 0), - ("end_column", None), - ("end_line", None), - ("line", 1), - ("message", "Line too long (1/2)"), - ("message-id", "C0301"), - ("module", "0123"), - ("obj", ""), - ("path", "0123"), - ("symbol", "line-too-long"), - ("type", "convention"), - ] +expected_result = [ + [ + ("column", 0), + ("line", 1), + ("message", "Line too long (1/2)"), + ("message-id", "C0301"), + ("module", "0123"), + ("obj", ""), + ("path", "0123"), + ("symbol", "line-too-long"), + ("type", "convention"), ] - report = get_linter_result(score=False, message=message) - assert len(report) == 1 - report_result = [sorted(report[0].items(), key=lambda item: item[0])] - assert report_result == expected +] -def test_simple_json_output_no_score_with_end_line() -> None: - """Test JSON reporter with no score with end_line and end_column""" - message = { - "msg": "line-too-long", - "line": 1, - "args": (1, 2), - "end_line": 1, - "end_column": 4, - } - expected = [ - [ - ("column", 0), - ("end_column", 4), - ("end_line", 1), - ("line", 1), - ("message", "Line too long (1/2)"), - ("message-id", "C0301"), - ("module", "0123"), - ("obj", ""), - ("path", "0123"), - ("symbol", "line-too-long"), - ("type", "convention"), - ] - ] - report = get_linter_result(score=False, message=message) +def test_simple_json_output_no_score() -> None: + report = get_linter_result(score=False) assert len(report) == 1 report_result = [sorted(report[0].items(), key=lambda item: item[0])] - assert report_result == expected + assert report_result == expected_result -def get_linter_result(score: bool, message: Dict[str, Any]) -> List[Dict[str, Any]]: +def get_linter_result(score: bool) -> List[Dict[str, Any]]: output = StringIO() reporter = JSONReporter(output) linter = PyLinter(reporter=reporter) @@ -96,13 +56,7 @@ def get_linter_result(score: bool, message: Dict[str, Any]) -> List[Dict[str, An linter.config.score = score linter.open() linter.set_current_module("0123") - linter.add_message( - message["msg"], - line=message["line"], - args=message["args"], - end_lineno=message["end_line"], - end_col_offset=message["end_column"], - ) + linter.add_message("line-too-long", line=1, args=(1, 2)) # we call those methods because we didn't actually run the checkers if score: reporter.display_reports(EvaluationSection(expected_score_message)) diff --git a/tests/unittest_reporting.py b/tests/unittest_reporting.py index 5252d4295b..e98eadfb90 100644 --- a/tests/unittest_reporting.py +++ b/tests/unittest_reporting.py @@ -220,8 +220,6 @@ def test_multi_format_output(tmp_path): ' "obj": "",\n' ' "line": 1,\n' ' "column": 0,\n' - ' "end_line": null,\n' - ' "end_column": null,\n' f' "path": {escaped_source_file},\n' ' "symbol": "missing-module-docstring",\n' ' "message": "Missing module docstring",\n' @@ -233,8 +231,6 @@ def test_multi_format_output(tmp_path): ' "obj": "",\n' ' "line": 1,\n' ' "column": 0,\n' - ' "end_line": null,\n' - ' "end_column": null,\n' f' "path": {escaped_source_file},\n' ' "symbol": "line-too-long",\n' ' "message": "Line too long (1/2)",\n'