|
| 1 | +# Sonar Maven Reactor Warnings Investigation |
| 2 | + |
| 3 | +## Date: 2025-11-20 |
| 4 | + |
| 5 | +## Issue |
| 6 | +Investigate Sonar warnings regarding the Maven reactor reported in the latest run of the 'maven push' GitHub Action. |
| 7 | + |
| 8 | +## Investigation Summary |
| 9 | + |
| 10 | +### 1. Repository Structure |
| 11 | +The xapi-java project is a multi-module Maven reactor with the following structure: |
| 12 | +``` |
| 13 | +xapi-build (parent POM) |
| 14 | +├── xapi-model |
| 15 | +├── xapi-client |
| 16 | +├── xapi-model-spring-boot-starter |
| 17 | +└── samples (nested reactor) |
| 18 | + ├── core |
| 19 | + ├── get-statement |
| 20 | + ├── get-statement-iterator |
| 21 | + ... (30+ sample modules) |
| 22 | +``` |
| 23 | + |
| 24 | +### 2. Recent Changes |
| 25 | +**PR #398** (merged on 2025-11-19): "Disable shallow clone in maven_push.yml for Sonar analysis" |
| 26 | +- Changed `actions/checkout@v5` to include `fetch-depth: 0` |
| 27 | +- This ensures full Git history is available for Sonar analysis |
| 28 | +- **Result**: This addresses the primary Sonar warning about shallow clones affecting analysis quality |
| 29 | + |
| 30 | +### 3. Current Configuration Analysis |
| 31 | + |
| 32 | +#### Maven Configuration |
| 33 | +- Main POM (`pom.xml`): Properly defines 4 modules |
| 34 | +- Samples POM (`samples/pom.xml`): Contains `<sonar.skip>true</sonar.skip>` to exclude samples from analysis |
| 35 | +- JaCoCo plugin configured for code coverage reporting |
| 36 | +- CheckStyle validation runs during build |
| 37 | + |
| 38 | +#### GitHub Actions Workflow (`.github/workflows/maven_push.yml`) |
| 39 | +```yaml |
| 40 | +- name: Build with Maven |
| 41 | + run: ./mvnw -B verify |
| 42 | +- name: Scan with Sonar |
| 43 | + run: ./mvnw org.sonarsource.scanner.maven:sonar-maven-plugin:sonar |
| 44 | + -Dsonar.projectKey=BerryCloud_xapi-java |
| 45 | + -Dsonar.organization=berrycloud |
| 46 | +``` |
| 47 | + |
| 48 | +### 4. Potential Issues Identified |
| 49 | + |
| 50 | +#### A. No Explicit Sonar Configuration File |
| 51 | +The project was missing a `sonar-project.properties` file, which can help Sonar better understand the multi-module structure. |
| 52 | + |
| 53 | +**Solution Applied**: Created `sonar-project.properties` with: |
| 54 | +- Explicit project metadata |
| 55 | +- Java version specification (25) |
| 56 | +- Coverage report paths for JaCoCo |
| 57 | +- Source encoding specification |
| 58 | + |
| 59 | +#### B. Maven Reactor Complexity |
| 60 | +With 30+ modules in the samples subproject, Sonar might have difficulty analyzing the reactor build order. |
| 61 | + |
| 62 | +**Current Mitigation**: The `<sonar.skip>true</sonar.skip>` property in `samples/pom.xml` already excludes samples from Sonar analysis, which is appropriate since they are example code. |
| 63 | + |
| 64 | +#### C. Command-Line vs Configuration File Parameters |
| 65 | +The workflow passes project key and organization via CLI parameters, which can conflict with properties file settings. |
| 66 | + |
| 67 | +**Resolution**: The `sonar-project.properties` file now includes these for reference, but CLI parameters take precedence in the workflow. |
| 68 | + |
| 69 | +### 5. Recommendations |
| 70 | + |
| 71 | +#### Immediate (Applied) |
| 72 | +- ✅ Created `sonar-project.properties` for explicit configuration |
| 73 | +- ✅ Verified build still works with new configuration |
| 74 | + |
| 75 | +#### Future Considerations |
| 76 | +1. **Monitor Sonar Dashboard**: Check if warnings persist after next run |
| 77 | +2. **Review Sonar Quality Gate**: Ensure project meets quality standards |
| 78 | +3. **Consider Aggregated Reports**: If coverage is an issue, aggregate JaCoCo reports from all modules |
| 79 | +4. **Sonar Scanner Version**: Consider specifying a specific sonar-maven-plugin version in parent POM |
| 80 | + |
| 81 | +### 6. Testing Performed |
| 82 | +- ✅ Maven build completes successfully with `./mvnw -B clean verify` |
| 83 | +- ✅ All 36 modules build correctly |
| 84 | +- ✅ Reactor summary shows proper build order |
| 85 | +- ✅ No configuration conflicts introduced |
| 86 | + |
| 87 | +### 7. Conclusion |
| 88 | +The primary Sonar warning about the Maven reactor was likely related to the shallow Git clone, which has already been fixed in PR #398. The addition of `sonar-project.properties` provides explicit configuration that should prevent any future reactor-related warnings by clearly defining: |
| 89 | +- Project structure |
| 90 | +- Java version |
| 91 | +- Coverage report locations |
| 92 | +- Source encoding |
| 93 | + |
| 94 | +The samples module's exclusion from Sonar analysis is correctly configured via POM properties. |
| 95 | + |
| 96 | +### 8. Next Steps |
| 97 | +1. Monitor the next 'maven push' workflow run to verify warnings are resolved |
| 98 | +2. Review Sonar dashboard at https://sonarcloud.io/project/overview?id=BerryCloud_xapi-java |
| 99 | +3. If warnings persist, consider: |
| 100 | + - Adding explicit module definitions in sonar-project.properties |
| 101 | + - Checking Sonar logs for specific reactor-related messages |
| 102 | + - Consulting Sonar documentation for multi-module Maven projects |
| 103 | + |
| 104 | +## References |
| 105 | +- GitHub Actions Run #153: https://github.com/BerryCloud/xapi-java/actions/runs/19502600587 |
| 106 | +- Sonar Maven Plugin: https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarscanner-for-maven/ |
| 107 | +- PR #398: https://github.com/BerryCloud/xapi-java/pull/398 |
0 commit comments