-
Notifications
You must be signed in to change notification settings - Fork 76
Remote API to connect additional code review tools #737
Conversation
plugin/src/test/java/io/jenkins/plugins/coverage/metrics/steps/LineCoverageViewTest.java
Fixed
Show fixed
Hide fixed
Codecov Report
@@ Coverage Diff @@
## master #737 +/- ##
============================================
+ Coverage 74.08% 74.47% +0.39%
- Complexity 1698 1749 +51
============================================
Files 130 135 +5
Lines 6289 6393 +104
Branches 677 690 +13
============================================
+ Hits 4659 4761 +102
- Misses 1407 1408 +1
- Partials 223 224 +1
... and 6 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
…naming and reformatting
plugin/src/main/java/io/jenkins/plugins/coverage/metrics/restapi/CoverageApi.java
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/coverage/metrics/restapi/ModifiedLineCoverageApi.java
Outdated
Show resolved
Hide resolved
modifiedLinesBlocks); | ||
filesWithModifiedLines.add(changedFile); | ||
} | ||
return filesWithModifiedLines; |
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.
I have a student implementation of such a code in the coverage-model (not yet published). So this code is ok for now but might be removed in the future...
|
||
int currentLine = modifiedLines.get(0); | ||
for (int i = 0; i < modifiedLines.size(); i++) { | ||
if (i == modifiedLines.size() - 1 || !modifiedLines.get(i).equals(modifiedLines.get(i + 1) - 1)) { |
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.
Note: this implementation is only partly correct. Since coverage calculation is done on the byte code, there might be lines without coverage information between two covered lines.
Example:
1 int code;
2 // empty
3 code = 0;
Will have a coverage of line 1 and 3 but not 2. As a user I would expect that the block 1-3 is fully covered. But your code produces two blocks. But this can be improved later one if someone complains 🤷
plugin/src/main/java/io/jenkins/plugins/coverage/metrics/restapi/ModifiedLineCoverageApi.java
Outdated
Show resolved
Hide resolved
plugin/src/main/resources/io/jenkins/plugins/coverage/metrics/restapi/_api.jelly
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/coverage/metrics/gerrit/GerritCoverageController.java
Outdated
Show resolved
Hide resolved
# Conflicts: # plugin/src/main/java/io/jenkins/plugins/coverage/metrics/gerrit/GerritCoverageController.java
…ine number instead of coverage type
…ine number instead of coverage type
@uhafner I extended the GitForensicsITest with a call to the new API to verify the resulting JSON. I added that in that test class since it offers a special setup where modified code lines as well as related coverage data is provided. Both is required for a decent test scenario here. From my side we can merge this PR, if you don't have any further suggestions. |
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.
Almost ready for merge, thanks for updating!
.../src/test/java/io/jenkins/plugins/coverage/metrics/restapi/ModifiedLinesCoverageApiTest.java
Outdated
Show resolved
Hide resolved
plugin/src/test/java/io/jenkins/plugins/coverage/metrics/steps/GitForensicsITest.java
Show resolved
Hide resolved
...in/resources/io/jenkins/plugins/coverage/metrics/restapi/ModifiedLinesCoverageApi/_api.jelly
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/coverage/metrics/restapi/ModifiedLinesCoverageApi.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/coverage/metrics/restapi/ModifiedLinesCoverageApi.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/coverage/metrics/restapi/ModifiedLinesCoverageApi.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/coverage/metrics/restapi/ModifiedLinesCoverageApi.java
Outdated
Show resolved
Hide resolved
plugin/src/main/java/io/jenkins/plugins/coverage/metrics/restapi/ModifiedLinesCoverageApi.java
Show resolved
Hide resolved
/** | ||
* Tests {@link FileWithModifiedLines}. | ||
*/ | ||
class FileWithModifiedLinesTest { |
Check notice
Code scanning / CodeQL
Unused classes and interfaces
/** | ||
* Tests {@link ModifiedLinesBlock}. | ||
*/ | ||
class ModifiedLinesBlockTest { |
Check notice
Code scanning / CodeQL
Unused classes and interfaces
@uhafner I reworked the implementation and included your comments. Now everything works like discussed and is also tested. The only problem is there are test failures regarding docker images and I think they are not caused by this pull request, so I do not know how to fix it. |
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.
Thanks!
I am rerunning the checks and will merge if everything is back to green... |
Adds a REST API that provides the coverage information of modified lines for each modified file - see #731 .