Skip to content

Conversation

@OsBlaineOra
Copy link
Contributor

with covered lines / total total lines.
Rounding to 17 decimal places since that's what I found when looking at cobertura examples online.
Used an rpad to generate the format mask to avoid having a long string of 9s.

This was mentioned in #1107 but does not have an issue of its own.

with covered lines / total  total lines.
Rounding to 17 decimal places since that's what I found when looking at cobertura examples online.
Used an rpad to generate the format mask to avoid having a long string of 9s.

This was mentioned in utPLSQL#1107 but does not have an issue of its own.
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.
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
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

||'" 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
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?

ut_utils.append_to_list(
l_result,
'<coverage line-rate="0" branch-rate="0.0" lines-covered="'
'<coverage line-rate="'
Copy link
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!

@jgebal
Copy link
Member

jgebal commented Oct 28, 2021

Thank you @OsBlaineOra for the improvement.
Four of our tests require updates in order for the build to be successful.
Are you able to fix those?
You can check the results of the failing tests here:
https://app.travis-ci.com/github/utPLSQL/utPLSQL/jobs/536073612#L6829

l_result,
'<coverage line-rate="0" branch-rate="0.0" lines-covered="'
'<coverage line-rate="'
||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
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

@jgebal jgebal merged commit b4c7db8 into utPLSQL:develop Nov 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants