Skip to content

remove deprecated text property from word#2193

Merged
jo-elimu merged 3 commits intomainfrom
1769-remove-deprecated-text-property-from-word
May 23, 2025
Merged

remove deprecated text property from word#2193
jo-elimu merged 3 commits intomainfrom
1769-remove-deprecated-text-property-from-word

Conversation

@jo-elimu
Copy link
Copy Markdown
Member

Issue Number

Purpose

Technical Details

Testing Instructions

Screenshots


Format Checks

Note

Files in PRs are automatically checked for format violations with mvn spotless:check.

If this PR contains files with format violations, run mvn spotless:apply to fix them.

@jo-elimu jo-elimu self-assigned this May 23, 2025
@jo-elimu jo-elimu requested a review from a team as a code owner May 23, 2025 15:04
@jo-elimu jo-elimu requested review from alexander-kuruvilla, eymaal and vrudas and removed request for a team May 23, 2025 15:04
@jo-elimu jo-elimu linked an issue May 23, 2025 that may be closed by this pull request
6 tasks
@jo-elimu jo-elimu merged commit 3efd48e into main May 23, 2025
13 checks passed
@jo-elimu jo-elimu deleted the 1769-remove-deprecated-text-property-from-word branch May 23, 2025 15:06
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented May 23, 2025

Caution

Review failed

The pull request is closed.

"""

Walkthrough

The changes introduce a new toString() method in the Word entity, update the display order of letter-sound correspondences in various JSP views, and restructure the word listing table for clarity. The only build-related change is an update to the main artifact version in the dependency tree file.

Changes

File(s) Change Summary
pom-dependency-tree.txt Updated the main project artifact version from 2.6.12-SNAPSHOT to 2.6.15-SNAPSHOT.
src/main/java/ai/elimu/entity/content/Word.java Added a toString() method to concatenate and return the letters from the word's letter-sound correspondences.
src/main/webapp/WEB-INF/jsp/content/word/create.jsp
src/main/webapp/WEB-INF/jsp/content/word/edit.jsp
Changed the display order of letter-sound correspondences in the chip elements to show sounds before letters.
src/main/webapp/WEB-INF/jsp/content/word/list.jsp Simplified the word listing table by merging columns, displaying word details and letter-sound correspondences together, and reversing the display order to show sounds before letters.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant JSP_View
    participant Word_Entity

    User->>JSP_View: Request word list/create/edit page
    JSP_View->>Word_Entity: word.toString()
    Word_Entity-->>JSP_View: Concatenated letters from letterSounds
    JSP_View-->>User: Rendered page (sounds shown before letters)
Loading

Assessment against linked issues

Objective Addressed Explanation
Remove deprecated text property from Word JPA entity and database table (#1769) The text property was not removed from the entity or database; no migration script is present.
Add toString() method to Word entity (#1769)
Update frontend files to use new structure and display (#1769)
Update controller classes and CSS files (#1769) No controller or CSS changes are present; unclear if needed or already handled elsewhere.

Suggested reviewers

  • tomaszsmy
  • vrudas
  • shiv810
  • AshishBagdane
    """

Note

⚡️ AI Code Reviews for VS Code, Cursor, Windsurf

CodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback.
Learn more here.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 26a7e6f and cfd819f.

📒 Files selected for processing (1)
  • src/main/webapp/WEB-INF/jsp/content/word/list.jsp (1 hunks)

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a 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

🔭 Outside diff range comments (2)
src/main/webapp/WEB-INF/jsp/content/word/create.jsp (1)

89-89: ⚠️ Potential issue

Fix inconsistency between template and JavaScript display order.

The JavaScript code still uses the old display order (letters first, then sounds), which is inconsistent with the updated template that now shows sounds first.

Apply this diff to match the new template order:

-$('#letterSoundsContainer').append('<div class="chip">"' + letterSoundLetters + '"<br />↓<br />/' + letterSoundSounds + '/</div>');
+$('#letterSoundsContainer').append('<div class="chip">/' + letterSoundSounds + '/<br />↓<br />"' + letterSoundLetters + '"</div>');
src/main/webapp/WEB-INF/jsp/content/word/edit.jsp (1)

109-109: ⚠️ Potential issue

Fix JavaScript inconsistency to match template order.

