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

Prettier codegen #827

Merged
merged 5 commits into from
Sep 5, 2019
Merged

Prettier codegen #827

merged 5 commits into from
Sep 5, 2019

Conversation

richardm-stripe
Copy link
Contributor

@richardm-stripe richardm-stripe commented Aug 19, 2019

@richardm-stripe
Copy link
Contributor Author

richardm-stripe commented Aug 27, 2019

$ function dodiff { git diff origin/master --ignore-all-space | grep '^[+-]' | grep -v "^---" | grep -v "^+++"; }
$ function percent_diff { echo "scale=3; $(dodiff | $1 | wc -l)/$(dodiff | wc -l)" | bc -l; }
$ percent_diff 'grep String\.format'
.028
$ percent_diff 'grep Builder.params'
0
$ percent_diff 'grep public.*Builder'
.310
$ percent_diff 'grep \.request'
.016

@richardm-stripe
Copy link
Contributor Author

I think most of this is method ordering still, though.

@richardm-stripe
Copy link
Contributor Author

err, ordering of the embedded class definitions

@richardm-stripe richardm-stripe force-pushed the richardm-gen-w-prettierpoet branch from 3401a48 to 07d0bb8 Compare August 27, 2019 20:14
@richardm-stripe
Copy link
Contributor Author

Seems like the biggest offenders are the *Params.java files:

$ git show HEAD --stat=200 | tail +7 | awk '{ print $3 " "$4 " " $1}' | sort -n -r | less
1170 +++++++++++++------------------------------------------------------------------------------------------- src/main/java/com/stripe/param/issuing/CardCreateParams.java
1155 +++++++++++++----------------------------------------------------------------------------------------- src/main/java/com/stripe/param/issuing/CardholderCreateParams.java
1130 ++++++++++++---------------------------------------------------------------------------------------- src/main/java/com/stripe/param/issuing/CardholderUpdateParams.java
1066 +++++++++------------------------------------------------------------------------------------- src/main/java/com/stripe/param/issuing/CardUpdateParams.java
909 ++++++++++++++++++++++++++++++++++++++------------------------------------------- src/main/java/com/stripe/param/AccountCreateParams.java
893 +++++++++++++++++++++++++++++++++++++------------------------------------------ src/main/java/com/stripe/param/AccountUpdateParams.java
571 ++++++++++++++++++++++++--------------------------- src/main/java/com/stripe/param/SourceCreateParams.java
502 ++++++++++++++++++++------------------------- src/main/java/com/stripe/param/checkout/SessionCreateParams.java
463 ++++++++++++++++++++--------------------- src/main/java/com/stripe/param/SourceUpdateParams.java
415 ++++++++++++++++++------------------- src/main/java/com/stripe/param/SubscriptionScheduleUpdateParams.java
408 ++++++++++++++++++------------------ src/main/java/com/stripe/param/SubscriptionScheduleCreateParams.java
339 ++++++++++++++---------------- src/main/java/com/stripe/param/PersonCollectionCreateParams.java
325 +++++++++++++---------------- src/main/java/com/stripe/param/PersonUpdateParams.java
325 +++++++++++++---------------- src/main/java/com/stripe/param/CustomerCreateParams.java
312 +++++++++++++--------------- src/main/java/com/stripe/param/PaymentIntentCreateParams.java
288 +++----------------------- src/main/java/com/stripe/param/WebhookEndpointCreateParams.java

@richardm-stripe richardm-stripe force-pushed the richardm-gen-w-prettierpoet branch 8 times, most recently from 61afc94 to 40fb30e Compare August 29, 2019 19:15
@richardm-stripe
Copy link
Contributor Author

richardm-stripe commented Aug 29, 2019

Ok, made the diff much smaller, adding some namespacing (and two whitespace changes which were most of the raw diff).

Biggest offenders now:

