Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed a divide by zero error.
I introduced the error in the previous commit.

To fix I added a l_lines_valid variable, used a case statement to check for 0 else return the calculation.
I also replaced the lines_valid calculation to use the new variable to reduce code duplication.
  • Loading branch information
OsBlaineOra authored Sep 7, 2021
commit 4e2b9f5f7b5ee5a39fac59a5fc20bb28f7c27d98
7 changes: 4 additions & 3 deletions source/reporters/ut_coverage_cobertura_reporter.tpb
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ create or replace type body ut_coverage_cobertura_reporter is
c_packages_footer constant varchar2(30) := '</packages>';
c_package_footer constant varchar2(30) := '</package>';
c_class_footer constant varchar2(30) := '</class>';
c_classes_footer constant varchar2(30) := '</classes>';
c_classes_footer constant varchar2(30) := '</classes>';
c_lines_footer constant varchar2(30) := '</lines>';
l_epoch varchar2(50) := (sysdate - to_date('01-01-1970 00:00:00', 'dd-mm-yyyy hh24:mi:ss')) * 24 * 60 * 60;
l_lines_valid number := a_coverage_data.covered_lines + a_coverage_data.uncovered_lines;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

integer will be better, as the lines are always integer

begin

ut_utils.append_to_list( l_result, ut_utils.get_xml_header(a_run.client_character_set) );
Expand All @@ -91,10 +92,10 @@ create or replace type body ut_coverage_cobertura_reporter is
ut_utils.append_to_list(
l_result,
'<coverage line-rate="'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice small fix. Love it!

||to_char(round(a_coverage_data.covered_lines/(a_coverage_data.covered_lines + a_coverage_data.uncovered_lines), 17), rpad('FM0.',21,'9'))
||to_char(round((case l_lines_valid when 0 then 0 else a_coverage_data.covered_lines/(l_lines_valid) end), 17), rpad('FM0.',21,'9'))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should probably be:
to_char( value , 'TM9' , 'NLS_NUMERIC_CHARACTERS=''. ''' ) to make sure it is OK for values of "0".

See those failing tests for extra "." present there.
The tests need to be fixed as they all assume the line-rate to be ZERO.
https://app.travis-ci.com/github/utPLSQL/utPLSQL/jobs/536073612#L6935

||'" branch-rate="0.0" lines-covered="'
||a_coverage_data.covered_lines||'" lines-valid="'
||TO_CHAR(a_coverage_data.covered_lines + a_coverage_data.uncovered_lines)
||TO_CHAR(l_lines_valid)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you make this TO_CHAR lowercase since you've touched this line?

||'" branches-covered="0" branches-valid="0" complexity="0" version="1" timestamp="'||l_epoch||'">'
);

Expand Down