Same issue as in create.jsp - the JavaScript code uses the old display order while the template uses the new order.

Apply this diff to maintain consistency:

-$('#letterSoundsContainer').append('<div class="chip">"' + letterSoundLetters + '"<br />↓<br />/' + letterSoundSounds + '/</div>');
+$('#letterSoundsContainer').append('<div class="chip">/' + letterSoundSounds + '/<br />↓<br />"' + letterSoundLetters + '"</div>');
🧹 Nitpick comments (1)
src/main/webapp/WEB-INF/jsp/content/word/list.jsp (1)

71-75: Improve CSS organization and accessibility.

While the word type display consolidation is good, consider moving the inline styles to CSS classes for better maintainability.

-                                ${word.wordType}
-                                <div style="font-size: 2em;">
-                                    <c:out value=" ${emojisByWordId[word.id]}" />
-                                </div>
+                                <div class="word-type-container">
+                                    <span class="word-type-text">${word.wordType}</span>
+                                    <div class="word-type-emoji">
+                                        <c:out value=" ${emojisByWordId[word.id]}" />
+                                    </div>
+                                </div>

Add corresponding CSS:

.word-type-emoji { font-size: 2em; }
.word-text-large { font-size: 2em; }
.word-display { margin-bottom: 1em; }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 04c9bd7 and 26a7e6f.

