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

Fix some sonar analysis: Call Optional#isPresent() before accessing the value #13256

Merged
merged 1 commit into from
Dec 13, 2020
Merged

Fix some sonar analysis: Call Optional#isPresent() before accessing the value #13256

merged 1 commit into from
Dec 13, 2020

Conversation

qmonmert
Copy link
Contributor

@qmonmert qmonmert commented Dec 12, 2020

#13232

Fix errors Call Optional#isPresent() before accessing the value


Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (bellow reviewers) and adding skip-ci label, you can still see CI build result at your branch.

@CLAassistant
Copy link

CLAassistant commented Dec 12, 2020

CLA assistant check
All committers have signed the CLA.

@qmonmert qmonmert closed this Dec 12, 2020
@qmonmert qmonmert reopened this Dec 12, 2020
@@ -56,5 +56,5 @@ _%>
<%_ } %>
})<% } %><% if (dto !== 'no') { %>
.map(<%= mapper %>::toDto)<% } %><% if (isService && !reactive) { %>
.get()<% } %>;
.orElse(null)<% } %>;
Copy link
Contributor

Choose a reason for hiding this comment

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

It sounds strange to return null after dealing with an optional, no?

Maybe throw an Exception or something like that will be better.

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to return the optional directly, and in Resource, instead of having:

Optional<ChipsDTO> result = Optional.ofNullable(chipsService.partialUpdate(chipsDTO));

We'll have:

Optional<ChipsDTO> result = chipsService.partialUpdate(chipsDTO);

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yea for sure, so far better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok guys, let's do this

@DanielFran DanielFran merged commit 5b3f9e5 into jhipster:main Dec 13, 2020
@pascalgrimaud pascalgrimaud added this to the 7.0.0-beta.0 milestone Dec 18, 2020
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.

None yet

5 participants