Skip to content

Commit 8f9ccf3

Browse files
committed
Error handling
1 parent 5905cfd commit 8f9ccf3

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scrub/tools/parsers/parse_metrics.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,11 @@ def parse_codesonar_metrics(raw_analysis_metrics_file, raw_file_metrics_file, pa
157157

158158
# Calculate comment density
159159
for item in cleaned_metrics_data.keys():
160-
comment_density = round(int(cleaned_metrics_data[item]['Comment Lines']) /
161-
int(cleaned_metrics_data[item]['Code Lines']) * 100, 2)
160+
if int(cleaned_metrics_data[item]['Code Lines']) != 0:
161+
comment_density = round(int(cleaned_metrics_data[item]['Comment Lines']) /
162+
int(cleaned_metrics_data[item]['Code Lines']) * 100, 2)
163+
else:
164+
comment_density = 'N/A'
162165
cleaned_metrics_data[item]['Comment Density'] = comment_density
163166

164167
# Check to make sure we have data

0 commit comments

Comments
 (0)