Skip to content

Commit

Permalink
panlint: Include breakdown of problem severities in file stats
Browse files Browse the repository at this point in the history
  • Loading branch information
jrha committed Dec 9, 2024
1 parent b570b22 commit d4a4d61
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions panc/src/main/scripts/panlint/panlint.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,15 @@ def get_string_ranges(line):

def filestats_table(problem_stats):
"""Return a formatted table of problem counts per file"""
t = PrettyTable(['Filename', 'Problems'])
t = PrettyTable(['Filename'] + [severity for severity in SEVERITY_VALUE] + ['Total'])
t.align['Filename'] = 'l'
t.align['Problems'] = 'r'
for filename, problem_count in problem_stats.iteritems():
if problem_count > 0:
t.add_row([filename, problem_count])
t.align['Total'] = 'r'
for severity in SEVERITY_VALUE:
t.align[severity] = 'r'

for filename, stats in problem_stats.items():
if stats:
t.add_row([filename] + stats + [sum(stats)])
t.sortby = 'Filename'
return t

Expand Down Expand Up @@ -595,6 +598,7 @@ def main():
problem_count = 0
problem_lines = []
problem_stats = {}
problem_max_severity = 0

if not args.paths:
print('No files were provided, not doing anything')
Expand All @@ -615,6 +619,17 @@ def main():
problem_count += file_problem_count
problem_stats[filename] = file_problem_count

file_severities = [0]
for line in file_problem_lines:
for problem in line.problems:
file_severities.append(problem.message.severity)

problem_stats[filename] = []
for value in SEVERITY_TEXT:
problem_stats[filename].append(file_severities.count(value))

problem_max_severity = max(problem_max_severity, max(file_severities))

for line in problem_lines:
print_report(line, vi=args.vi)

Expand Down

0 comments on commit d4a4d61

Please sign in to comment.