feat: fixed some isues
This commit is contained in:
@@ -143,8 +143,8 @@ class FormatersTestCase(unittest.TestCase):
|
||||
(GithubFormater(True), ONE_WARNING, ""),
|
||||
(ColoredFormater(True), ONE_WARNING, ""),
|
||||
(StandardFormater(True), ONE_WARNING, ""),
|
||||
(JSONFormater(True), ONE_WARNING, '[\n {\n "line": 1,\n "column": 2,\n "rule": "my-rule",\n "level": "warning",\n "message": "desc of warn",\n "path": "file1.yml"\n }\n]\n'),
|
||||
(CodeclimateFormater(True), ONE_WARNING, '[\n {\n "type": "issue",\n "check_name": "my-rule",\n "description": "desc of warn",\n "content": "desc of warn (my-rule)",\n "categories": [\n "Style"\n ],\n "location": {\n "path": "file1.yml",\n "positions": {\n "begin": {\n "line": 1,\n "column": 2\n }\n }\n },\n "remediation_points": 1000,\n "severity": "minor"\n }\n]\n'),
|
||||
(JSONFormater(True), ONE_WARNING, '[]\n'),
|
||||
(CodeclimateFormater(True), ONE_WARNING, '[]\n'),
|
||||
(ParsableFormater(True), ONE_ERROR, 'file1.yml:1:2: [error] desc of error (my-rule)\n'),
|
||||
(GithubFormater(True), ONE_ERROR, '::group::file1.yml\n::error file=file1.yml,line=1,col=2::1:2 [my-rule] desc of error\n::endgroup::\n\n'),
|
||||
(ColoredFormater(True), ONE_ERROR, '\x1b[4mfile1.yml\x1b[0m\n \x1b[2m1:2\x1b[0m \x1b[31merror\x1b[0m desc of error \x1b[2m(my-rule)\x1b[0m\n\n'),
|
||||
@@ -154,6 +154,8 @@ class FormatersTestCase(unittest.TestCase):
|
||||
)
|
||||
@ddt.unpack
|
||||
def test_all_formaters(self, inst, inp, ret):
|
||||
if inst.show_problems_for_all_files(inp) != ret:
|
||||
print(f"\n{inst.__class__.__name__}\n" + inst.show_problems_for_all_files(inp))
|
||||
self.assertEqual(
|
||||
inst.show_problems_for_all_files(inp),
|
||||
ret
|
||||
|
||||
@@ -252,7 +252,16 @@ class JSONFormater(Formater):
|
||||
|
||||
def show_problems_for_file(self, problems, file):
|
||||
"""Show all problems of a specific file."""
|
||||
return list(map(self.show_problem, problems, [file] * len(problems)))
|
||||
return list(
|
||||
filter(
|
||||
lambda x: x["level"] == "error" or not self.no_warn,
|
||||
map(
|
||||
self.show_problem,
|
||||
problems,
|
||||
[file] * len(problems)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def show_problem(self, problem, file):
|
||||
"""Show all problems of a specific file.
|
||||
@@ -332,7 +341,16 @@ class CodeclimateFormater(Formater):
|
||||
|
||||
def show_problems_for_file(self, problems, file):
|
||||
"""Show all problems of a specific file."""
|
||||
return list(map(self.show_problem, problems, [file] * len(problems)))
|
||||
return list(
|
||||
filter(
|
||||
lambda x: x["severity"] == "major" or not self.no_warn,
|
||||
map(
|
||||
self.show_problem,
|
||||
problems,
|
||||
[file] * len(problems)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def show_problem(self, problem, file):
|
||||
"""Show all problems of a specific file.
|
||||
|
||||
Reference in New Issue
Block a user