1use std::collections::HashMap;
2
3pub struct I18n {
4 pub lang: String,
5 messages: HashMap<String, HashMap<String, String>>,
6}
7
8impl I18n {
9 pub fn new(lang: &str) -> Self {
10 let normalized_lang = match lang.to_lowercase().replace("_", "-").as_str() {
12 "en" | "en-us" | "english" => "en-US",
13 "zh" | "zh-cn" | "chinese" => "zh-CN",
14 _ => lang,
15 };
16
17 let mut messages = HashMap::new();
18
19 let mut zh_cn = HashMap::new();
21 zh_cn.insert("title".to_string(), "🗑️ 垃圾代码猎人 🗑️".to_string());
22 zh_cn.insert(
23 "preparing".to_string(),
24 "正在准备吐槽你的代码...".to_string(),
25 );
26 zh_cn.insert(
27 "report_title".to_string(),
28 "📊 垃圾代码检测报告".to_string(),
29 );
30 zh_cn.insert(
31 "found_issues".to_string(),
32 "发现了一些需要改进的地方:".to_string(),
33 );
34 zh_cn.insert("statistics".to_string(), "📈 问题统计:".to_string());
35 zh_cn.insert(
36 "nuclear_issues".to_string(),
37 "🔥 核弹级问题 (需要立即修复)".to_string(),
38 );
39 zh_cn.insert(
40 "spicy_issues".to_string(),
41 "🌶️ 辣眼睛问题 (建议修复)".to_string(),
42 );
43 zh_cn.insert(
44 "mild_issues".to_string(),
45 "😐 轻微问题 (可以忽略)".to_string(),
46 );
47 zh_cn.insert("total".to_string(), "📝 总计".to_string());
48 zh_cn.insert("summary".to_string(), "📋 总结".to_string());
49 zh_cn.insert("suggestions".to_string(), "💡 改进建议".to_string());
50 zh_cn.insert(
51 "clean_code".to_string(),
52 "🎉 哇!你的代码居然没有明显的垃圾!".to_string(),
53 );
54 zh_cn.insert(
55 "clean_code_warning".to_string(),
56 "但是别高兴太早,也许你的逻辑有问题我还没检测到 😏".to_string(),
57 );
58 zh_cn.insert(
59 "keep_improving".to_string(),
60 "继续努力,让代码变得更好!🚀".to_string(),
61 );
62 zh_cn.insert("top_files".to_string(), "🏆 问题最多的文件".to_string());
63 zh_cn.insert("detailed_analysis".to_string(), "🔍 详细分析".to_string());
64
65 zh_cn.insert("project_personality".to_string(), "🧠 项目人格".to_string());
67 zh_cn.insert("score".to_string(), "评分:".to_string());
68 zh_cn.insert("threat_level".to_string(), "威胁等级:".to_string());
69 zh_cn.insert("corruption".to_string(), "腐化度:".to_string());
70 zh_cn.insert("core_traits".to_string(), "核心特征:".to_string());
71 zh_cn.insert("emotional_state".to_string(), "情绪状态:".to_string());
72 zh_cn.insert("philosophy".to_string(), "代码哲学:".to_string());
73 zh_cn.insert("lore".to_string(), "📜 传说:".to_string());
74
75 zh_cn.insert(
77 "codebase_autopsy".to_string(),
78 "☠ 代码库尸检报告".to_string(),
79 );
80 zh_cn.insert("cause_of_death".to_string(), "死因:".to_string());
81 zh_cn.insert("condition".to_string(), "状况:".to_string());
82 zh_cn.insert(
83 "high_contamination".to_string(),
84 "☣ 高污染区域:".to_string(),
85 );
86 zh_cn.insert("final_words".to_string(), "遗言:".to_string());
87 zh_cn.insert(
88 "mutation_propagation".to_string(),
89 "🧬 突变传播:".to_string(),
90 );
91 zh_cn.insert("infection_origin".to_string(), "☣ 感染源".to_string());
92 zh_cn.insert("replication_cluster".to_string(), "⚠ 复制集群".to_string());
93
94 zh_cn.insert("final_boss".to_string(), "☠ 最终BOSS".to_string());
96 zh_cn.insert("file".to_string(), "文件:".to_string());
97 zh_cn.insert("corruption_index".to_string(), "腐化指数:".to_string());
98 zh_cn.insert("known_attacks".to_string(), "已知攻击:".to_string());
99 zh_cn.insert("survival_chance".to_string(), "存活几率:".to_string());
100
101 zh_cn.insert(
103 "behavior_distribution".to_string(),
104 "🧬 行为分布".to_string(),
105 );
106
107 zh_cn.insert("final_verdict".to_string(), "📊 最终判决".to_string());
109 zh_cn.insert("mutation_density".to_string(), "突变密度:".to_string());
110
111 zh_cn.insert(
113 "person_copy_paste".to_string(),
114 "复制粘贴艺术家".to_string(),
115 );
116 zh_cn.insert("person_yolo".to_string(), "YOLO工程师".to_string());
117 zh_cn.insert("person_trait_wizard".to_string(), "Trait巫师".to_string());
118 zh_cn.insert("person_legacy".to_string(), "遗产驱魔人".to_string());
119 zh_cn.insert("person_hotfix".to_string(), "热修复雇佣兵".to_string());
120 zh_cn.insert(
121 "person_enterprise".to_string(),
122 "企业官僚主义者".to_string(),
123 );
124 zh_cn.insert("person_startup".to_string(), "创业幸存者".to_string());
125 zh_cn.insert("person_academic".to_string(), "学术巫师".to_string());
126
127 zh_cn.insert(
129 "cond_terminal".to_string(),
130 "晚期——建议姑息治疗".to_string(),
131 );
132 zh_cn.insert("cond_critical".to_string(), "危重但可救治".to_string());
133 zh_cn.insert(
134 "cond_severe".to_string(),
135 "严重——上帝函数威胁可读性".to_string(),
136 );
137 zh_cn.insert(
138 "cond_moderate".to_string(),
139 "中度——部分函数需要拆分".to_string(),
140 );
141 zh_cn.insert("cond_chronic".to_string(), "慢性——需要简化治疗".to_string());
142 zh_cn.insert(
143 "cond_stable_debt".to_string(),
144 "稳定但技术债务利息很高".to_string(),
145 );
146 zh_cn.insert("cond_fair".to_string(), "尚可——建议定期维护".to_string());
147
148 zh_cn.insert(
150 "cod_duplication".to_string(),
151 "失控的重复代码转移".to_string(),
152 );
153 zh_cn.insert("cod_panic".to_string(), "恐慌驱动开发".to_string());
154 zh_cn.insert(
155 "cod_complexity".to_string(),
156 "复杂度坍塌——嵌套层级超过事件视界".to_string(),
157 );
158 zh_cn.insert(
159 "cod_naming".to_string(),
160 "语义饥饿——变量名失去所有意义".to_string(),
161 );
162 zh_cn.insert(
163 "cod_todo".to_string(),
164 "TODO堆积——承诺超出交付能力".to_string(),
165 );
166 zh_cn.insert("cod_growth".to_string(), "不惜代价增长综合症".to_string());
167 zh_cn.insert(
168 "cod_abstraction".to_string(),
169 "抽象过量——复杂度超出理解能力".to_string(),
170 );
171 zh_cn.insert("cod_paper_cuts".to_string(), "千刀万剐式死亡".to_string());
172
173 zh_cn.insert("fw_hotfix".to_string(), "再修一个热修复".to_string());
175 zh_cn.insert(
176 "fw_error_handling".to_string(),
177 "以后再加错误处理".to_string(),
178 );
179 zh_cn.insert("fw_understand".to_string(), "我还是能看懂的".to_string());
180 zh_cn.insert("fw_temp2".to_string(), "temp2应该能用".to_string());
181 zh_cn.insert("fw_next_sprint".to_string(), "下个冲刺再修".to_string());
182 zh_cn.insert("fw_funding".to_string(), "等下一轮融资再修".to_string());
183 zh_cn.insert(
184 "fw_theory".to_string(),
185 "其实你理解了理论就很简单的".to_string(),
186 );
187 zh_cn.insert("fw_refactor".to_string(), "下个季度再重构".to_string());
188
189 zh_cn.insert("surv_none".to_string(), "无".to_string());
191 zh_cn.insert("surv_low".to_string(), "低".to_string());
192 zh_cn.insert("surv_casualties".to_string(), "可存活但有伤亡".to_string());
193 zh_cn.insert("surv_high".to_string(), "高".to_string());
194
195 zh_cn.insert(
197 "density_extreme".to_string(),
198 "极端——需要紧急干预".to_string(),
199 );
200 zh_cn.insert("density_elevated".to_string(), "升高——建议隔离".to_string());
201 zh_cn.insert("density_low".to_string(), "低——病人状况稳定".to_string());
202
203 zh_cn.insert("threat_apocalyptic".to_string(), "☢ 末日级".to_string());
205 zh_cn.insert("threat_critical".to_string(), "💀 危险级".to_string());
206 zh_cn.insert("threat_high".to_string(), "⚠ 高危".to_string());
207 zh_cn.insert("threat_elevated".to_string(), "⚠ 升高".to_string());
208 zh_cn.insert("threat_moderate".to_string(), "🟢 中等".to_string());
209
210 zh_cn.insert("emotion_numb".to_string(), "对重复工作麻木".to_string());
212 zh_cn.insert("emotion_denial".to_string(), "否认".to_string());
213 zh_cn.insert("emotion_proud".to_string(), "为复杂度感到自豪".to_string());
214 zh_cn.insert(
215 "emotion_confident".to_string(),
216 "对自己的缩写充满信心".to_string(),
217 );
218 zh_cn.insert(
219 "emotion_overwhelmed".to_string(),
220 "不堪重负但保持乐观".to_string(),
221 );
222 zh_cn.insert("emotion_professional".to_string(), "职业性疏离".to_string());
223 zh_cn.insert(
224 "emotion_battle_scarred".to_string(),
225 "身经百战但仍在上线".to_string(),
226 );
227 zh_cn.insert(
228 "emotion_intellectual".to_string(),
229 "智识上满足,实践上迷失".to_string(),
230 );
231
232 zh_cn.insert(
234 "phil_copy_paste".to_string(),
235 "成功过一次,就会再成功一次".to_string(),
236 );
237 zh_cn.insert("phil_yolo".to_string(), "生产环境不会崩的".to_string());
238 zh_cn.insert("phil_trait".to_string(), "不嵌套就不够高级".to_string());
239 zh_cn.insert(
240 "phil_legacy".to_string(),
241 "注释是给看不懂代码的人准备的".to_string(),
242 );
243 zh_cn.insert("phil_hotfix".to_string(), "未来的我会处理的".to_string());
244 zh_cn.insert("phil_enterprise".to_string(), "能编译就能上线".to_string());
245 zh_cn.insert("phil_startup".to_string(), "快速行动,必然出错".to_string());
246 zh_cn.insert(
247 "phil_academic".to_string(),
248 "理论很美,实践其次".to_string(),
249 );
250
251 zh_cn.insert(
253 "trait_dup_1".to_string(),
254 "Ctrl+C、Ctrl+V是你IDE最常用的快捷键".to_string(),
255 );
256 zh_cn.insert("trait_dup_2".to_string(), "能复制为什么要抽象".to_string());
257 zh_cn.insert(
258 "trait_dup_3".to_string(),
259 "同一个bug出现在5个地方=5倍的调试乐趣".to_string(),
260 );
261 zh_cn.insert(
262 "trait_dup_4".to_string(),
263 "DRY代表'不要重...算了,来不及了'".to_string(),
264 );
265
266 let mut en_us = HashMap::new();
268 en_us.insert(
269 "title".to_string(),
270 "🗑️ Garbage Code Hunter 🗑️".to_string(),
271 );
272 en_us.insert(
273 "preparing".to_string(),
274 "Preparing to roast your code...".to_string(),
275 );
276 en_us.insert(
277 "report_title".to_string(),
278 "📊 Code Quality Report".to_string(),
279 );
280 en_us.insert(
281 "found_issues".to_string(),
282 "Found some areas for improvement:".to_string(),
283 );
284 en_us.insert("statistics".to_string(), "📈 Issue Statistics:".to_string());
285 en_us.insert(
286 "nuclear_issues".to_string(),
287 "🔥 Nuclear Issues (fix immediately)".to_string(),
288 );
289 en_us.insert(
290 "spicy_issues".to_string(),
291 "🌶️ Spicy Issues (should fix)".to_string(),
292 );
293 en_us.insert(
294 "mild_issues".to_string(),
295 "😐 Mild Issues (can ignore)".to_string(),
296 );
297 en_us.insert("total".to_string(), "📝 Total".to_string());
298 en_us.insert("summary".to_string(), "📋 Summary".to_string());
299 en_us.insert("suggestions".to_string(), "💡 Suggestions".to_string());
300 en_us.insert(
301 "clean_code".to_string(),
302 "🎉 Wow! Your code doesn't have obvious garbage!".to_string(),
303 );
304 en_us.insert(
305 "clean_code_warning".to_string(),
306 "But don't celebrate too early, maybe there are logic issues I haven't detected 😏"
307 .to_string(),
308 );
309 en_us.insert(
310 "keep_improving".to_string(),
311 "Keep working hard to make your code better! 🚀".to_string(),
312 );
313 en_us.insert(
314 "top_files".to_string(),
315 "🏆 Files with Most Issues".to_string(),
316 );
317 en_us.insert(
318 "detailed_analysis".to_string(),
319 "🔍 Detailed Analysis".to_string(),
320 );
321
322 messages.insert("zh-CN".to_string(), zh_cn);
323 messages.insert("en-US".to_string(), en_us);
324
325 Self {
326 lang: normalized_lang.to_string(),
327 messages,
328 }
329 }
330
331 pub fn get(&self, key: &str) -> String {
332 self.messages
333 .get(&self.lang)
334 .and_then(|lang_map| lang_map.get(key))
335 .cloned()
336 .unwrap_or_else(|| {
337 self.messages
339 .get("en-US")
340 .and_then(|lang_map| lang_map.get(key))
341 .cloned()
342 .unwrap_or_else(|| format!("Missing translation: {key}"))
343 })
344 }
345
346 pub fn get_roast_messages(&self, rule_name: &str) -> Vec<String> {
347 match (self.lang.as_str(), rule_name) {
348 ("zh-CN", "terrible-naming") => vec![
349 "这个变量名比我的编程技能还要抽象,而我连 Hello World 都写不对".to_string(),
350 "这个名字告诉我你已经放弃治疗了,建议直接转行卖煎饼果子".to_string(),
351 "用这个做变量名?你是想让维护代码的人哭着辞职吗?".to_string(),
352 "恭喜你发明了最没有意义的变量名,可以申请专利了".to_string(),
353 "这变量名就像'无名氏'一样毫无特色,连我奶奶都能起个更好的名字".to_string(),
354 "看到这个变量名,我的智商都下降了,现在只能数到3了".to_string(),
355 "这变量名的创意程度约等于给孩子起名叫'小明'".to_string(),
356 "你这变量名让我想起了我的前任——毫无意义且令人困惑".to_string(),
357 "这个变量名的描述性约等于'东西'这个词的精确度".to_string(),
358 "恭喜!你成功地让变量名比注释还要难懂".to_string(),
359 ],
360 ("zh-CN", "single-letter-variable") => vec![
361 "单字母变量?你是在写数学公式还是在考验我的猜谜能力?".to_string(),
362 "这是变量名还是你键盘只剩一个键能用了?".to_string(),
363 "用单字母做变量名,建议你去买本《变量命名从入门到放弃》".to_string(),
364 "单字母变量:让代码比古埃及象形文字还难懂的神器".to_string(),
365 "这个变量名短得像我对你代码技能的期望一样".to_string(),
366 "单字母变量名?你这是在玩猜字谜游戏吗?".to_string(),
367 "恭喜你用一个字母成功地表达了无穷的困惑".to_string(),
368 "这变量名的信息量约等于一个句号".to_string(),
369 "你这是在节约字符还是在为难后来的维护者?".to_string(),
370 ],
371 ("zh-CN", "deep-nesting") => vec![
372 "这嵌套层数比俄罗斯套娃还要深,你是在挑战人类的理解极限吗?".to_string(),
373 "嵌套这么深,是想挖到地心还是想让读代码的人迷路?".to_string(),
374 "这代码嵌套得像洋葱一样,剥一层哭一次".to_string(),
375 "嵌套层数超标!建议重构,或者直接删了重写".to_string(),
376 "这嵌套深度已经可以申请吉尼斯世界纪录了,类别:最令人绝望的代码".to_string(),
377 "这代码比盗梦空间还要复杂,至少电影还有字幕".to_string(),
378 "你这嵌套层数让我想起了我的人际关系——复杂且令人困惑".to_string(),
379 "这嵌套深度足够埋葬我对编程的热情了".to_string(),
380 "恭喜你成功地把简单问题复杂化,这是一门艺术".to_string(),
381 "这代码的嵌套层数比我的焦虑层数还要多".to_string(),
382 ],
383 ("zh-CN", "long-function") => vec![
384 "这个函数比我的简历还要长,而我的简历已经长到HR看了想哭!".to_string(),
385 "函数长度建议拆分成几个小函数,或者直接删了重新做人".to_string(),
386 "这么长的函数?你是想让人一口气读完然后当场去世吗?".to_string(),
387 "这个函数比我对前任的怨念还要长".to_string(),
388 "这函数长得像《战争与和平》一样,但至少托尔斯泰会分章节".to_string(),
389 "这个函数需要一个GPS才能导航到结尾".to_string(),
390 "你这函数长度已经超越了我的注意力极限".to_string(),
391 "这函数比我妈的唠叨还要长,至少我妈会换个话题".to_string(),
392 "恭喜你写出了一个需要分期付款才能读完的函数".to_string(),
393 "这函数的长度让我怀疑你是按行数计工资的".to_string(),
394 ],
395 ("zh-CN", "unwrap-abuse") => vec![
396 "又一个 unwrap()!你是想让程序在生产环境里爆炸给老板看烟花吗?".to_string(),
397 "unwrap() 大师!错误处理是什么?能吃吗?还是说你觉得错误不会发生?".to_string(),
398 "看到这个 unwrap(),我仿佛听到了运维工程师的哭声".to_string(),
399 "unwrap() 使用者,恭喜你获得了'半夜被电话吵醒专业户'称号".to_string(),
400 "这个 unwrap() 就像俄罗斯轮盘赌,总有一发是实弹".to_string(),
401 "unwrap():让程序员体验心脏病发作的最佳工具".to_string(),
402 "你这 unwrap() 用得比我吃泡面还频繁,至少泡面不会让程序崩溃".to_string(),
403 "unwrap() 狂魔!你是不是觉得 panic 很好玩?".to_string(),
404 "这么多 unwrap(),你确定不是在写自毁程序?".to_string(),
405 "unwrap() 使用过度,建议改名为 'panic_generator.rs'".to_string(),
406 ],
407 ("zh-CN", "unnecessary-clone") => vec![
408 "clone() 狂魔!你是想把内存用完还是想让电脑罢工?".to_string(),
409 "这么多 clone(),你确定不是从 Java 转过来的?".to_string(),
410 "clone() 使用过度!Rust 的借用检查器已经哭晕在厕所".to_string(),
411 "又见 clone()!建议你重新学习 Rust,或者改学 Python".to_string(),
412 "这些 clone() 让我想起了复印机店的老板——疯狂复制一切".to_string(),
413 "clone() 滥用:让内存管理专家失业的最佳方式".to_string(),
414 "你这 clone() 用得比我换袜子还频繁".to_string(),
415 "恭喜你成功地把零拷贝变成了无限拷贝".to_string(),
416 "这么多 clone(),你是不是觉得内存是免费的?".to_string(),
417 "clone() 大师!你已经掌握了如何让程序跑得像蜗牛一样慢".to_string(),
418 ],
419 ("zh-CN", "complex-closure") => vec![
420 "闭包套闭包?你这是在写俄罗斯套娃还是在考验读者的智商?".to_string(),
421 "嵌套闭包比我的人际关系还复杂".to_string(),
422 "这闭包嵌套得像洋葱一样,剥一层哭一次".to_string(),
423 "闭包嵌套过深,建议拆分成独立函数".to_string(),
424 "这个闭包的参数比我的借口还多".to_string(),
425 "闭包参数过多,你确定不是在写函数?".to_string(),
426 ],
427 ("zh-CN", "lifetime-abuse") => vec![
428 "生命周期标注比我的生命还复杂".to_string(),
429 "这么多生命周期,你是在写哲学论文吗?".to_string(),
430 "生命周期滥用,建议重新设计数据结构".to_string(),
431 "生命周期多到让人怀疑人生".to_string(),
432 ],
433 ("zh-CN", "trait-complexity") => vec![
434 "这个 trait 的方法比我的借口还多".to_string(),
435 "trait 方法过多,违反了单一职责原则".to_string(),
436 "这个 trait 比瑞士军刀还要全能".to_string(),
437 "trait 臃肿,建议拆分成多个小 trait".to_string(),
438 "泛型参数比我的密码还复杂".to_string(),
439 "这么多泛型,你是在写数学公式吗?".to_string(),
440 ],
441 ("zh-CN", "generic-abuse") => vec![
442 "泛型参数比我的购物清单还长".to_string(),
443 "这么多泛型,编译器都要哭了".to_string(),
444 "泛型滥用,建议重新设计架构".to_string(),
445 "泛型多到让人怀疑这还是 Rust 吗".to_string(),
446 "泛型参数的命名创意约等于零".to_string(),
447 "泛型名字比我的耐心还短".to_string(),
448 ],
449 ("zh-CN", "channel-abuse") => vec![
450 "Channel 用得比我发微信还频繁,你确定不是在写聊天软件?".to_string(),
451 "这么多 Channel,你是想开通讯公司吗?".to_string(),
452 "Channel 滥用!你的程序比电话交换机还复杂".to_string(),
453 "Channel 数量超标,建议重新设计架构".to_string(),
454 "这么多 Channel,我怀疑你在写分布式系统".to_string(),
455 ],
456 ("zh-CN", "async-abuse") => vec![
457 "Async 函数比我的异步人生还要复杂".to_string(),
458 "这么多 async,你确定不是在写 JavaScript?".to_string(),
459 "Async 滥用!建议学习一下同步编程的美好".to_string(),
460 "异步函数过多,小心把自己绕晕了".to_string(),
461 "Await 用得比我等外卖还频繁".to_string(),
462 "这么多 await,你的程序是在等什么?世界末日吗?".to_string(),
463 ],
464 ("zh-CN", "dyn-trait-abuse") => vec![
465 "Dyn trait 用得比我换工作还频繁".to_string(),
466 "这么多动态分发,性能都跑到哪里去了?".to_string(),
467 "Dyn trait 滥用,你确定不是在写 Python?".to_string(),
468 "动态 trait 过多,编译器优化都哭了".to_string(),
469 "这么多 dyn,你的程序比变色龙还善变".to_string(),
470 ],
471 ("zh-CN", "unsafe-abuse") => vec![
472 "Unsafe 代码!你这是在玩火还是在挑战 Rust 的底线?".to_string(),
473 "又见 unsafe!安全性是什么?能吃吗?".to_string(),
474 "Unsafe 使用者,恭喜你获得了'内存安全破坏者'称号".to_string(),
475 "这个 unsafe 让我想起了 C 语言的恐怖回忆".to_string(),
476 "Unsafe 代码:让 Rust 程序员夜不能寐的存在".to_string(),
477 ],
478 ("zh-CN", "ffi-abuse") => vec![
479 "FFI 滥用!你这是在和多少种语言谈恋爱?".to_string(),
480 "外部接口比我的社交关系还复杂!".to_string(),
481 "这么多 FFI,Rust 的安全性都要哭了".to_string(),
482 "C 语言接口过多,你确定这还是 Rust 项目?".to_string(),
483 "FFI 代码让我想起了指针地狱的恐怖".to_string(),
484 ],
485 ("zh-CN", "macro-abuse") => vec![
486 "宏定义比我的借口还多".to_string(),
487 "这么多宏,你确定不是在写 C 语言?".to_string(),
488 "宏滥用!编译时间都被你搞长了".to_string(),
489 "宏过多,调试的时候准备哭吧".to_string(),
490 "这么多宏,IDE 都要罢工了".to_string(),
491 ],
492 ("zh-CN", "module-complexity") => vec![
493 "模块嵌套比俄罗斯套娃还深".to_string(),
494 "这模块结构比我的家族关系还复杂".to_string(),
495 "模块嵌套过深,建议重新组织代码结构".to_string(),
496 "这么深的模块,找个函数比找宝藏还难".to_string(),
497 ],
498 ("zh-CN", "pattern-matching-abuse") => vec![
499 "模式匹配比我的感情生活还复杂".to_string(),
500 "这么多模式,你是在写解谜游戏吗?".to_string(),
501 "模式过多,建议简化逻辑".to_string(),
502 "复杂的模式让代码可读性直线下降".to_string(),
503 "Match 分支比我的人生选择还多".to_string(),
504 "这么多 match 分支,你确定不是在写状态机?".to_string(),
505 ],
506 ("zh-CN", "reference-abuse") => vec![
507 "引用比我的社交关系还复杂".to_string(),
508 "这么多引用,你确定不是在写指针迷宫?".to_string(),
509 "引用过多,小心借用检查器罢工".to_string(),
510 "引用数量超标,建议重新设计数据结构".to_string(),
511 ],
512 ("zh-CN", "box-abuse") => vec![
513 "Box 用得比快递还频繁".to_string(),
514 "这么多 Box,你是在开仓库吗?".to_string(),
515 "Box 过多,堆内存都要爆炸了".to_string(),
516 "Box 滥用,建议考虑栈分配".to_string(),
517 "这么多 Box,内存分配器都累了".to_string(),
518 ],
519 ("zh-CN", "slice-abuse") => vec![
520 "切片比我切菜还频繁".to_string(),
521 "这么多切片,你是在开水果店吗?".to_string(),
522 "切片过多,数组都被你切碎了".to_string(),
523 "Slice 滥用,建议使用 Vec".to_string(),
524 ],
525 ("zh-CN", "code-duplication") => vec![
526 "检测到重复代码!你是复制粘贴大师吗?".to_string(),
527 "这些重复代码比双胞胎还像".to_string(),
528 "DRY原则哭了,你的代码湿得像雨季".to_string(),
529 "重复代码这么多,建议改名为copy-paste.rs".to_string(),
530 ],
531 ("zh-CN", "cyclomatic-complexity") => vec![
532 "圈复杂度爆表!这代码比迷宫还复杂".to_string(),
533 "复杂度这么高,连AI都看不懂".to_string(),
534 "这函数的复杂度已经超越人类理解范围".to_string(),
535 "建议拆分函数,或者直接重写".to_string(),
536 ],
537 ("en-US", "terrible-naming") => vec![
539 "This variable name is more abstract than my programming skills, and I can't even write Hello World correctly".to_string(),
540 "This name tells me you've given up on life and should probably sell hotdogs instead".to_string(),
541 "Using this as a variable name? Are you trying to make code maintainers cry and quit their jobs?".to_string(),
542 "Congratulations on inventing the most meaningless variable name, you should patent this level of confusion".to_string(),
543 "This variable name is as generic as 'John Doe', even my grandmother could come up with something better".to_string(),
544 "Seeing this variable name, my IQ just dropped to single digits".to_string(),
545 "This variable name has the creativity level of naming a kid 'Child'".to_string(),
546 "Your variable name reminds me of my ex - meaningless and confusing".to_string(),
547 "This variable name's descriptiveness is equivalent to calling everything 'stuff'".to_string(),
548 "Congrats! You've successfully made variable names harder to understand than comments".to_string(),
549 ],
550 ("en-US", "single-letter-variable") => vec![
551 "Single letter variable? Are you writing math formulas or testing my psychic abilities?".to_string(),
552 "Is this a variable name or did your keyboard only have one working key?".to_string(),
553 "Using single letters for variables, I suggest buying 'Variable Naming for Dummies'".to_string(),
554 "Single letter variables: making code harder to read than ancient hieroglyphics".to_string(),
555 "This variable name is as short as my expectations for your coding skills".to_string(),
556 "Single letter variable name? Are we playing charades now?".to_string(),
557 "Congrats on expressing infinite confusion with just one letter".to_string(),
558 "This variable name has the information content of a period".to_string(),
559 "Are you saving characters or just torturing future maintainers?".to_string(),
560 ],
561 ("en-US", "deep-nesting") => vec![
562 "This nesting is deeper than Russian dolls, are you challenging the limits of human comprehension?".to_string(),
563 "Nesting this deep, are you trying to dig to Earth's core or just make code readers get lost?".to_string(),
564 "This code is nested like an onion, peel one layer, cry once".to_string(),
565 "Nesting level exceeded! Suggest refactoring, or just delete and start over".to_string(),
566 "This nesting depth could apply for a Guinness World Record in 'Most Despair-Inducing Code'".to_string(),
567 "This code is more complex than Inception, at least the movie had subtitles".to_string(),
568 "Your nesting levels remind me of my relationships - complex and confusing".to_string(),
569 "This nesting depth is enough to bury my passion for programming".to_string(),
570 "Congrats on successfully complicating simple problems, it's an art form".to_string(),
571 "This code has more nesting levels than my anxiety layers".to_string(),
572 ],
573 ("en-US", "long-function") => vec![
574 "This function is longer than my resume, and my resume already makes HR cry!".to_string(),
575 "Function length suggests splitting into smaller functions, or just delete and start a new career".to_string(),
576 "Such a long function? Are you trying to make people read it in one breath and die on the spot?".to_string(),
577 "This function is longer than my grudges against my ex".to_string(),
578 "This function is as long as 'War and Peace', but at least Tolstoy used chapters".to_string(),
579 "This function needs a GPS to navigate to the end".to_string(),
580 "Your function length has exceeded my attention span limits".to_string(),
581 "This function is longer than my mom's nagging, at least she changes topics".to_string(),
582 "Congrats on writing a function that requires installment payments to read completely".to_string(),
583 "This function's length makes me suspect you're paid by lines of code".to_string(),
584 ],
585 ("en-US", "unwrap-abuse") => vec![
586 "Another unwrap()! Are you trying to make the program explode in production like fireworks for your boss?".to_string(),
587 "unwrap() master! What is error handling? Can you eat it? Or do you think errors just don't happen?".to_string(),
588 "Seeing this unwrap(), I can almost hear the DevOps engineers crying".to_string(),
589 "unwrap() user, congratulations on earning the 'Midnight Phone Call Specialist' title".to_string(),
590 "This unwrap() is like Russian roulette, eventually you'll hit the real bullet".to_string(),
591 "unwrap(): the best tool for experiencing heart attacks as a programmer".to_string(),
592 "You use unwrap() more than I eat instant noodles, at least noodles don't crash programs".to_string(),
593 "unwrap() maniac! Do you think panic is fun?".to_string(),
594 "So many unwrap()s, are you sure you're not writing a self-destruct program?".to_string(),
595 "unwrap() overuse detected, suggest renaming to 'panic_generator.rs'".to_string(),
596 ],
597 ("en-US", "unnecessary-clone") => vec![
598 "clone() maniac! Are you trying to exhaust all memory or make the computer go on strike?".to_string(),
599 "So many clone()s, are you sure you didn't just migrate from Java?".to_string(),
600 "clone() overuse! Rust's borrow checker has fainted in the bathroom".to_string(),
601 "Another clone()! Suggest relearning Rust, or maybe switch to Python".to_string(),
602 "These clone()s remind me of a copy shop owner - frantically copying everything".to_string(),
603 "clone() abuse: the best way to make memory management experts unemployed".to_string(),
604 "You use clone() more frequently than I change socks".to_string(),
605 "Congrats on successfully turning zero-copy into infinite-copy".to_string(),
606 "So many clone()s, do you think memory is free?".to_string(),
607 "clone() master! You've mastered how to make programs run as slow as snails".to_string(),
608 ],
609 ("en-US", "complex-closure") => vec![
610 "Nested closures? Are you writing Russian dolls or testing readers' IQ?".to_string(),
611 "Nested closures are more complex than my relationships".to_string(),
612 "This closure nesting is like an onion, peel one layer, cry once".to_string(),
613 "Closure nesting too deep, suggest splitting into separate functions".to_string(),
614 "This closure has more parameters than my excuses".to_string(),
615 "Too many closure parameters, are you sure you're not writing a function?".to_string(),
616 ],
617 ("en-US", "lifetime-abuse") => vec![
618 "Lifetime annotations are more complex than my actual life".to_string(),
619 "So many lifetimes, are you writing a philosophy paper?".to_string(),
620 "Lifetime abuse, suggest redesigning data structures".to_string(),
621 "So many lifetimes it makes me question existence".to_string(),
622 ],
623 ("en-US", "trait-complexity") => vec![
624 "This trait has more methods than my excuses".to_string(),
625 "Too many trait methods, violates single responsibility principle".to_string(),
626 "This trait is more versatile than a Swiss Army knife".to_string(),
627 "Bloated trait, suggest splitting into multiple smaller traits".to_string(),
628 "Generic parameters more complex than my passwords".to_string(),
629 "So many generics, are you writing mathematical formulas?".to_string(),
630 ],
631 ("en-US", "generic-abuse") => vec![
632 "Generic parameters longer than my shopping list".to_string(),
633 "So many generics, even the compiler is crying".to_string(),
634 "Generic abuse, suggest redesigning architecture".to_string(),
635 "So many generics, makes me wonder if this is still Rust".to_string(),
636 "Generic parameter naming creativity equals zero".to_string(),
637 "Generic name shorter than my patience".to_string(),
638 ],
639 ("en-US", "channel-abuse") => vec![
640 "Using channels more frequently than I text, are you writing a chat app?".to_string(),
641 "So many channels, are you starting a telecom company?".to_string(),
642 "Channel abuse! Your program is more complex than a phone exchange".to_string(),
643 "Channel count exceeded, suggest redesigning architecture".to_string(),
644 "So many channels, I suspect you're writing a distributed system".to_string(),
645 ],
646 ("en-US", "async-abuse") => vec![
647 "Async functions more complex than my asynchronous life".to_string(),
648 "So many async, are you sure you're not writing JavaScript?".to_string(),
649 "Async abuse! Suggest learning the beauty of synchronous programming".to_string(),
650 "Too many async functions, careful not to confuse yourself".to_string(),
651 "Using await more frequently than I wait for food delivery".to_string(),
652 "So many awaits, what is your program waiting for? The apocalypse?".to_string(),
653 ],
654 ("en-US", "dyn-trait-abuse") => vec![
655 "Using dyn traits more frequently than I change jobs".to_string(),
656 "So much dynamic dispatch, where did the performance go?".to_string(),
657 "Dyn trait abuse, are you sure you're not writing Python?".to_string(),
658 "Too many dynamic traits, even compiler optimizations are crying".to_string(),
659 "So many dyns, your program is more changeable than a chameleon".to_string(),
660 ],
661 ("en-US", "unsafe-abuse") => vec![
662 "Unsafe code! Are you playing with fire or challenging Rust's bottom line?".to_string(),
663 "Another unsafe! What is safety? Can you eat it?".to_string(),
664 "Unsafe user, congratulations on earning the 'Memory Safety Destroyer' title".to_string(),
665 "This unsafe reminds me of the horrifying memories of C language".to_string(),
666 "Unsafe code: the existence that keeps Rust programmers awake at night".to_string(),
667 ],
668 ("en-US", "ffi-abuse") => vec![
669 "FFI abuse! How many languages are you dating?".to_string(),
670 "External interfaces are more complex than my social relationships!".to_string(),
671 "So much FFI, Rust's safety is crying".to_string(),
672 "Too many C interfaces, are you sure this is still a Rust project?".to_string(),
673 "FFI code reminds me of the horror of pointer hell".to_string(),
674 ],
675 ("en-US", "macro-abuse") => vec![
676 "More macro definitions than my excuses".to_string(),
677 "So many macros, are you sure you're not writing C?".to_string(),
678 "Macro abuse! You've made compile time longer".to_string(),
679 "Too many macros, prepare to cry when debugging".to_string(),
680 "So many macros, even the IDE wants to quit".to_string(),
681 ],
682 ("en-US", "module-complexity") => vec![
683 "Module nesting deeper than Russian dolls".to_string(),
684 "This module structure is more complex than my family relationships".to_string(),
685 "Module nesting too deep, suggest reorganizing code structure".to_string(),
686 "Such deep modules, finding a function is harder than finding treasure".to_string(),
687 ],
688 ("en-US", "pattern-matching-abuse") => vec![
689 "Pattern matching more complex than my love life".to_string(),
690 "So many patterns, are you writing a puzzle game?".to_string(),
691 "Too many patterns, suggest simplifying logic".to_string(),
692 "Complex patterns make code readability plummet".to_string(),
693 "More match branches than my life choices".to_string(),
694 "So many match branches, are you sure you're not writing a state machine?".to_string(),
695 ],
696 ("en-US", "reference-abuse") => vec![
697 "References more complex than my social relationships".to_string(),
698 "So many references, are you sure you're not writing a pointer maze?".to_string(),
699 "Too many references, careful the borrow checker might strike".to_string(),
700 "Reference count exceeded, suggest redesigning data structures".to_string(),
701 ],
702 ("en-US", "box-abuse") => vec![
703 "Using Box more frequently than courier services".to_string(),
704 "So many Boxes, are you opening a warehouse?".to_string(),
705 "Too many Boxes, heap memory is about to explode".to_string(),
706 "Box abuse, suggest considering stack allocation".to_string(),
707 "So many Boxes, even the memory allocator is tired".to_string(),
708 ],
709 ("en-US", "slice-abuse") => vec![
710 "Slicing more frequently than I chop vegetables".to_string(),
711 "So many slices, are you opening a fruit shop?".to_string(),
712 "Too many slices, you've chopped the arrays to pieces".to_string(),
713 "Slice abuse, suggest using Vec instead".to_string(),
714 ],
715 ("en-US", "code-duplication") => vec![
716 "Copy-paste ninja detected! 🥷 Your code has more duplicates than a hall of mirrors".to_string(),
717 "DRY principle is crying in the corner while your code is drowning in repetition".to_string(),
718 "This much duplication suggests you should rename your file to 'ctrl-c-ctrl-v.rs'".to_string(),
719 "Duplicate code alert! Even my copy machine is jealous of your efficiency".to_string(),
720 "Your code has more clones than a sci-fi movie, time for some refactoring!".to_string(),
721 ],
722 _ => vec!["Unknown issue detected".to_string()],
723 }
724 }
725}