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

Quality: code cleaning #2975

Merged
merged 20 commits into from
Aug 5, 2024
Merged

Quality: code cleaning #2975

merged 20 commits into from
Aug 5, 2024

Conversation

EtienneLt
Copy link
Contributor

@EtienneLt EtienneLt commented Apr 12, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?
No

What kind of change does this PR introduce?
Cleaning some code:

  • Use Java14 switch syntax (JEP-361), especially return switch syntax.
  • Replace some Stream.collect(Collector.toList()) with Stream.toList() (when immutable lists can be returned without impact for callers).
  • Use JsonParser.currentName() instead of deprecated method JsonParser.getCurrentName().
  • Replace Files.write(file, string.getBytes(StandardCharsets.UTF_8)) with Files.writeString(file, string).
  • Replace some Arrays.asList(...) with List.of(...).
  • Replace assertTrue(obj instanceof Foo) with assertInstanceOf(Foo.class, obj).
  • A few other simplifications.

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

@EtienneLt EtienneLt self-assigned this Apr 12, 2024
Copy link
Member

@geofjamg geofjamg left a comment

Choose a reason for hiding this comment

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

Be careful, each time you replace a collec(Collectors.toList())) by a toList() and that it is returned from an api you break potentialy the api because list is now immutable. And using code outside of powsybl core might failed at runtime.

@EtienneLt
Copy link
Contributor Author

Be careful, each time you replace a collec(Collectors.toList())) by a toList() and that it is returned from an api you break potentialy the api because list is now immutable. And using code outside of powsybl core might failed at runtime.

ok I can revert if needed, I left many Collectors.toList()

@geofjamg
Copy link
Member

Be careful, each time you replace a collec(Collectors.toList())) by a toList() and that it is returned from an api you break potentialy the api because list is now immutable. And using code outside of powsybl core might failed at runtime.

ok I can revert if needed, I left many Collectors.toList()

I just say that each time a list is exposed to an API we have to think and decide if we want to expose a mutable or immutable list and report if we change from actual code as a breaking change and write it in the migration guide

Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
rolnico and others added 4 commits April 16, 2024 10:50
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
EtienneLt and others added 2 commits April 23, 2024 09:56
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Copy link

sonarcloud bot commented May 14, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
77.7% Coverage on New Code (required ≥ 80%)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarCloud

Catch issues before they fail your Quality Gate with our IDE extension SonarLint

Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@EtienneLt EtienneLt requested a review from olperr1 July 25, 2024 14:58
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@olperr1 olperr1 changed the title refactor code Quality: code cleaning Jul 29, 2024
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
Signed-off-by: Etienne LESOT <etienne.lesot@rte-france.com>
@EtienneLt EtienneLt requested a review from olperr1 August 5, 2024 09:46
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
Copy link

sonarcloud bot commented Aug 5, 2024

@olperr1 olperr1 dismissed rolnico’s stale review August 5, 2024 12:48

All rolnico's requests were addressed.

@olperr1 olperr1 merged commit 7432a7e into main Aug 5, 2024
7 checks passed
@olperr1 olperr1 deleted the refactor-code branch August 5, 2024 12:50
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

4 participants