New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage not reported correctly for CTEs at the end of a stored procedure if the 'with' is immediately preceded with a semicolon #8

Closed
jmclusky opened this Issue Sep 28, 2016 · 1 comment

Comments

Projects
None yet
1 participant
@jmclusky
Contributor

jmclusky commented Sep 28, 2016

If a CTE is preceded by a semicolon e.g.

;with MyCTE as
(
...

and it is the last statement in a batch, the executed statement is matched against the immediately preceding statement instead. This is because the Overlaps function matches the preceding statement first due to the way that the coveredEnd variable is assigned the same value as the coveredOffset.

(This technically applies to other statements preceded with a semicolon, but it's unusual to see those).

I believe that the logic should change to treat those where coveredStatement.OffsetEnd is -1 (i.e. last statement) separate from others, and return true where the coveredOffset is equal or less than the tested statement's offset.

For other covered statements, the logic can now be simplified as we're no longer having to cope with both cases.

I've developed and tested a fix locally on my fork and will submit a pull request shortly.

@jmclusky

This comment has been minimized.

Show comment
Hide comment
@jmclusky

jmclusky Sep 29, 2016

Contributor

This can now be closed following the pull request that was accepted yesterday evening

Contributor

jmclusky commented Sep 29, 2016

This can now be closed following the pull request that was accepted yesterday evening

@jmclusky jmclusky closed this Sep 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment