Skip to content

feat: add Duplicates and Mismatch validators; enhance validation command options#3

Merged
konradmichalik merged 1 commit intomainfrom
duplicates-validator
Jun 24, 2025
Merged

feat: add Duplicates and Mismatch validators; enhance validation command options#3
konradmichalik merged 1 commit intomainfrom
duplicates-validator

Conversation

@konradmichalik
Copy link
Copy Markdown
Contributor

@konradmichalik konradmichalik commented Jun 24, 2025

Summary by CodeRabbit

  • New Features

    • Introduced support for multiple validators when validating translation files, including new checks for duplicate keys and key mismatches.
    • Added the ability to specify a particular validator when running translation validation.
    • Enhanced output messages for validation results and errors.
  • Documentation

    • Updated documentation to clarify supported validators and provide additional usage guidance.
  • Tests

    • Added test cases and scripts to verify detection of duplicate translation keys in XLIFF files.

@konradmichalik konradmichalik merged commit 2fe26c7 into main Jun 24, 2025
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jun 24, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The changes introduce a modular validation system for translation files, adding new validator classes for detecting key mismatches and duplicates. The command-line interface now supports specifying validators. Utility methods are added for resolving parsers and validators. Documentation is updated to reflect these enhancements, and tests are adjusted for duplicate detection.

Changes

File(s) Change Summary
README.md Updated phrasing, listed supported validators with links, and added usage notes.
src/Command/ValidateTranslationCommand.php Refactored to support multiple/specific validators, removed old validation logic, updated output.
src/Parser/ParserUtility.php Added methods to resolve allowed file extensions, validators, and parser classes.
src/Parser/XliffParser.php Added static method to declare supported validators.
src/Utility/OutputUtility.php Introduced utility class for conditional debug output.
src/Validator/DuplicatesValidator.php Added new validator class for detecting duplicate translation keys.
src/Validator/MismatchValidator.php Added new validator class for detecting key mismatches between source and target files.
src/Validator/ValidatorInterface.php Added interface for validator classes with a validate method.
tests/Build/app/Language/XLIFF-fail/locallang.xlf Added duplicate translation unit to test duplicate detection.
tests/Build/app/composer.json Added script to run duplicate validator on test directories.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Command as ValidateTranslationCommand
    participant ParserUtil as ParserUtility
    participant Validator as ValidatorInterface (e.g., MismatchValidator, DuplicatesValidator)
    participant Output

    User->>Command: Run validation command (optionally with --validator)
    Command->>ParserUtil: resolveValidators() / resolveParserClasses()
    ParserUtil-->>Command: List of validator class names
    loop For each validator
        Command->>Validator: validate(fileDetector, parserClass, allFiles)
        Validator->>Output: Output validation results
    end
    Command->>User: Print summary and exit code
Loading

Poem

In the warren where translations dwell,
New validators hop in, keen to tell—
Of keys that mismatch, or duplicate rows,
Parsers and utilities, each rabbit knows.
With a twitch of the nose and a debug cheer,
Our code grows clearer, year by year!
🐇✨


📜 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 4a98617 and 479944e.

📒 Files selected for processing (10)
  • README.md (2 hunks)
  • src/Command/ValidateTranslationCommand.php (5 hunks)
  • src/Parser/ParserUtility.php (3 hunks)
  • src/Parser/XliffParser.php (2 hunks)
  • src/Utility/OutputUtility.php (1 hunks)
  • src/Validator/DuplicatesValidator.php (1 hunks)
  • src/Validator/MismatchValidator.php (1 hunks)
  • src/Validator/ValidatorInterface.php (1 hunks)
  • tests/Build/app/Language/XLIFF-fail/locallang.xlf (1 hunks)
  • tests/Build/app/composer.json (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

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.

1 participant