Skip to content

Commit

Permalink
fix divide by zero exception (#17)
Browse files Browse the repository at this point in the history
Fix bug where a value (e.g. enum) was specified with --kind but did not exist within the code. since p_total and l_total are 0 in this case, the divition rise exception.
  • Loading branch information
shuky-shukrun authored Aug 8, 2021
1 parent 19cb37a commit f961554
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions coverxygen/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ def calculate_totals(p_symbolKindCounts):
return {
"documented_symbol_count": l_totalDocumented,
"symbol_count" : l_total,
"coverage_rate" : l_totalDocumented / l_total
"coverage_rate" : 0 if l_total == 0 else l_totalDocumented / l_total
}

@staticmethod
Expand Down Expand Up @@ -419,7 +419,7 @@ def determine_first_column_width(p_symbolsKindCountsList):

@staticmethod
def print_summary_line(p_stream, p_header, p_headerWidth, p_count, p_total):
l_percentage = (p_count / p_total) * 100.0
l_percentage = 0 if p_total == 0 else (p_count / p_total) * 100.0
p_stream.write("%s: %5.1f%% (%d/%d)\n" % (("%%-%ds" % (p_headerWidth)) % p_header,
l_percentage, p_count, p_total))

Expand Down

0 comments on commit f961554

Please sign in to comment.