Conversation
添加设置选项以还原歌词中的屏蔽词(如 f**k 还原为 fuck)。新增迁移函数、设置状态、UI 开关及歌词处理逻辑。
Summary of ChangesHello @kazukokawagawa, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 此拉取请求引入了一个新功能,允许用户选择还原歌词中被屏蔽的词汇。通过在设置中提供一个用户界面开关,用户可以控制是否将“f**k”等审查过的词语恢复为原始形式。这一改进增强了用户对歌词显示内容的控制,并确保了设置状态的正确持久化和迁移。 Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
The pull request introduces a feature to uncensor masked profanity in lyrics. While the implementation is functional, there are several performance and correctness issues. Specifically, the use of multiple sequential regex replacements is inefficient, and the current patterns risk false positives. Additionally, the processing pipeline leads to redundant deep cloning of lyric data, and a utility function accesses global state directly, which impacts testability and modularity.
There was a problem hiding this comment.
Pull request overview
This PR adds a feature to restore censored profanity in song lyrics (e.g., "f**k" → "fuck"). The implementation follows established patterns in the codebase for lyric transformation features, including a new utility module, setting state management, migration function, and UI configuration.
Changes:
- Added
lyricProfanity.tsutility module with regex-based replacement logic for common profanity censorship patterns - Integrated profanity uncensor processing into the lyric pipeline in
LyricManager.ts - Added
uncensorMaskedProfanitysetting with migration from schema version 10 to 11
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/utils/lyric/lyricProfanity.ts | New utility module implementing regex-based profanity uncensoring for masked words in lyrics |
| src/stores/setting.ts | Added uncensorMaskedProfanity boolean property to settings state with default value false |
| src/stores/migrations/settingMigrations.ts | Incremented schema version to 11 and added migration function to initialize the new setting |
| src/core/player/LyricManager.ts | Integrated applyProfanityUncensor into lyric processing pipeline after bracket replacement |
| src/components/Setting/config/play.ts | Added "Fuck *** Mode" UI toggle with description for the profanity uncensor feature |
| .replace(/\*{4}ing/gi, "fucking") | ||
| .replace(/b\*{3}h/gi, "bitch") | ||
| .replace(/d\*{2}k/gi, "dick") | ||
| .replace(/d\*{2}n/gi, "damn") | ||
| .replace(/\*{4}er/gi, "fucker") |
There was a problem hiding this comment.
The generic patterns "****ing" and "****er" could potentially match censored words other than the intended profanity. While the likelihood of false positives is low in practice (since music services typically only censor profanity), consider adding a comment explaining the assumption that these patterns primarily match "fucking" and "fucker" respectively, to help future maintainers understand the design decision.
| const replaceMaskedProfanity = (text: string) => { | ||
| if (!text) return text; | ||
| return text | ||
| .replace(/f\*{2}k/gi, "fuck") | ||
| .replace(/s\*{2}t/gi, "shit") | ||
| .replace(/c\*{2}t/gi, "cunt") | ||
| .replace(/c\*{2}k/gi, "cock") | ||
| .replace(/co\*{2}/gi, "cock") | ||
| .replace(/s\*{2}ker/gi, "sucker") | ||
| .replace(/\*{4}ing/gi, "fucking") | ||
| .replace(/b\*{3}h/gi, "bitch") | ||
| .replace(/d\*{2}k/gi, "dick") | ||
| .replace(/d\*{2}n/gi, "damn") | ||
| .replace(/\*{4}er/gi, "fucker") | ||
| .replace(/as\*{2}le/gi, "asshole") | ||
| .replace(/w\*{3}e/gi, "whore") | ||
| .replace(/n\*{3}a/gi, "nigga"); | ||
| }; |
There was a problem hiding this comment.
Missing JSDoc comment for the replaceMaskedProfanity function. Following the codebase convention seen in lyricFormat.ts, internal helper functions should have JSDoc comments explaining their purpose, parameters, and return values. This improves code maintainability and developer understanding.
| const processLine = (line: LyricLine) => { | ||
| if (line.words) { | ||
| line.words.forEach((w) => { | ||
| w.word = replaceMaskedProfanity(w.word); | ||
| if (w.romanWord) w.romanWord = replaceMaskedProfanity(w.romanWord); | ||
| }); | ||
| } | ||
| if (line.translatedLyric) line.translatedLyric = replaceMaskedProfanity(line.translatedLyric); | ||
| if (line.romanLyric) line.romanLyric = replaceMaskedProfanity(line.romanLyric); | ||
| }; |
There was a problem hiding this comment.
Missing JSDoc comment for the processLine function. Following the codebase convention seen in lyricFormat.ts (lines 169-175), helper functions should have JSDoc comments explaining their purpose and parameters.
| export const applyProfanityUncensor = (lyricData: SongLyric): SongLyric => { | ||
| const settingStore = useSettingStore(); | ||
| if (!settingStore.uncensorMaskedProfanity) return lyricData; | ||
|
|
||
| const newLyricData = cloneDeep(lyricData); | ||
| newLyricData.lrcData?.forEach(processLine); | ||
| newLyricData.yrcData?.forEach(processLine); | ||
| return newLyricData; | ||
| }; |
There was a problem hiding this comment.
Missing JSDoc comment for the applyProfanityUncensor function. Following the codebase convention seen in lyricFormat.ts (lines 42-46), exported functions should have JSDoc comments explaining their purpose, parameters, and return values.
修复 applyProfanityUncensor 函数中未正确传递去码设置的问题,将设置判断逻辑从函数内部移至调用处,确保歌词去码功能能根据用户设置正确生效。
添加设置选项以还原歌词中的屏蔽词(如 f**k 还原为 fuck)。新增迁移函数、设置状态、UI 开关及歌词处理逻辑。