SONARJAVA-6490 Implement S8910: Interfaces with @Mapper should have @DaoFactory methods#5690
SONARJAVA-6490 Implement S8910: Interfaces with @Mapper should have @DaoFactory methods#5690romainbrenguier wants to merge 9 commits into
Conversation
134235b to
dd242b4
Compare
54d1175 to
d2cecff
Compare
50364f5 to
5ad2ff5
Compare
Add comprehensive test cases to improve code coverage: - Multi-level inheritance (interface extending interface extending base) - Multiple inheritance (interface extending multiple interfaces) - Extending unknown type (to test isUnknown branch) - Complex inheritance with mixed scenarios These additions help reach the 90% code coverage threshold required by the SonarQube quality gate. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
When a @Mapper interface extends an unresolved type (e.g., due to incomplete classpath), assume it might provide the required @DaoFactory method to avoid false positives. This conservative approach prioritizes precision over recall in real-world scenarios where classpaths may be incomplete. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
When a @Mapper interface explicitly extends other interfaces and one of them is unresolved (e.g., due to incomplete classpath), assume it might provide the required @DaoFactory method to avoid false positives. This conservative approach only applies when the interface has explicit extends clauses, not for interfaces with no supertypes, ensuring we still catch genuine violations while avoiding noise in projects with incomplete classpaths. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
a303d8a to
13bbacd
Compare
Added test cases to cover additional code paths: - Non-compiling test for unresolved supertypes scenario - Deep inheritance chain test case - Circular reference base test case This improves code coverage to meet the 90% quality gate threshold. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added diamond inheritance pattern to test the visited set logic when the same interface is encountered multiple times through different inheritance paths. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added diamond inheritance pattern without @DaoFactory to ensure the visited set logic is exercised when traversing all branches looking for the required annotation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Code Review ✅ Approved 4 resolved / 4 findingsImplements rule S8910 to validate ✅ 4 resolved✅ Quality: Rule S8910 not added to a quality profile
✅ Edge Case: Inherited @DaoFactory methods from super-interfaces ignored
✅ Edge Case: @Mapper on class/enum/record not handled or documented
✅ Edge Case: Possible false positives when @Mapper extends unresolved supertypes
OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|




Summary
Implements rule S8910 to detect interfaces annotated with
@Mapperthat don't contain at least one@DaoFactorymethod.Implementation
@Mapperannotation for presence of@DaoFactorymethodsStatus
WIP - Implementation incomplete after initial attempts. Requires review and completion.
🤖 Generated with Claude Code
Summary by Gitar
Sonar_way_profile.jsonandSonar_agentic_AI_profile.json.S8910.htmlandS8910.jsonfor rule documentation and configuration.diff_S8910.jsonforautoscanverification.JavaAgenticWayProfileTestto validate the new rule integration.build.ymlto use Java 26.Mapper.javaandDaoFactory.javafor test source compilation.MapperWithoutDaoFactoryCheckSample.javaandnon-compiling/checks/MapperWithoutDaoFactoryCheckSample.javacovering edge cases.MapperWithoutDaoFactoryCheck.javaand corresponding unit tests.This will update automatically on new commits.