fix: resolve all sonarjs/no-duplicate-string lint warnings - #26
Merged
Conversation
Agent-Logs-Url: https://github.com/leejsinclair/kipling-v2/sessions/ec6ff984-8a3f-41d1-81c7-a8d9c5e33e80 Co-authored-by: leejsinclair <707675+leejsinclair@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
leejsinclair
May 16, 2026 06:20
View session
leejsinclair
marked this pull request as ready for review
May 16, 2026 06:21
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors the codebase to eliminate 11 sonarjs/no-duplicate-string lint warnings by extracting repeated string literals into named constants and removing duplicated API key guard code in favor of an existing ensureApiKey() helper.
Changes:
- Extract repeated literals (bullet prefixes, color classes, test fixtures, grade labels) into named constants across 6 files.
- Replace duplicated inline API key validation with
ensureApiKey()helper inimproveStoryWithAI/improveCriteriaWithAI. - No behavior change; refactor-only.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/criteriaScoring.js | Extracts BULLET_PREFIX_THE_SYSTEM / BULLET_PREFIX_SYSTEM_MUST constants. |
| src/llmService.js | Delegates to ensureApiKey(); adds NOT_PROVIDED constant. |
| src/components/CriteriaScoreBreakdown.jsx | Adds COLOR_GREEN constant for repeated Tailwind class. |
| src/test/criteriaScoring.test.js | Adds shared BULLET_CRITERIA fixture. |
| src/test/llmService.test.js | Adds TEST_API_KEY and SAMPLE_CRITERION constants. |
| src/test/scoreSoThatStatement.test.js | Adds GRADE_NEEDS_WORK constant. |
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.
Eliminates all 11
sonarjs/no-duplicate-stringwarnings surfaced bynpm run lintby extracting repeated string literals into named constants and consolidating duplicate API key guard logic.📝 Summary
11
sonarjs/no-duplicate-stringwarnings across 6 files — each caused by string literals repeated 3–8 times. Fixed by extracting constants and removing redundant inline guards in favour of the existingensureApiKey()helper.🔧 Changes
criteriaScoring.js—BULLET_PREFIX_THE_SYSTEM/BULLET_PREFIX_SYSTEM_MUSTconstants replace 3× inline literals eachllmService.js—improveStoryWithAIandimproveCriteriaWithAInow delegate to the existingensureApiKey()helper instead of duplicating the guard;NOT_PROVIDEDconstant replaces 3× inline'(not provided)'inbuildCriteriaPromptCriteriaScoreBreakdown.jsx— module-levelCOLOR_GREENconstant replaces 3×'text-green-600'criteriaScoring.test.js—BULLET_CRITERIAconstant replaces 3 identical inline arraysllmService.test.js—TEST_API_KEY(8 uses) andSAMPLE_CRITERION(4 uses) constants extractedscoreSoThatStatement.test.js—GRADE_NEEDS_WORKconstant replaces 3×'Needs work'Notable: the
llmService.jsfix also removes dead duplicate validation code —ensureApiKey()already existed at module scope and is a function declaration (hoisted), so replacing the inline guards is a pure deduplification with no behaviour change.🎯 Motivation
npm run lintreported 11 warnings. Reducing string duplication improves maintainability: rename/update in one place rather than hunting literals.🧪 Testing
npm run lint— 0 warnings (was 11)npm test -- --run— 222/222 tests pass📸 Screenshots (optional)
N/A
✅ Checklist