Skip to content

Conversation

@chrismacdonaldw
Copy link
Contributor

@chrismacdonaldw chrismacdonaldw commented Oct 31, 2025

Summary by CodeRabbit

  • New Features
    • Added configurable string truncation for migration processes: set maximum length, enable word-safe truncation to avoid cutting words, and optionally append an ellipsis. Configuration is validated to prevent invalid settings, and empty or non-string inputs are preserved unchanged. Usage example and documentation included.

@chrismacdonaldw chrismacdonaldw added the patch Backwards compatible bug fixes. label Oct 31, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 31, 2025

Walkthrough

Adds a new Drupal Migrate process plugin class Truncate to truncate string values with configurable max_length, word_safe, and add_ellipsis; validates configuration in the constructor and delegates truncation to Unicode::truncate().

Changes

Cohort / File(s) Summary
New Truncate Process Plugin
src/Plugin/migrate/process/Truncate.php
Adds Truncate class extending ProcessPluginBase. Introduces typed properties maxLength, wordSafe, addEllipsis; constructor validates max_length (required, positive); transform() returns non-strings unchanged and calls Unicode::truncate() for strings.

Sequence Diagram(s)

sequenceDiagram
    participant Migration as Migration Process
    participant Truncate as Truncate Plugin
    participant Unicode as Unicode Utility
    participant Result as Output

    Migration ->> Truncate: transform(value, migrate_executable, row, dest)
    alt value is empty or not string
        Truncate -->> Result: return original value
    else
        Truncate ->> Unicode: truncate(value, maxLength, wordSafe, addEllipsis)
        Unicode -->> Truncate: truncated string
        Truncate -->> Result: return truncated string
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Inspect constructor validation for max_length and type consistency.
  • Confirm transform() handles non-string/empty inputs and calls Unicode::truncate() with correct arguments.
  • Verify annotations (@MigrateProcessPlugin) and namespace/imports.

Poem

🐰 I nibble bytes and lop each line,
Snip to length, make endings fine,
Word-safe hops, ellipsis if queued,
Migration carrots neatly chewed,
Hooray — one tidy field renewed! 🥕✂️

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Create truncate plugin" is directly related to the main change in the changeset, which introduces a new Drupal Migrate process plugin called Truncate. The title is concise, clear, and specific enough that a teammate scanning the git history would immediately understand that this PR adds a truncate plugin. The issue reference (JIM-137) is a standard convention and does not detract from the clarity of the change description. The title accurately summarizes the primary objective without vague terminology or noise.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch JIM-137

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 88937bb and 47fe07c.

📒 Files selected for processing (1)
  • src/Plugin/migrate/process/Truncate.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Plugin/migrate/process/Truncate.php
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: PHPUnit / Drupal 10.4 | PHP 8.3
  • GitHub Check: PHPUnit / Drupal 10.3 | PHP 8.2
  • GitHub Check: PHPUnit / Drupal 10.5 | PHP 8.3
  • GitHub Check: PHPUnit / Drupal 11.1 | PHP 8.3
  • GitHub Check: PHPUnit / Drupal 10.4 | PHP 8.4
  • GitHub Check: PHPUnit / Drupal 10.5 | PHP 8.4

Warning

Review ran into problems

🔥 Problems

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
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: 3

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e6e0dac and 88937bb.

📒 Files selected for processing (1)
  • src/Plugin/migrate/process/Truncate.php (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: Code Linting
src/Plugin/migrate/process/Truncate.php

[warning] 21-21: Line exceeds 80 characters; contains 85 characters (Drupal.Files.LineLength.TooLong)


[warning] 22-22: Line exceeds 80 characters; contains 100 characters (Drupal.Files.LineLength.TooLong)


[error] 61-61: There must be exactly one blank line before the tags in a doc comment (Drupal.Commenting.DocComment.SpacingBeforeTags)


[error] 61-61: Data types in @throws tags need to be fully namespaced (Drupal.Commenting.DataTypeNamespace.DataTypeNamespace)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: PHPUnit / Drupal 10.3 | PHP 8.2
  • GitHub Check: PHPUnit / Drupal 10.4 | PHP 8.4
  • GitHub Check: PHPUnit / Drupal 10.5 | PHP 8.4
  • GitHub Check: PHPUnit / Drupal 10.5 | PHP 8.3
  • GitHub Check: PHPUnit / Drupal 10.4 | PHP 8.3
🔇 Additional comments (3)
src/Plugin/migrate/process/Truncate.php (3)

1-10: LGTM!

The namespace and imports are correctly structured for a Drupal Migrate process plugin.


36-58: LGTM!

The class structure and typed properties are well-designed and properly documented.


82-88: LGTM!

The transform method correctly handles edge cases (empty and non-string values) and properly delegates to Drupal's Unicode::truncate utility with the configured parameters.

Note: empty($value) returns TRUE for the string "0", but this is acceptable behavior for truncation since "0" is already a short string that doesn't need processing.

chrismacdonaldw and others added 4 commits October 30, 2025 21:32
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@nchiasson-dgi nchiasson-dgi added minor Added functionality that is backwards compatible. and removed patch Backwards compatible bug fixes. labels Nov 3, 2025
@nchiasson-dgi nchiasson-dgi merged commit 923e309 into main Nov 3, 2025
11 checks passed
@nchiasson-dgi nchiasson-dgi deleted the JIM-137 branch November 3, 2025 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor Added functionality that is backwards compatible.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants