Refactor problems output
Signed-off-by: Mathieu Rul <mathroule@gmail.com>
This commit is contained in:
@@ -99,9 +99,8 @@ class Format:
|
||||
return line
|
||||
|
||||
|
||||
def show_problems(problems, file, args_format, no_warn):
|
||||
def show_problems(results, args_format, no_warn):
|
||||
max_level = 0
|
||||
first = True
|
||||
|
||||
if args_format == 'auto':
|
||||
if ('GITHUB_ACTIONS' in os.environ and
|
||||
@@ -110,6 +109,10 @@ def show_problems(problems, file, args_format, no_warn):
|
||||
elif supports_color():
|
||||
args_format = 'colored'
|
||||
|
||||
for file in results:
|
||||
first = True
|
||||
|
||||
problems = results[file]
|
||||
for problem in problems:
|
||||
max_level = max(max_level, PROBLEM_LEVELS[problem.level])
|
||||
if no_warn and (problem.level != 'error'):
|
||||
@@ -225,8 +228,7 @@ def run(argv=None):
|
||||
print(file)
|
||||
sys.exit(0)
|
||||
|
||||
max_level = 0
|
||||
|
||||
results = {}
|
||||
for file in find_files_recursively(args.files, conf):
|
||||
filepath = file[2:] if file.startswith('./') else file
|
||||
try:
|
||||
@@ -235,9 +237,7 @@ def run(argv=None):
|
||||
except OSError as e:
|
||||
print(e, file=sys.stderr)
|
||||
sys.exit(-1)
|
||||
prob_level = show_problems(problems, file, args_format=args.format,
|
||||
no_warn=args.no_warnings)
|
||||
max_level = max(max_level, prob_level)
|
||||
results[filepath] = problems
|
||||
|
||||
# read yaml from stdin
|
||||
if args.stdin:
|
||||
@@ -246,9 +246,9 @@ def run(argv=None):
|
||||
except OSError as e:
|
||||
print(e, file=sys.stderr)
|
||||
sys.exit(-1)
|
||||
prob_level = show_problems(problems, 'stdin', args_format=args.format,
|
||||
no_warn=args.no_warnings)
|
||||
max_level = max(max_level, prob_level)
|
||||
results['stdin'] = problems
|
||||
|
||||
max_level = show_problems(results, args_format=args.format, no_warn=args.no_warnings)
|
||||
|
||||
if max_level == PROBLEM_LEVELS['error']:
|
||||
return_code = 1
|
||||
|
||||
Reference in New Issue
Block a user