Fix sonarcloud reported code issues#2370
Conversation
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)
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
JIRA: LIGHTY-381