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 12, 2024
1 parent ac6b37a commit 7437432
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 @@ -385,12 +385,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'] + list(SEVERITY_VALUE_MAP) + ['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_MAP:
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 @@ -603,6 +606,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 @@ -623,6 +627,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 7437432

Please sign in to comment.