-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 cleanup #2282
Code cleanup #2282
Conversation
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 a lot for these changes!
Feel free to consider these review comments mostly as suggestions; Éamonn will probably provide the main review.
extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java
Outdated
Show resolved
Hide resolved
extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java
Outdated
Show resolved
Hide resolved
metrics/src/main/java/com/google/gson/metrics/BagOfPrimitives.java
Outdated
Show resolved
Hide resolved
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, some of these changes are clear improvements! I agree with @Marcono1234 about the formatting concerns, though, so can you fix those?
metrics/src/main/java/com/google/gson/metrics/BagOfPrimitives.java
Outdated
Show resolved
Hide resolved
extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java
Outdated
Show resolved
Hide resolved
extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java
Outdated
Show resolved
Hide resolved
Yes, i read your suggestions and I agree. In the next days, when I have more free time, I will fix everything EDIT: Well, I found the time today 😆 |
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.
There are quite a few good improvements here! Still a few nits, though.
extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java
Outdated
Show resolved
Hide resolved
metrics/src/main/java/com/google/gson/metrics/BagOfPrimitives.java
Outdated
Show resolved
Hide resolved
If you want I can run in the google-java-format in the project so everything could be formatted. Let me know @eamonnmcmanus |
No, please don't do that. We should probably do it at some point, in a PR with no other changes, but we've hesitated to because it would mean any outstanding PRs would probably get a bunch of annoying merge work to do. |
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 is looking good! Just one thing.
extras/src/main/java/com/google/gson/typeadapters/UtcDateTypeAdapter.java
Outdated
Show resolved
Hide resolved
Ohh yes, make sense. Thank you for explaining 😄
I don't know why Github don't show the indentation changes. If you look at this commit, for me it's fine |
The indentation problem is still there, including in the commit you referenced. It should look like this: ..public Date read(JsonReader in) throws IOException {
....try {
......switch (in.peek()) {
........case NULL:
..........in.nextNull(); but obviously with spaces instead of dots. It doesn't look as if there are any real changes to that file anyway, so maybe just restore it to what it was? (Also make sure that you don't have whitespace changes hidden: Files changed > ⚙️ > Hide whitespace.) |
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 hadn't realized that the indentation of the switch in UtcDateTypeAdapter
did not follow Google style, since the case labels were at the same indentation as the switch
. So thanks for fixing that.
Most welcome! i'm happy to help 😃 |
* Simplify `if` condition in JsonReader.peekNumber() * Remove `if` to simplify a `return` in Excluder.excludeClassChecks() * Remove redundant variable in Gson.fromJson() * equal condition replace by `Objects.equals()` in $Gson$Types.equal() * equal condition replace by `Objects.equals()` in LinkedTreeMap.equal() * Replace `switch` with `if` in UtcDateTypeAdapter.read() * Remove redundant `throws` clause in GraphAdapterBuilder.read() * Remove redundant `throws` clause in JsonTreeReader.UNREADABLE_READER * Remove redundant `throws` clause in JsonTreeWriter.UNREADABLE_READER * Remove unnecessary `.initCause()` call * Remove redundant cast in TreeTypeAdapter.GsonContextImpl.deserialize * Replace `StringBuilder` with `String` * Fix the import and restore the `switch` * Fix the import * Add the `util.Objects` import * Fix indentation * Add a comment to clarify the condition * Fix indentation * Fix imports * Fix indentation * Fix indentation * Fix indentation (cherry picked from commit 0a42c31)
I have cleanup the codebase