Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR automates the removal of raw types from the Java codebase in the Uyuni project using a sed script
1)- Replaces List, Map, Set, and Class with generic type parameters (List, Map<Object, Object>, etc.).
2)- Improves code maintainability and eliminates SonarCloud warnings regarding raw types.
3)- Uses Docker to run the script in an isolated environment, ensuring a smooth and consistent update process.
4) -Changes were verified by running SonarCloud analysis after applying modifications.
GUI diffrence
No difference.
Before: Java classes contained raw types (List, Map, Set) without generics.

SonarCloud reported warnings for raw type usage.
After:

Raw types were removed and replaced with generics (List, Map<Object, Object>).
SonarCloud confirms the warnings are resolved.
Documentation
No documentation needed: only internal and user invisible changes.
[ ✅ ] DONE
Issue(s): Remove use of Java raw types
Automated Java Raw Type Removal Script
Overview
This script automates the removal of raw types (e.g., List, Map, Set) in Java code for the Uyuni project, replacing them with parameterized generics (List, Map<Object, Object>, etc.). It ensures compliance with SonarCloud recommendations, improving code maintainability.
Prerequisites
Docker installed (optional, for isolated execution)
A local copy of the Uyuni repository
Backup of codebase before making bulk changes
Setup & Execution
Step 1: Clone and Backup the Repository
git clone https://github.com/uyuni-project/uyuni.git
cd uyuni
cp -r uyuni uyuni_backup
Automated Script (remove_raw_types.sh)
This script scans all .java files and replaces raw types with their generic equivalents.
#!/bin/bash
Define the file extension (only modify Java files)
EXTENSION="java"
Define the list of raw types to replace
TYPES=("List" "Map" "Set")
Loop through each Java file in the project
find . -type f -name "*.$EXTENSION" | while read -r file; do
for TYPE in "${TYPES[@]}"; do
# Use sed to replace raw types with generic versions
sed -i -E "s/\b${TYPE}\b/${TYPE}/g" "$file"
done
echo "Processed: $file"
done
echo "Raw type replacement complete"
How to Run the Script
chmod +x remove_raw_types.sh
./remove_raw_types.sh
The script scans .java files, replaces raw types, and prints processed files.
Verification with SonarCloud
After applying the script, verify the changes using SonarCloud:
mvn clean verify sonar:sonar
-Dsonar.projectKey=uyuni-project_uyuni
-Dsonar.host.url=https://sonarcloud.io
If warnings for raw types are removed, the script worked successfully.
Running Inside Docker
For isolated execution, run the script inside a Docker container:
Build Docker Image-
docker build -t java-cleanup .
docker run --rm -v "$(pwd)":/app java-cleanup ./remove_raw_types.sh
This ensures a clean environment without modifying the local setup.
1)- Setup & Execution
2)-Automated Script (remove_raw_types.sh)
3)- How to Run the Script
4)-Verification with SonarCloud
If warnings for raw types are removed, the script worked successfully. As given in above image.
Re-run a test
If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run
Re-run test "changelog_test"
Re-run test "backend_unittests_pgsql"
Re-run test "java_pgsql_tests"
Re-run test "schema_migration_test_pgsql"
Re-run test "susemanager_unittests"
Re-run test "javascript_lint"
Re-run test "spacecmd_unittests"
Changelogs
Make sure the changelogs entries you are adding are compliant with https://github.com/uyuni-project/uyuni/wiki/Contributing#changelogs and https://github.com/uyuni-project/uyuni/wiki/Contributing#uyuni-projectuyuni-repository
If you don't need a changelog check, please mark this checkbox:
If you uncheck the checkbox after the PR is created, you will need to re-run
changelog_test
(see below)Re-run a test
If you need to re-run a test, please mark the related checkbox, it will be unchecked automatically once it has re-run:
Before you merge
Check How to branch and merge properly!