Skip to content
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

Perform an overall code cleanup #108

Merged
merged 22 commits into from
Apr 10, 2024
Merged

Conversation

lppedd
Copy link
Contributor

@lppedd lppedd commented Apr 9, 2024

As per title, this is just a cleanup to enhance readability or remove unused/duplicated APIs.

I've split each cleanup action into its own commit to make it easier to review them.

@lppedd
Copy link
Contributor Author

lppedd commented Apr 9, 2024

CI seems to be failing because of unreachable codecov.

Copy link
Owner

@petertrr petertrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks nice! Even though I could argue that keeping one class per file is really Java-style, I don't mind extracting some things.

Please take a look at my comments.

BTW, I update codecov action on main, hopefully it will be more stable if you rebase.

return if (!snake && prev != null) {
prev.previousSnake()
} else {
this
}
}

override fun toString() = generateSequence(this) { it.prev }
.joinToString(prefix = "[", postfix = "]") { "(${it.i}, ${it.j})" }
override fun toString(): String {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why rewrite this method? For me, the existing implementation feels Kotlin-idiomatic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly two reasons:

  1. like with one class per file, an implementation closer to the upstream Java one helps in porting future changes
  2. we need to keep in mind readability. While generateSequence + joinToString is definitely more kotlinesque, understanding what's happening when you approach it is much more challenging. With a sequential solution you immediately infer what the result will be.

Copy link

codecov bot commented Apr 10, 2024

Codecov Report

Attention: Patch coverage is 69.89247% with 56 lines in your changes are missing coverage. Please review.

Project coverage is 84.17%. Comparing base (5f3e6b3) to head (04efa7a).

Files Patch % Lines
...hub/petertrr/diffutils/algorithm/myers/PathNode.kt 13.33% 12 Missing and 1 partial ⚠️
...n/kotlin/io/github/petertrr/diffutils/DiffUtils.kt 76.19% 10 Missing ⚠️
.../io/github/petertrr/diffutils/patch/ChangeDelta.kt 58.82% 7 Missing ⚠️
...ub/petertrr/diffutils/algorithm/myers/MyersDiff.kt 72.72% 1 Missing and 5 partials ⚠️
.../io/github/petertrr/diffutils/patch/DeleteDelta.kt 58.33% 5 Missing ⚠️
.../io/github/petertrr/diffutils/patch/InsertDelta.kt 66.66% 4 Missing ⚠️
...diffutils/patch/ConflictProducingConflictOutput.kt 75.00% 1 Missing and 2 partials ⚠️
...kotlin/io/github/petertrr/diffutils/patch/Chunk.kt 81.81% 1 Missing and 1 partial ⚠️
...iffutils/patch/ExceptionProducingConflictOutput.kt 33.33% 1 Missing and 1 partial ⚠️
...o/github/petertrr/diffutils/patch/DiffException.kt 0.00% 1 Missing ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #108      +/-   ##
============================================
- Coverage     85.85%   84.17%   -1.69%     
- Complexity      110      151      +41     
============================================
  Files            14       22       +8     
  Lines           502      537      +35     
  Branches         89       89              
============================================
+ Hits            431      452      +21     
- Misses           47       58      +11     
- Partials         24       27       +3     
Flag Coverage Δ
unittests 84.17% <69.89%> (-1.69%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@lppedd lppedd force-pushed the refactor/cleanup branch from bebe3e7 to 04efa7a Compare April 10, 2024 10:32
@lppedd lppedd requested a review from petertrr April 10, 2024 10:36
Copy link
Owner

@petertrr petertrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@petertrr petertrr merged commit 06b7c72 into petertrr:main Apr 10, 2024
1 of 3 checks passed
@lppedd
Copy link
Contributor Author

lppedd commented Apr 10, 2024

Thank you! I'll try to get code coverage up with one of the following PRs to port the java-diff changes.

@lppedd lppedd deleted the refactor/cleanup branch April 10, 2024 19:33
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