Skip to content

fix: resolve 3 SonarQube issues in naming and collection checks#49

Open
sonarqube-agent[bot] wants to merge 1 commit intomainfrom
remediate-main-20260509-090228-311884eb
Open

fix: resolve 3 SonarQube issues in naming and collection checks#49
sonarqube-agent[bot] wants to merge 1 commit intomainfrom
remediate-main-20260509-090228-311884eb

Conversation

@sonarqube-agent
Copy link
Copy Markdown

Renamed method calls to follow camelCase naming conventions (getZipExtension and getTxtExtension) and replaced size() check with isEmpty() for better clarity and performance. These changes improve code quality by adhering to Java naming standards and using collection API best practices.

View Project in SonarCloud


Fixed Issues

java:S100 - Rename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'. • MINORView issue

Location: src/main/java/fr/ans/psc/pscextract/controller/ExtractionController.java:233

Why is this an issue?

Shared naming conventions allow teams to collaborate efficiently.

What changed

This hunk renames the call from getZIP_EXTENSION() to getZipExtension(), which is part of fixing the method naming convention violation where getZIP_EXTENSION() does not match the required pattern ^[a-z][a-zA-Z0-9]*$. By updating all call sites to use the new compliant name getZipExtension(), the old non-compliant method can be renamed or removed.

--- a/src/main/java/fr/ans/psc/pscextract/service/TransformationService.java
+++ b/src/main/java/fr/ans/psc/pscextract/service/TransformationService.java
@@ -385,1 +385,1 @@ public class TransformationService {
-                         getFileNameWithExtension(extractionController.getZIP_EXTENSION())
+                         getFileNameWithExtension(extractionController.getZipExtension())
java:S100 - Rename this method name to match the regular expression '^[a-z][a-zA-Z0-9]*$'. • MINORView issue

Location: src/main/java/fr/ans/psc/pscextract/controller/ExtractionController.java:237

Why is this an issue?

Shared naming conventions allow teams to collaborate efficiently.

What changed

This hunk updates the call from getTXT_EXTENSION() to getTxtExtension(), fixing the method naming convention violation where getTXT_EXTENSION() does not match the required pattern ^[a-z][a-zA-Z0-9]*$. By renaming the call site to use the compliant camelCase name getTxtExtension(), the old non-compliant method can be renamed accordingly.

--- a/src/main/java/fr/ans/psc/pscextract/service/TransformationService.java
+++ b/src/main/java/fr/ans/psc/pscextract/service/TransformationService.java
@@ -437,1 +438,1 @@ public class TransformationService {
-    ZipEntry zipEntry = new ZipEntry(getFileNameWithExtension(extractionController.getTXT_EXTENSION()));
+    ZipEntry zipEntry = new ZipEntry(getFileNameWithExtension(extractionController.getTxtExtension()));
java:S1155 - Use isEmpty() to check whether the collection is empty or not. • MINORView issue

Location: src/main/java/fr/ans/psc/pscextract/service/utils/FileNamesUtil.java:66

Why is this an issue?

When you call isEmpty(), it clearly communicates the code’s intention, which is to check if the collection is empty. Using size() == 0 for this purpose is less direct and makes the code slightly more complex.

What changed

Replaces listOfFiles.size() > 0 with !listOfFiles.isEmpty(), which is the recommended way to check whether a collection is empty. Using isEmpty() is clearer in intent, and is guaranteed to be an O(1) operation, whereas size() may be O(n) depending on the collection implementation.

--- a/src/main/java/fr/ans/psc/pscextract/service/utils/FileNamesUtil.java
+++ b/src/main/java/fr/ans/psc/pscextract/service/utils/FileNamesUtil.java
@@ -66,1 +66,1 @@ public class FileNamesUtil {
-    if (listOfFiles.size() > 0) {
+    if (!listOfFiles.isEmpty()) {

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


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AZZjJ27ISTHyJcTACtx2 for java:S1155 rule
- AZZjJ2_gSTHyJcTACtyl for java:S100 rule
- AZZjJ2_gSTHyJcTACtym for java:S100 rule

Generated by SonarQube Agent (task: c91726b4-fa52-4ef5-9e26-a7365404cb88)
@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 9, 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