📒 Files selected for processing (5)
  • pom-dependency-tree.txt (1 hunks)
  • src/main/java/ai/elimu/entity/content/Word.java (2 hunks)
  • src/main/webapp/WEB-INF/jsp/content/word/create.jsp (1 hunks)
  • src/main/webapp/WEB-INF/jsp/content/word/edit.jsp (1 hunks)
  • src/main/webapp/WEB-INF/jsp/content/word/list.jsp (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (11)
  • GitHub Check: test_ui
  • GitHub Check: test_ui
  • GitHub Check: test_rest
  • GitHub Check: build (macos-latest, 21)
  • GitHub Check: build (macos-latest, 17)
  • GitHub Check: build (windows-latest, 17)
  • GitHub Check: test_rest
  • GitHub Check: test_rest
  • GitHub Check: build (ubuntu-latest, 17)
  • GitHub Check: build (ubuntu-latest, 21)
  • GitHub Check: build (windows-latest, 21)
🔇 Additional comments (7)
pom-dependency-tree.txt (1)

1-1: Version update looks good.

The version bump from 2.6.12-SNAPSHOT to 2.6.15-SNAPSHOT is a routine update that aligns with the project changes.

src/main/webapp/WEB-INF/jsp/content/word/create.jsp (1)

44-48: Display order change looks good, but check JavaScript consistency.

The reversal of letter-sound correspondence display order (sounds first, then letters) is implemented correctly in the template.

src/main/webapp/WEB-INF/jsp/content/word/edit.jsp (1)

64-68: Display order change is consistent with create.jsp.

The letter-sound correspondence display order change matches the pattern used in create.jsp, maintaining consistency across the UI.

src/main/java/ai/elimu/entity/content/Word.java (1)

15-15: Import addition is appropriate.

The java.util.stream.Collectors import is correctly added to support the stream operations in the new toString() method.

src/main/webapp/WEB-INF/jsp/content/word/list.jsp (3)

28-28: Table header simplification looks good.

The consolidation of multiple columns into a single "Word" column simplifies the table structure.


54-69: Approve the sound-to-letter correspondence reordering.

The change to display sounds first, followed by letters, with the downward arrow is a logical improvement that shows the phonetic-to-textual mapping flow clearly.


41-52: 🛠️ Refactor suggestion

Inconsistent with PR objectives and confusing user experience.

This implementation has several concerns:

  1. Inconsistency with PR objectives: The PR states it removes the deprecated text property, but ${word.text} is still being used on line 45.

  2. Confusing dual display: Showing both word.getText() and word.toString() representations without clear user-friendly labels may confuse users about the difference between these values.

  3. Technical labels: Using method names like "word.getText()" and "word.toString()" as labels is not user-friendly for non-technical users.

Consider this improved approach:

-                                <div style="float: right; text-align: right;">
-                                    <label>word.getText()</label>
-                                    <div style="font-size: 2em;">
-                                        "${word.text}"
-                                    </div>
-                                </div>
-                                
-                                <label>word.toString()</label>
-                                <div style="font-size: 2em;">
-                                    "${word}"
-                                </div>
+                                <div class="word-display">
+                                    <label>Text Representation</label>
+                                    <div class="word-text-large">
+                                        "${word}"
+                                    </div>
+                                </div>

And add corresponding CSS classes instead of inline styles.

Likely an incorrect or invalid review comment.

Comment on lines +47 to +53
public String toString() {
String letters = "";
for (LetterSound letterSound : letterSounds) {
letters += letterSound.getLetters().stream().map(Letter::getText).collect(Collectors.joining());
}
return letters;
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve toString() implementation for robustness and efficiency.

The current implementation has several issues that should be addressed:

  1. Null safety: No null checks for letterSounds or individual letterSound objects
  2. Inefficiency: String concatenation in a loop creates multiple intermediate objects
  3. Readability: No separators between letter groups may affect readability

Apply this diff to improve the implementation:

-  public String toString() {
-    String letters = "";
-    for (LetterSound letterSound : letterSounds) {
-      letters += letterSound.getLetters().stream().map(Letter::getText).collect(Collectors.joining());
-    }
-    return letters;
-  }
+  public String toString() {
+    if (letterSounds == null || letterSounds.isEmpty()) {
+      return "";
+    }
+    return letterSounds.stream()
+      .filter(letterSound -> letterSound != null && letterSound.getLetters() != null)
+      .map(letterSound -> letterSound.getLetters().stream()
+        .map(Letter::getText)
+        .collect(Collectors.joining()))
+      .collect(Collectors.joining());
+  }

This version:

  • Adds null safety checks
  • Uses streams throughout for better performance
  • Filters out null objects to prevent runtime exceptions
  • Maintains the same concatenation behavior while being more robust
🤖 Prompt for AI Agents
In src/main/java/ai/elimu/entity/content/Word.java around lines 47 to 53, the
toString() method lacks null checks for letterSounds and its elements, uses
inefficient string concatenation in a loop, and does not separate letter groups
for readability. To fix this, add null checks for letterSounds and each
letterSound, replace string concatenation with a StringBuilder or use streams to
join strings efficiently, filter out any null letterSound objects, and consider
adding a separator between letter groups to improve readability while preserving
the original concatenation logic.

Comment on lines +41 to 75
<td>
<div style="float: right; text-align: right;">
<label>word.getText()</label>
<div style="font-size: 2em;">
"${word.text}"
</div>
</div>

<label>word.toString()</label>
<div style="font-size: 2em;">
"${word}"
</div>

<div id="letterSoundsContainer">
<label>Sound-to-letter correspondences</label><br />
<c:forEach var="letterSound" items="${word.letterSounds}">
<input name="letterSounds" type="hidden" value="${letterSound.id}" />
<div class="chip">
<a href="<spring:url value='/content/letter-sound/edit/${letterSound.id}' />">
" <c:forEach var="letter" items="${letterSound.letters}">
${letter.text}<c:out value=" " />
</c:forEach> "<br />
/ <c:forEach var="sound" items="${letterSound.sounds}">
${sound.valueIpa}<c:out value=" " />
</c:forEach> /
</c:forEach> /<br />
↓<br />
" <c:forEach var="letter" items="${letterSound.letters}">
${letter.text}<c:out value=" " />
</c:forEach> "
</a>
</div>
</c:forEach>
</div>
</td>
<%--
<td>
<c:choose>
<c:when test="${word.spellingConsistency == 'PERFECT'}">
<c:set var="spellingConsistencyColor" value="green lighten-1" />
</c:when>
<c:when test="${word.spellingConsistency == 'HIGHLY_PHONEMIC'}">
<c:set var="spellingConsistencyColor" value="green lighten-3" />
</c:when>
<c:when test="${word.spellingConsistency == 'PHONEMIC'}">
<c:set var="spellingConsistencyColor" value="yellow lighten-3" />
</c:when>
<c:when test="${word.spellingConsistency == 'NON_PHONEMIC'}">
<c:set var="spellingConsistencyColor" value="orange lighten-3" />
</c:when>
<c:when test="${word.spellingConsistency == 'HIGHLY_NON_PHONEMIC'}">
<c:set var="spellingConsistencyColor" value="red lighten-3" />
</c:when>
<c:otherwise>
<c:set var="spellingConsistencyColor" value="" />
</c:otherwise>
</c:choose>
<div class="chip ${spellingConsistencyColor}">
<c:choose>
<c:when test="${word.spellingConsistency == 'PERFECT'}">Perfect (100% correspondence)</c:when>
<c:when test="${word.spellingConsistency == 'HIGHLY_PHONEMIC'}">Highly phonemic (80%-99% correspondence)</c:when>
<c:when test="${word.spellingConsistency == 'PHONEMIC'}">Phonemic (60%-79% correspondence)</c:when>
<c:when test="${word.spellingConsistency == 'NON_PHONEMIC'}">Non-phonemic (40%-59% correspondence)</c:when>
<c:when test="${word.spellingConsistency == 'HIGHLY_NON_PHONEMIC'}">Highly non-phonemic (0%-39% correspondence)</c:when>
</c:choose>
${word.wordType}
<div style="font-size: 2em;">
<c:out value=" ${emojisByWordId[word.id]}" />
</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify responsive design and layout consistency.

The new layout structure with floating divs and inline styles may cause issues on mobile devices or smaller screens. Please test the responsiveness of this layout.


🏁 Script executed:

#!/bin/bash
# Description: Check for responsive design patterns and CSS classes in JSP files
# Expected: Find consistent CSS patterns and responsive design considerations

echo "Checking for responsive design patterns in JSP files..."
rg -A 3 -B 3 "style.*float|font-size.*2em" --type jsp

echo -e "\nChecking for existing CSS classes that could be reused..."
rg "class.*word|class.*text" --type css --type scss

echo -e "\nChecking for mobile-responsive patterns..."
rg "@media|responsive|mobile" --type css --type scss

Length of output: 603


🏁 Script executed:

#!/bin/bash
# Re-verify inline styles and responsive patterns

echo "Searching for inline style attributes in JSP files..."
rg -n -g '*.jsp' -e 'style="[^"]*(float|font-size)' 

echo -e "\nSearching for responsive design patterns in CSS files..."
rg -n -g '*.css' -e '@media' -e 'responsive' -e 'mobile'

echo -e "\nSearching for responsive design patterns in SCSS files..."
rg -n -g '*.scss' -e '@media' -e 'responsive' -e 'mobile'

Length of output: 5888


Refactor inline styles for true responsiveness
Inline styles (e.g., float:right, font-size:2em) won’t adapt under your existing media queries (see static/css/styles.css at lines 274–284). To ensure layout consistency on smaller screens, move these styles into CSS classes and leverage your breakpoints.

Please address the following in src/main/webapp/WEB-INF/jsp/content/word/list.jsp (and similar files):

  • Line 42: <div style="float: right; text-align: right;">
  • Line 44: <div style="font-size: 2em;"> (word.text)
  • Line 50: <div style="font-size: 2em;"> (word.toString())
  • Line 73: <div style="font-size: 2em;"> (emoji)

Actions:

  • Create or reuse CSS classes (e.g., .word-text, .word-value, etc.).
  • Define responsive adjustments in styles.css under your @media screen and (max-width:1000px) rules.
  • Replace all inline style attributes in JSPs with these classes.
🤖 Prompt for AI Agents
In src/main/webapp/WEB-INF/jsp/content/word/list.jsp around lines 41 to 75,
replace all inline style attributes such as 'float: right; text-align: right;'
and 'font-size: 2em;' with appropriate CSS classes. Create or reuse classes like
.word-text or .word-value in your styles.css, and define responsive behavior for
these classes within the existing @media screen and (max-width:1000px) rules.
Then update the JSP to use these classes instead of inline styles to ensure
consistent layout and responsiveness on smaller screens.

@codecov
Copy link
Copy Markdown

codecov bot commented May 23, 2025

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 14.60%. Comparing base (2831101) to head (cfd819f).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/main/java/ai/elimu/entity/content/Word.java 0.00% 5 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #2193      +/-   ##
============================================
- Coverage     14.62%   14.60%   -0.02%     
  Complexity      397      397              
============================================
  Files           238      238              
  Lines          6491     6496       +5     
  Branches        753      754       +1     
============================================
  Hits            949      949              
- Misses         5491     5496       +5     
  Partials         51       51              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove deprecated text property from Word

1 participant