-
Notifications
You must be signed in to change notification settings - Fork 31
Add Code Difference API #372
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #372 +/- ##
============================================
+ Coverage 66.28% 68.44% +2.16%
- Complexity 307 365 +58
============================================
Files 41 48 +7
Lines 1053 1160 +107
Branches 88 100 +12
============================================
+ Hits 698 794 +96
- Misses 315 325 +10
- Partials 40 41 +1
Continue to review full report at Codecov.
|
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.
In general very well written!
Some methods are not yet clear to me but I did not yet read the downstream PR.
/** | ||
* Returns a {@link DeltaCalculator} for the specified {@link SCM repository}. | ||
* | ||
* @param scm the key of the SCM repository (substring that must be part of the SCM key) | ||
* @param run the current build | ||
* @param workTree the working tree of the repository | ||
* @param listener a task listener | ||
* @param logger a logger to report error messages | ||
* @return a delta calculator for the SCM of the specified build or a {@link NullDeltaCalculator} if the SCM is not | ||
* supported | ||
*/ |
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.
Somehow you did use a different coding style for JavaDoc comments. Didn't you open these projects using https://github.com/uhafner/warnings-ng-plugin-devenv? Then the coding style settings should be automatically set in IntelliJ.
/** | ||
* The {@link ChangeEditType} of the change. | ||
*/ |
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.
Such comments are just duplicating the name and type of the field and should be omitted.
/** | ||
* The currently processed commit. | ||
*/ |
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.
See above, delete such comments
/** | ||
* The reference commit. | ||
*/ |
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.
See above
/** | ||
* The difference file created by Git. | ||
*/ |
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.
Is this the content? OR in which format?
private static Change change; | ||
|
||
@BeforeAll | ||
static void init() { | ||
change = new Change(EDIT_TYPE, FROM_LINE, TO_LINE); | ||
} | ||
|
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.
This makes the test hard to read, inline and use a simple factory method that returns the object in the test.
Change changeTwo = new Change(EDIT_TYPE, FROM_LINE, TO_LINE); | ||
|
||
assertThat(change).isEqualTo(changeTwo); | ||
} |
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 would recommend to test equals
in the following way:
@Test
void shouldObeyEqualsContract() {
EqualsVerifier.simple().forClass(Change.class).verify();
}
private static Delta delta; | ||
|
||
@BeforeAll | ||
static void init() { | ||
delta = new Delta(CURRENT_COMMIT_ID, REFERENCE_COMMIT_ID); | ||
} | ||
|
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.
See above.
* | ||
* @return the created map | ||
*/ | ||
private Map<String, FileChanges> createFileChanges() { |
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.
Using an empty map would be sufficient , but it is fine to use the complex map here
private static Map<ChangeEditType, List<Change>> changesMap; | ||
|
||
private static FileChanges fileChanges; | ||
|
||
@BeforeAll | ||
static void init() { | ||
ChangeEditType editType = ChangeEditType.INSERT; | ||
List<Change> changes = Collections.singletonList(new Change(editType, 1, 6)); | ||
changesMap = new HashMap<>(); | ||
changesMap.put(editType, changes); | ||
fileChanges = new FileChanges(FILE_NAME, FILE_CONTENT, FILE_EDIT_TYPE, changesMap); | ||
} |
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.
See above. Maybe just inline the code and use EqualsVersifier
for equals
An API which calculates the code differences - so called 'delta' - between two commits.
The resulting delta model contains information about:
The implementation for Git is available in the downstream PR jenkinsci/git-forensics-plugin#390