Skip to content

Comments

Fix sonarcloud reported code issues#2370

Merged
ihrasko merged 6 commits intoPANTHEONtech:21.xfrom
ihrasko:21.x-sonarcloud
Sep 26, 2025
Merged

Fix sonarcloud reported code issues#2370
ihrasko merged 6 commits intoPANTHEONtech:21.xfrom
ihrasko:21.x-sonarcloud

Conversation

@ihrasko
Copy link
Collaborator

@ihrasko ihrasko commented Sep 26, 2025

JIRA: LIGHTY-381

According to java:S1186:
An empty method is generally considered bad practice and can lead
to confusion, readability, and maintenance issues. Empty methods
bring no functionality and are misleading to others as they might think
the method implementation fulfills a specific and identified requirement.

JIRA: LIGHTY-381
Signed-off-by: tobias.pobocik <[email protected]>
(cherry picked from commit 40af5cd)
According to java:S2093:
Many resources in Java need be closed after they have been
used. If they are not, the garbage collector cannot reclaim
the resources' memory, and they are still considered to be
in use by the operating system. Such resources are
considered to be leaked, which can lead to performance issues.

JIRA: LIGHTY-381
Signed-off-by: tobias.pobocik <[email protected]>
(cherry picked from commit 35070c1)
Rework the shutdown of resources in Topology and Callhome plugins.

JIRA: LIGHTY-381
Signed-off-by: tobias.pobocik <[email protected]>
(cherry picked from commit 5332945)
This resource was not closed as well as being duplicated.

JIRA: LIGHTY-381
Signed-off-by: tobias.pobocik <[email protected]>
(cherry picked from commit a1c1e9d)
This resource was not closed.

JIRA: LIGHTY-381
Signed-off-by: tobias.pobocik <[email protected]>
(cherry picked from commit 91e0373)
This resource was not closed.

JIRA: LIGHTY-381
Signed-off-by: tobias.pobocik <[email protected]>
(cherry picked from commit 8888da7)
@gemini-code-assist
Copy link

Summary of Changes

Hello @ihrasko, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing code quality and robustness by addressing several SonarCloud reported issues. The changes include adding explanatory comments for better code readability, modernizing resource management in a test case, and improving the lifecycle handling of critical components within Netconf plugins to ensure proper cleanup.

Highlights

  • Code Clarity: Added clarifying comments to empty methods in test classes to explain their intended behavior, specifically for X509ExtendedTrustManager implementations and test constructors.
  • Resource Management Refinement: Improved resource handling in SocketAnalyzerTest by adopting a try-with-resources statement for ServerSocket to ensure proper closure and simplify error handling.
  • Lifecycle Management and Cleanup: Refactored NetconfCallhomePlugin and NetconfTopologyPlugin to promote key resources (like NetconfTopologySchemaAssembler and DefaultNetconfTimer) to class fields, ensuring they are properly initialized and then safely closed using a new closeResource helper method during the stopProcedure.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request addresses several code quality issues, likely reported by SonarCloud. The changes include adding comments to empty methods to clarify their purpose, refactoring resource management to use try-with-resources for better safety, and ensuring all closeable resources are properly managed and closed in the stopProcedure methods. These changes improve code robustness and maintainability. My main feedback is about a duplicated helper method, which could be extracted to a shared utility class to avoid code duplication.

@ihrasko ihrasko merged commit fe52725 into PANTHEONtech:21.x Sep 26, 2025
6 checks passed
@ihrasko ihrasko deleted the 21.x-sonarcloud branch September 26, 2025 10:25
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.

2 participants