notification-service: extract repeated route error messages into constants (kotlin:S1192) - #1552
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
…tants (kotlin:S1192)
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes two SonarCloud
kotlin:S1192(duplicated string literal) findings inservices/notification-service/.../routes/Routes.kt:AZ6OP-RWRoUIIbwnU9eq—"Notification ID is required"repeated 3× (GET/PUT/DELETE/{id}handlers)AZ6OP-RWRoUIIbwnU9er—"Notification not found"repeated 3× (same three handlers)Both messages now live as top-level constants in
Routes.ktand every call site references them, so the client-facing error text can only diverge in one place:Response bodies are byte-for-byte unchanged.
Test
New
routes/RoutesTest.ktboots the routing module under Ktor's test host with a mockedNotificationService(via Koin) and asserts that GET/api/v1/notifications/{id}, PUT/{id}/read, and DELETE/{id}all return 404 with the sharedNOTIFICATION_NOT_FOUNDbody, plus a guard that the constants carry the original messages. It does not compile againstmain(the constants don't exist there).cd services/notification-service && ./gradlew build— 35 tests, all green.Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/295ba1f62fdf4469ba720d4b7bc81fe1
Open in Devin Desktop: https://partner-workshops.devinenterprise.com/desktop/session/295ba1f62fdf4469ba720d4b7bc81fe1?variant=devin
Requested by: @mbatchelor81