Skip to content

Refractoring code smells#220

Open
DarunNayeem wants to merge 2 commits into
vdurmont:masterfrom
DarunNayeem:master
Open

Refractoring code smells#220
DarunNayeem wants to merge 2 commits into
vdurmont:masterfrom
DarunNayeem:master

Conversation

@DarunNayeem

Copy link
Copy Markdown

Before, the library mixed startup work, indexing, and ordering logic directly inside the static initializer in EmojiManager.java, and EmojiParser.java repeated nearly identical anonymous transformer logic for aliases and HTML encodings. EmojiLoader.java also used manual stream handling and verbose JSON field branching.

After, the bootstrap logic is split into small helpers for indexing and sorting, the parser’s transformation rules are centralized in dedicated methods, and the loader uses simpler field extraction and safer cleanup. I also preserved variation selectors in parser candidates because that was required to keep the round-trip emoji tests passing.

This refactor improves readability and maintainability without changing the library’s public API. It addresses three areas: static initialization in the emoji manager, duplicated transformation logic in the parser, and stream/JSON handling in the loader. The parser change also fixes a loss of variation selector data that broke round-trip behavior on some emoji sequences.

Before, the library mixed startup work, indexing, and ordering logic directly inside the static initializer in EmojiManager.java, and EmojiParser.java repeated nearly identical anonymous transformer logic for aliases and HTML encodings. EmojiLoader.java also used manual stream handling and verbose JSON field branching.

After, the bootstrap logic is split into small helpers for indexing and sorting, the parser’s transformation rules are centralized in dedicated methods, and the loader uses simpler field extraction and safer cleanup. I also preserved variation selectors in parser candidates because that was required to keep the round-trip emoji tests passing.

This refactor improves readability and maintainability without changing the library’s public API. It addresses three areas: static initialization in the emoji manager, duplicated transformation logic in the parser, and stream/JSON handling in the loader. The parser change also fixes a loss of variation selector data that broke round-trip behavior on some emoji sequences.
Copilot AI review requested due to automatic review settings July 4, 2026 16:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Refactors core emoji initialization and parsing code to reduce duplication, improve readability, and preserve variation selector data to maintain round-trip behavior for certain emoji sequences.

Changes:

  • Extracted repeated EmojiTransformer switch logic in EmojiParser into dedicated helper methods and added variation-selector support to unicode candidates and extraction.
  • Split EmojiManager static initialization into smaller indexing/sorting helpers and added safer stream cleanup.
  • Simplified JSON field extraction and made stream-to-string reading safer in EmojiLoader.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/main/java/com/vdurmont/emoji/EmojiParser.java Centralizes transformer logic and preserves variation selectors in unicode candidate handling and extraction.
src/main/java/com/vdurmont/emoji/EmojiManager.java Refactors static initialization into helper methods and improves stream cleanup.
src/main/java/com/vdurmont/emoji/EmojiLoader.java Simplifies JSON optional-field handling and ensures reader cleanup via finally.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/main/java/com/vdurmont/emoji/EmojiManager.java
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.

2 participants