124 ++++++++++++++++++++++++++++++++++++++----------------------------------------------------------
--------- src/main/java/com/stripe/model/BankAccount.java
114 +++++++++++++++++++++++++----------------------------------------------------------------------- src/main/java/com/stripe/model/Invoice.java
112 +++++++++++++++++++++++++++++----------------------------------------------------------------- src/main/java/com/stripe/param/SubscriptionScheduleUpdateParams.java
100 ++++++++++++++++++++++++------------------------------------------------------------ src/main/java/com/stripe/param/SubscriptionScheduleCreateParams.java
97 ++++++++++++++++++++++++++++++++++++++++------------------------------------------ src/main/java/com/stripe/param/AccountCreateParams.java
95 +++++++++++++++++++++++++++++++++++++++----------------------------------------- src/main/java/com/stripe/param/AccountUpdateParams.java
85 +++++++++++++++++++++++++++++------------------------------------------- src/main/java/com/stripe/param/issuing/CardCreateParams.java
84 ++++++++++++++++------------------------------------------------------- src/main/java/com/stripe/model/Person.java
83 +++++++++++++++++++--------------------------------------------------- src/main/java/com/stripe/model/SubscriptionSchedule.java
82 +++++++++++---------------------------------------------------------- src/main/java/com/stripe/model/Charge.java
80 +++++++++++++++++--------------------------------------------------- src/main/java/com/stripe/model/PaymentIntent.java
72 +++++++++++++++++-------------------------------------------- src/main/java/com/stripe/model/Source.java
72 +++++++++++++++++++------------------------------------------ src/main/java/com/stripe/model/Account.java
71 ++++++++++++++++++++++++------------------------------------ src/main/java/com/stripe/param/issuing/CardholderCreateParams.java
71 ++++++++++++++++++++++++++++-------------------------------- src/main/java/com/stripe/param/SourceCreateParams.java
67 +++++++++++---------------------------------------------- src/main/java/com/stripe/model/TransferReversal.java
64 ++++++++---------------------------------------------- src/main/java/com/stripe/model/Dispute.jav

@richardm-stripe richardm-stripe force-pushed the richardm-gen-w-prettierpoet branch 4 times, most recently from f8db34b to 9c1f9e3 Compare August 30, 2019 16:37
@richardm-stripe richardm-stripe force-pushed the richardm-gen-w-prettierpoet branch from 9c1f9e3 to 3f7817f Compare August 30, 2019 18:33
@richardm-stripe richardm-stripe force-pushed the richardm-gen-w-prettierpoet branch from 3f7817f to 05ec36e Compare September 3, 2019 16:22
@richardm-stripe richardm-stripe force-pushed the richardm-gen-w-prettierpoet branch from 839bedf to c06d4b4 Compare September 3, 2019 19:54
@richardm-stripe richardm-stripe force-pushed the richardm-gen-w-prettierpoet branch from c06d4b4 to 7843094 Compare September 3, 2019 19:59
@richardm-stripe
Copy link
Contributor Author

richardm-stripe commented Sep 3, 2019

r? @ob-stripe
I think this is (finally) good to go.

@ob-stripe
Copy link
Contributor

ob-stripe commented Sep 3, 2019

Here's the list of all changes I noticed:

ℹ️ = cosmetic change
⚠️ = functional change
🛑 = breaking

Most of these seem peaceful to me. Can I just ask you to fix these two?

ptal @richardm-stripe

@richardm-stripe
Copy link
Contributor Author

ptal @ob-stripe
should be addressed with 430f00f

please also approve https://github.com/stripe/stripe-api-codegen/pull/129

@ob-stripe
Copy link
Contributor

Looks great!

One final nit: can you fix the missing whitespace in adapter factory classes? Like here: https://github.com/stripe/stripe-java/pull/827/files#diff-c235a01258aeff703a67c9fd41deff9dL63

@richardm-stripe
Copy link
Contributor Author

@ob-stripe done
d8beca3

@richardm-stripe
Copy link
Contributor Author

@ob-stripe good to go now?

Copy link
Contributor

@ob-stripe ob-stripe left a comment

Choose a reason for hiding this comment

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

LGTM!

Aside from the explicit null check in nested resources that was removed, all the other changes are noted are cosmetic and should have no impact on the output JAR.

Let's run the compatibility checker script to double check that the prettier version is 100% compatible with the current one, but I think this is ready to ship!

@ob-stripe
Copy link
Contributor

Er, belay that, looks like tests are not passing.

@ob-stripe
Copy link
Contributor

ob-stripe commented Sep 4, 2019

It's because of this change:

StripeCollection derives from StripeObject, not ApiResource, so it has to use the ApiResource.request/ApiResource.requestCollection forms to call these static methods.

ptal @richardm-stripe

@richardm-stripe
Copy link
Contributor Author

There was one last change in b7b8e34

$ /tmp/compat/bin/japi-compliance-checker /tmp/old/stripe-java-11.6.1.jar /tmp/new/stripe-java-11.6.1.jar
Preparing, please wait ...
Using Java 1.8.0_212
Reading classes 11.6.1 ...
Reading classes 11.6.1 ...
Comparing classes ...
Creating compatibility report ...
Binary compatibility: 100%
Source compatibility: 100%
Total binary compatibility problems: 0, warnings: 0
Total source compatibility problems: 0, warnings: 0

@richardm-stripe richardm-stripe merged commit f773212 into master Sep 5, 2019
@richardm-stripe richardm-stripe deleted the richardm-gen-w-prettierpoet branch September 5, 2019 13:13
@ob-stripe
Copy link
Contributor

Released as 11.7.0 \o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants