Skip to content

fix: use List interface instead of ArrayList in TransformationService#48

Open
sonarqube-agent[bot] wants to merge 1 commit intomainfrom
remediate-main-20260508-090155-2902003d
Open

fix: use List interface instead of ArrayList in TransformationService#48
sonarqube-agent[bot] wants to merge 1 commit intomainfrom
remediate-main-20260508-090155-2902003d

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Changed the return type of the unwind method from ArrayList to List to adhere to best practices of returning interface types rather than concrete implementations. This improves code flexibility and maintainability by allowing implementations to be swapped without affecting the method signature.

View Project in SonarCloud


Fixed Issues

java:S1319 - The return type of this method should be an interface such as "List" rather than the implementation "ArrayList". • MINORView issue

Location: src/main/java/fr/ans/psc/pscextract/service/TransformationService.java:149

Why is this an issue?

The Java Collections API offers a well-structured hierarchy of interfaces designed to hide collection implementation details. For the various collection data structures like lists, sets, and maps, specific interfaces (java.util.List, java.util.Set, java.util.Map) cover the essential features.

What changed

Changes the return type of the public method unwind from the concrete implementation ArrayList<Ps> to the interface type List<Ps>. This directly fixes the code smell where a collection implementation class (ArrayList) was used as a public method return type instead of the appropriate interface (List).

--- a/src/main/java/fr/ans/psc/pscextract/service/TransformationService.java
+++ b/src/main/java/fr/ans/psc/pscextract/service/TransformationService.java
@@ -149,1 +149,1 @@ public class TransformationService {
-    public ArrayList<Ps> unwind(List<Ps> psList) {
+    public List<Ps> unwind(List<Ps> psList) {

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZZjJ298STHyJcTACtx8 for java:S1319 rule

Generated by SonarQube Agent (task: f644162a-4f2a-495b-8c2a-f807ac28ee81)
@sonarqube-agent
Copy link
Copy Markdown
Author

⚠️ This repository does not have a CODEOWNERS file. The PR has been created but has not been automatically assigned to any reviewer. To ensure PRs are reviewed promptly, consider adding a CODEOWNERS file to your repository.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 8, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants