From 40574518ba524f662216eed4ff53494857817785 Mon Sep 17 00:00:00 2001 From: QuentinN42 Date: Tue, 8 Feb 2022 15:11:03 +0100 Subject: [PATCH] feat: changed json format according to @adrienverge comment --- yamllint/format.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/yamllint/format.py b/yamllint/format.py index a1eb294..e3d9b08 100644 --- a/yamllint/format.py +++ b/yamllint/format.py @@ -255,8 +255,23 @@ class JSONFormater(Formater): return list(map(self.show_problem, problems, [file] * len(problems))) def show_problem(self, problem, file): - """Show all problems of a specific file.""" - return {**problem.dict, "path": file} + """Show all problems of a specific file. + + The desired format is: + + >>> { + >>> "path": "dir/file.yaml", + >>> "line": 1337, + >>> "column": 42, + >>> "message": "duplication of key \"k\" in mapping", + >>> "rule": "key-duplicates", + >>> "level": "error" + >>> } + """ + dico = problem.dict + dico["message"] = dico.pop("desc") + dico["path"] = file + return dico class JunitFormater(Formater):