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

Feature/reduce duplication #381

Merged
merged 7 commits into from
Feb 3, 2022

Conversation

pelletier197
Copy link
Contributor

@pelletier197 pelletier197 commented Oct 7, 2021

Changes

I couldn't help but notice that there is a lot of duplication and redundancy across the SDK. Generally speaking, having copy-pasted code increase maintaining efforts and increase the probability of error for new maintainers.

So I bring a little suggestion to help reduce repetition by having the base entity class providing functions that allow implementations to customise a RequestBuilder and automatically build that builder.

Feel free to suggest improvements or refuse it if you don't like the idea.

Testing

I added this only to the Guardian Entity. The code here is completely covered by existing tests. No tests were changed.

  • This change adds test coverage
  • This change has been tested on the latest version of the platform/language or why not

Checklist

@pelletier197 pelletier197 requested a review from a team as a code owner October 7, 2021 01:02
@jimmyjames
Copy link
Contributor

👋 hi @pelletier197, thanks for the contribution! There is duplication across the SDK and this looks like a good change on first glance. I'll look at the specific changes in detail next week, but just on first glance, do we need to make the new request builder public? Guessing we might need to since it's in a different package, or is there a use case for making the builder available to any user of the lib?

@pelletier197
Copy link
Contributor Author

Guessing we might need to since it's in a different package, or is there a use case for making the builder available to any user of the lib?

I don't think there would be any need for the users to use this outside the library. People most likely only use the different Entity implementations and don't need to create requests themselves.

I did put the Builder where I believe it would fit better (close to the Request objects). If you prefer, it can be closer to where it's used instead if that makes more sense and make it package private.

@jimmyjames
Copy link
Contributor

I don't think there would be any need for the users to use this outside the library. People most likely only use the different Entity implementations and don't need to create requests themselves.

I agree; it shouldn't be for public consumption until/unless there's a good reason.

I did put the Builder where I believe it would fit better (close to the Request objects). If you prefer, it can be closer to where it's used instead if that makes more sense and make it package private.

That makes sense, but to avoid tying ourselves to this implementation it's better to put it closer where it can be package-private. People shouldn't use it if it's documented as not for public-use, but ultimately as a public class it becomes part of the library's public API (and our backwards-compatibility check would fail if we did need to making a breaking change it at some point).

I'm headed out for holiday for the next week, I'll check back when I return. Thanks again!

@pelletier197
Copy link
Contributor Author

Better late than never. I updated the PR to make the RequestBuilder package private 😃

@pelletier197
Copy link
Contributor Author

pelletier197 commented Jan 27, 2022

Hey @jimmyjames! Did you get some time to review this? I'm on my way to implement a new entity for the Branding API, and I would really like to use this if possible.

@pelletier197 pelletier197 mentioned this pull request Jan 27, 2022
5 tasks
@jimmyjames
Copy link
Contributor

He @pelletier197, nso sorry for not getting to this sooner 😞. I like this change! I thought for a moment about reverting on my earlier comment about making the builder package-private, and instead putting it in an internal package so it can be shared with AuthenticationAPI... but that can be done later and let's not make perfect be the enemy of good. Looks like the codecov check is failing, so we probably have some code that needs tests here - let me know if you need help identifying where the coverage gaps are.

Thanks again for the contribution, your patience, and persistence 🙇

@pelletier197
Copy link
Contributor Author

pelletier197 commented Jan 28, 2022

@jimmyjames Thanks for you answer. Correct me if i'm wrong, but I think that 100% of my changes are tested. The code coverage reduced because I reduced the amount of code in the project. Since there is less code, the percentage of uncovered code is simply greater... Am I missing something??

@pelletier197
Copy link
Contributor Author

Any help here? 😅

@jimmyjames
Copy link
Contributor

@jimmyjames Thanks for you answer. Correct me if i'm wrong, but I think that 100% of my changes are tested. The code coverage reduced because I reduced the amount of code in the project. Since there is less code, the percentage of uncovered code is simply greater... Am I missing something??

Yes, that makes sense. I'll try updating the branch and then approve and merge. Thanks!

@jimmyjames jimmyjames added this to the v1-Next milestone Feb 3, 2022
Copy link
Contributor

@jimmyjames jimmyjames left a comment

Choose a reason for hiding this comment

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

Thanks for this change! As discussed on the PR, the project coverage check is failing because of the code removal, so this is ready to be merged. Thanks!

@jimmyjames jimmyjames merged commit caf1a85 into auth0:master Feb 3, 2022
@jimmyjames jimmyjames modified the milestones: v1-Next, 1.39.0 Feb 18, 2022
@jimmyjames jimmyjames mentioned this pull request Feb 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants