fix: filter None to exclude them
This commit is contained in:
@@ -106,6 +106,9 @@ class ParsableFormater(Formater):
|
|||||||
"""Show all problems of a specific file."""
|
"""Show all problems of a specific file."""
|
||||||
string = ''
|
string = ''
|
||||||
for problem in problems:
|
for problem in problems:
|
||||||
|
if problem.level is not None and (
|
||||||
|
problem.level == "error" or not self.no_warn
|
||||||
|
):
|
||||||
string += self.show_problem(problem, file)
|
string += self.show_problem(problem, file)
|
||||||
return string
|
return string
|
||||||
|
|
||||||
@@ -140,6 +143,9 @@ class GithubFormater(Formater):
|
|||||||
"""Show all problems of a specific file."""
|
"""Show all problems of a specific file."""
|
||||||
string = '::group::%s\n' % file
|
string = '::group::%s\n' % file
|
||||||
for problem in problems:
|
for problem in problems:
|
||||||
|
if problem.level is not None and (
|
||||||
|
problem.level == "error" or not self.no_warn
|
||||||
|
):
|
||||||
string += self.show_problem(problem, file)
|
string += self.show_problem(problem, file)
|
||||||
if string == '::group::%s\n' % file:
|
if string == '::group::%s\n' % file:
|
||||||
return ''
|
return ''
|
||||||
@@ -181,6 +187,9 @@ class ColoredFormater(Formater):
|
|||||||
"""Show all problems of a specific file."""
|
"""Show all problems of a specific file."""
|
||||||
string = '\033[4m%s\033[0m\n' % file
|
string = '\033[4m%s\033[0m\n' % file
|
||||||
for problem in problems:
|
for problem in problems:
|
||||||
|
if problem.level is not None and (
|
||||||
|
problem.level == "error" or not self.no_warn
|
||||||
|
):
|
||||||
string += self.show_problem(problem, file)
|
string += self.show_problem(problem, file)
|
||||||
if string == '\033[4m%s\033[0m\n' % file:
|
if string == '\033[4m%s\033[0m\n' % file:
|
||||||
return ''
|
return ''
|
||||||
@@ -219,6 +228,9 @@ class StandardFormater(Formater):
|
|||||||
"""Show all problems of a specific file."""
|
"""Show all problems of a specific file."""
|
||||||
string = file + '\n'
|
string = file + '\n'
|
||||||
for problem in problems:
|
for problem in problems:
|
||||||
|
if problem.level is not None and (
|
||||||
|
problem.level == "error" or not self.no_warn
|
||||||
|
):
|
||||||
string += self.show_problem(problem, file)
|
string += self.show_problem(problem, file)
|
||||||
if string == file + '\n':
|
if string == file + '\n':
|
||||||
return ''
|
return ''
|
||||||
@@ -252,16 +264,13 @@ class JSONFormater(Formater):
|
|||||||
|
|
||||||
def show_problems_for_file(self, problems, file):
|
def show_problems_for_file(self, problems, file):
|
||||||
"""Show all problems of a specific file."""
|
"""Show all problems of a specific file."""
|
||||||
return list(
|
lst = []
|
||||||
filter(
|
for problem in problems:
|
||||||
lambda x: x["level"] == "error" or not self.no_warn,
|
if problem.level is not None and (
|
||||||
map(
|
problem.level == "error" or not self.no_warn
|
||||||
self.show_problem,
|
):
|
||||||
problems,
|
lst.append(self.show_problem(problem, file))
|
||||||
[file] * len(problems)
|
return lst
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def show_problem(self, problem, file):
|
def show_problem(self, problem, file):
|
||||||
"""Show all problems of a specific file.
|
"""Show all problems of a specific file.
|
||||||
@@ -321,7 +330,13 @@ class JunitFormater(Formater):
|
|||||||
|
|
||||||
def show_problems_for_file(self, problems, file):
|
def show_problems_for_file(self, problems, file):
|
||||||
"""Show all problems of a specific file."""
|
"""Show all problems of a specific file."""
|
||||||
return list(map(self.show_problem, problems, [file] * len(problems)))
|
lst = []
|
||||||
|
for problem in problems:
|
||||||
|
if problem.level is not None and (
|
||||||
|
problem.level == "error" or not self.no_warn
|
||||||
|
):
|
||||||
|
lst.append(self.show_problem(problem, file))
|
||||||
|
return lst
|
||||||
|
|
||||||
def show_problem(self, problem, file):
|
def show_problem(self, problem, file):
|
||||||
"""Show all problems of a specific file."""
|
"""Show all problems of a specific file."""
|
||||||
@@ -341,16 +356,13 @@ class CodeclimateFormater(Formater):
|
|||||||
|
|
||||||
def show_problems_for_file(self, problems, file):
|
def show_problems_for_file(self, problems, file):
|
||||||
"""Show all problems of a specific file."""
|
"""Show all problems of a specific file."""
|
||||||
return list(
|
lst = []
|
||||||
filter(
|
for problem in problems:
|
||||||
lambda x: x["severity"] == "major" or not self.no_warn,
|
if problem.level is not None and (
|
||||||
map(
|
problem.level == "error" or not self.no_warn
|
||||||
self.show_problem,
|
):
|
||||||
problems,
|
lst.append(self.show_problem(problem, file))
|
||||||
[file] * len(problems)
|
return lst
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
def show_problem(self, problem, file):
|
def show_problem(self, problem, file):
|
||||||
"""Show all problems of a specific file.
|
"""Show all problems of a specific file.
|
||||||
@@ -405,7 +417,7 @@ def max_level(all_problems):
|
|||||||
for problem in problems
|
for problem in problems
|
||||||
]
|
]
|
||||||
if all_levels:
|
if all_levels:
|
||||||
return max(map(lambda x: PROBLEM_LEVELS[x], all_levels))
|
return max(map(lambda x: int(PROBLEM_LEVELS[x]), all_levels))
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user