-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
Fix executable lines analysis #949
Conversation
4af0ece
to
35b0598
Compare
Codecov Report
@@ Coverage Diff @@
## 9.2 #949 +/- ##
============================================
+ Coverage 83.65% 83.71% +0.05%
- Complexity 1169 1191 +22
============================================
Files 59 59
Lines 3421 3427 +6
============================================
+ Hits 2862 2869 +7
+ Misses 559 558 -1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
35b0598
to
cbcc638
Compare
Hi @Slamdunk, I added more tests, can you please adjust the static analyser for them? data generated by xdebug l53 is not critical to be added, but l125 vs. l127 means whole method will be uncovered (issue #946) I will then conduct more testing - what is the definition of executable line, what are the cases when it should differ from xdebug coverage output? |
cbcc638
to
ff56101
Compare
ff56101
to
02422d1
Compare
02422d1
to
5409243
Compare
Sorry for late reply: I'll answer your questions and review the PR as soon as I can |
Due to the runtime nature of the language, there is no definition of executable line.
So how did I shape the As far as I can tell, there's no bulletproof algorithm. Who is going to write in real life the example below? return
true
or
false
; Almost any similar case involves a function call or a variable fetch or constant fetch: all these three cases are already correctly handled. |
Can this be closed then? |
The opposite: as soon as mvorisek#1 gets merged, this PR will be updated as well and the CI should pass, with a fix for other edge cases that @mvorisek found |
Ah, so you sent him a PR that will update this PR when merged. Got it, was confused / not fully awake yet. Thanks! |
@mvorisek awesome: you can now to this PR into "Ready for review" I guess |
ceedb51
to
ef9e521
Compare
b06f390
to
20e307d
Compare
@kukulich what lines do you expect covered and why? |
@kukulich as far as I can tell, your code coverage sample works as expected |
Hmm, it looks I sent bad screenshot because I thought both are caused by the change. So now the right screenshots: phpunit/php-code-coverage 9.2.17 phpunit/php-code-coverage 9.2.18 The problem is that With phpunit/php-code-coverage 9.2.17: 29) /home/runner/work/BetterReflection/BetterReflection/src/Reflection/StringCast/ReflectionAttributeStringCast.php:27 [M] Concat
--- Original
+++ New
@@ @@
{
$arguments = $attributeReflection->getArguments();
$argumentsFormat = $arguments !== [] ? " {\n - Arguments [%d] {%s\n }\n}" : '';
- return sprintf('Attribute [ %s ]' . $argumentsFormat . "\n", $attributeReflection->getName(), count($arguments), self::argumentsToString($arguments));
+ return sprintf($argumentsFormat . 'Attribute [ %s ]' . "\n", $attributeReflection->getName(), count($arguments), self::argumentsToString($arguments));
} |
some non-executable (compile time) lines are excluded probably by #892 this PR does not try to add more lines, this PR tries to exclude lines that are no present in xdebug output when formatted with random newlines between php tokens @Slamdunk can you please review? @kukulich please describe the problem in separate PR with a test case and description what should be chaged and why |
@mvorisek I'm not sure if I understand now. There's #946 mentioned in the release notes of 9.2.18 This issue was fixed by PR #948 And this PR draft has in description "Add more tests for #948 and fix found issues" so it looks to me it is still the same problem and my screenshots are relevant. However I can open new issue with the problem if it's better for you 🤷♂️ |
3b8871e
to
7a0ff15
Compare
Co-authored-by: Filippo Tessarotto <[email protected]>
05f0673
to
7b6d7e8
Compare
PR is RTM, I squashed the commits and for easier review I separated "else statement fix" into a separate commit as it affected many test reports 858b0f2...05f0673 comparison before squash can help you to understand/follow the static analyser changes made |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests/_files/source_with_heavy_indentation.php
has been changed too much, it's a bit exausting to review now, but I trust @mvorisek work on this.
mvorisek#3 instead need to be merged
I have added a test for concat. Here is a list of lines output by xdebug:
based on this data and my other experiments, I have not found any difference between binary plus and binary concat expression in sense of coverage. In mvorisek#3 you impose a different handling of binary concat which is wrong. With the test I added, your PR is breaking it and I do not see an easy way to fix it. Even if you will adjust the PR from binary concat to any binary expr (to handle them the same), it will unfix #942 and #889 again as const/enum variable assignments are const expressions too. Given this explanation I ask you to approve this PR as the #953 is not even related with this PR and close mvorisek#3. |
@mvorisek thank you for your patience and explanations. I approve this PR. Nevertheless, I now think we are fixing the wrong problem. What |
Good to know. However, the type checker result scares me:
|
@sebastianbergmann I did not change the |
Merged manually, thanks. |
Just cross-referencing from Roave/BackwardCompatibilityCheck#696 (comment) I somehow think this worsened the issue reported in #953 :D |
I'm pouring my energies into #959 I hope to give a valuable feedback in few weeks |
add more tests for #948 and fix found issues to make executable lines really a maximal subset (edge cases can be non-present, but not the other way around, otherwise #942) of xdebug
fix https://github.com/sebastianbergmann/php-code-coverage/pull/909/files#r820517185
fix #942 (nested array test added and tested againt about 50k real LoC)
fix #954 (merged via mvorisek#2)
fix #938 (test added)