-
Notifications
You must be signed in to change notification settings - Fork 12
[INJIVER-1534] fix: sonar reliability and coverage #156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[INJIVER-1534] fix: sonar reliability and coverage #156
Conversation
… safely Signed-off-by: srikanth716 <[email protected]>
Signed-off-by: srikanth716 <[email protected]>
…ver-1534-sonar-reliability-issue-coverage
WalkthroughAdds multiplatform test annotation support, large new JVM/common test suites for QR/CBOR/JSON mapping and utilities, a small Android unit-test message tweak, and a guarded temp-file deletion with error logging in PixelPass.decodeBinary. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In
`@kotlin/PixelPass/src/androidUnitTest/kotlin/io/mosip/pixelpass/QrDataConvertorAndroidTest.kt`:
- Around line 55-58: The test expects convertQRDataIntoBase64 to let the
RuntimeException from QrCode.encodeText propagate, but the implementation in
QrDataConvertorAndroid.kt currently swallows all exceptions in the catch (e:
Exception) block and returns ""; change the implementation in
convertQRDataIntoBase64 to stop suppressing errors — either remove the broad
try/catch so exceptions bubble up, or rethrow the caught exception (e.g., throw
e) instead of returning an empty string; keep logging (logger.severe) if desired
but ensure the exception is propagated to satisfy
assertFailsWith<RuntimeException>.
In `@kotlin/PixelPass/src/commonTest/kotlin/io/mosip/pixelpass/PixelPassTest.kt`:
- Around line 726-745: The test testComplexMappingRoundTrip prepares a
decodeKeyMapper but never uses it; either rename the test to reflect it only
encodes (e.g., testComplexMappingEncode) or complete the round-trip by calling
the decoding method (use pixelPass.getMappedData or the appropriate decode
function with the encoded map and decodeKeyMapper) and add assertions that the
decoded JSONObject contains "userStatus"="active" and "userName"="TestUser".
Ensure you reference the existing local variables encodeKeyMapper,
encodeValueMapper, decodeKeyMapper and the encoded result when adding the decode
call and assertions.
🧹 Nitpick comments (3)
kotlin/PixelPass/src/jvmTest/kotlin/io/mosip/pixelpass/UtilsTest.kt (1)
292-343: Tighten Claim169 tests with deterministic expectations.A few tests only assert non-null or rely on implicit mapper configuration, which can pass even if mappings are incorrect. Consider asserting specific transformed values using known mapper entries or a test-local mapper to improve reliability.
kotlin/PixelPass/src/commonTest/kotlin/io/mosip/pixelpass/PixelPassTest.kt (2)
277-279: Consider simplifying redundant type cast.After the
is Stringcheck on line 278, the explicit cast on line 279 is safe but could be simplified. A similar pattern appears at lines 344-345.♻️ Suggested simplification
assertNotNull(result) - assertTrue(result is String) - assertTrue((result as String).isNotEmpty()) + assertTrue(result is String && result.isNotEmpty())Or using smart cast:
assertNotNull(result) assertTrue(result is String) assertTrue(result.isNotEmpty()) // Smart cast applies after type check
663-672: Consider adding positive test cases fordecodeBinary.Currently only the error path is tested. If valid binary decoding is a core feature, consider adding test cases with valid image byte arrays (e.g., minimal valid PNG or JPEG headers) to verify successful decoding behavior.
kotlin/PixelPass/src/androidUnitTest/kotlin/io/mosip/pixelpass/QrDataConvertorAndroidTest.kt
Outdated
Show resolved
Hide resolved
kotlin/PixelPass/src/commonTest/kotlin/io/mosip/pixelpass/PixelPassTest.kt
Show resolved
Hide resolved
Signed-off-by: srikanth716 <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@kotlin/PixelPass/src/jvmTest/kotlin/io/mosip/pixelpass/IgnoreOnAndroid.kt`:
- Line 3: The JVM actual annotation class IgnoreOnAndroid is missing the `@Target`
and `@Retention` metadata present on the expect declaration; update the actual
declaration of IgnoreOnAndroid to include the exact same `@Target`(...) and
`@Retention`(...) annotations as the expect declaration (copy the AnnotationTarget
entries and AnnotationRetention value), and add the necessary imports
(kotlin.annotation.Target, kotlin.annotation.Retention,
kotlin.annotation.AnnotationTarget, kotlin.annotation.AnnotationRetention) so
the JVM annotation metadata matches the expect metadata exactly.
♻️ Duplicate comments (1)
kotlin/PixelPass/src/commonTest/kotlin/io/mosip/pixelpass/PixelPassTest.kt (1)
759-767: Rename test or add a decode step.The test name says “GenerateQRCodeAndDecode” but only generates and asserts non-empty output. Either rename to match intent or add a decode step if the API supports it.
✅ Suggested rename
- fun testGenerateQRCodeAndDecodeIntegration() { + fun testGenerateQRCodeIntegration() {
kotlin/PixelPass/src/jvmTest/kotlin/io/mosip/pixelpass/IgnoreOnAndroid.kt
Show resolved
Hide resolved
…xpect declaration Signed-off-by: srikanth716 <[email protected]>
|



Summary by CodeRabbit
Bug Fixes
Tests
✏️ Tip: You can customize this high-level summary in your review settings.