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

Code improvements #228

Merged
merged 15 commits into from
Oct 22, 2021
Merged

Code improvements #228

merged 15 commits into from
Oct 22, 2021

Conversation

offa
Copy link
Contributor

@offa offa commented Sep 21, 2021

  • Code clean-up
  • Deprecated APIs replaced (still some left)
  • Missing nullability annotations added
  • JSR 305 annotations replaced

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Ran out of time to review further. Will require detailed review from someone experienced in Jenkins code before merging to ensure there are no regressions.

offa and others added 3 commits September 29, 2021 07:31
Co-authored-by: Jesse Glick <jglick@cloudbees.com>
Co-authored-by: Jesse Glick <jglick@cloudbees.com>
@offa
Copy link
Contributor Author

offa commented Sep 29, 2021

Thanks for your review, I have addressed all comments.

Co-authored-by: Jesse Glick <jglick@cloudbees.com>
Copy link
Contributor

@Wadeck Wadeck left a comment

Choose a reason for hiding this comment

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

👍 For Lambda, NonNull refactoring, import optimization it seems to be fine. (those are proposed by IntelliJ)

⁉️ But for getDeclaredConstructor, I will not merge this without an explanation of the benefit using this approach, it seems less interesting than current version. Perhaps it's just me not knowing why you are doing that ;-)
So, either you provide the advantage/rationale of that approach or you remove them from this PR so that I can merge it.

💡 In general, I would say that I prefer to have PRs without a mix of manual proposals and IntelliJ (or other tool) proposals. The manual ones require more review than the automated ones. And saying it came from a tool in the PR description also helps ;)

Thanks for your contribution @offa 👍

@Wadeck
Copy link
Contributor

Wadeck commented Oct 1, 2021

If you want me to update your PR and merge it just tell me ;)
(without constructor changes, with the NonNull annotation on WrappedCredentialsStore changed and the getById changed)

Co-authored-by: Wadeck Follonier <Wadeck@users.noreply.github.com>
@offa
Copy link
Contributor Author

offa commented Oct 1, 2021

⁉️ But for getDeclaredConstructor, I will not merge this without an explanation of the benefit using this approach, it seems less interesting than current version. Perhaps it's just me not knowing why you are doing that ;-)
So, either you provide the advantage/rationale of that approach or you remove them from this PR so that I can merge it.

I'm on Java 11+ and newInstance() is deprecated since Java 9 (Java 11 docs). The docs (and discussion on SO) suggest getDeclaredConstructor().newInstance() as the replacement.

However, it's better to get a consensus here, so I'll remove it from this PR and in doubt provide a follow up.

@offa
Copy link
Contributor Author

offa commented Oct 1, 2021

If you want me to update your PR and merge it just tell me ;)
(without constructor changes, with the NonNull annotation on WrappedCredentialsStore changed and the getById changed)

Thanks 😄, but I've committed getById() through PR suggestion, newInstance() is reverted (I'll push once tested locally); regarding annotation, please see my comment above.

@Wadeck
Copy link
Contributor

Wadeck commented Oct 1, 2021

However, it's better to get a consensus here, so I'll remove it from this PR and in doubt provide a follow up.

Perfect yes thank you :)

regarding annotation, please see my comment above.

Will check the latest version and adjust if necessary before merge 👍

I'm on Java 11+ [...]

Thanks for the link and the rationale, will keep that in a place of my brain for next reviews / plugins 👍

Wadeck added 3 commits October 1, 2021 14:34
# Conflicts:
#	src/test/java/com/cloudbees/plugins/credentials/casc/CredentialsCategoryTest.java
@Wadeck
Copy link
Contributor

Wadeck commented Oct 1, 2021

Will merge once the CI is good :)

@Wadeck
Copy link
Contributor

Wadeck commented Oct 1, 2021

@offa Thanks for the contribution! Don't hesitate to make others, Hacktoberfest started today, you can gain a t-shirt with 5 approved PRs during October, more info on https://hacktoberfest.digitalocean.com/

@jglick
Copy link
Member

jglick commented Oct 1, 2021

Use getConstructor(), not getDeclaredConstructor(), since in the contexts in which we would be calling newInstance() we expect the no-arg constructor to be public.

@jglick
Copy link
Member

jglick commented Oct 1, 2021

(still reviewing)

Copy link
Member

@jglick jglick left a comment

Choose a reason for hiding this comment

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

Looks good other than a couple of nits. Thanks!

@jglick jglick added the chore label Oct 22, 2021
@jglick jglick merged commit 674e610 into jenkinsci:master Oct 22, 2021
@offa offa deleted the dev branch October 22, 2021 16:05
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