garbage_code_hunter/
i18n.rs

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 mut messages = HashMap::new();
11
12        // chinese messages
13        let mut zh_cn = HashMap::new();
14        zh_cn.insert("title".to_string(), "🗑️  垃圾代码猎人 🗑️".to_string());
15        zh_cn.insert(
16            "preparing".to_string(),
17            "正在准备吐槽你的代码...".to_string(),
18        );
19        zh_cn.insert(
20            "report_title".to_string(),
21            "📊 垃圾代码检测报告".to_string(),
22        );
23        zh_cn.insert(
24            "found_issues".to_string(),
25            "发现了一些需要改进的地方:".to_string(),
26        );
27        zh_cn.insert("statistics".to_string(), "📈 问题统计:".to_string());
28        zh_cn.insert(
29            "nuclear_issues".to_string(),
30            "🔥 核弹级问题 (需要立即修复)".to_string(),
31        );
32        zh_cn.insert(
33            "spicy_issues".to_string(),
34            "🌶️  辣眼睛问题 (建议修复)".to_string(),
35        );
36        zh_cn.insert(
37            "mild_issues".to_string(),
38            "😐 轻微问题 (可以忽略)".to_string(),
39        );
40        zh_cn.insert("total".to_string(), "📝 总计".to_string());
41        zh_cn.insert("summary".to_string(), "📋 总结".to_string());
42        zh_cn.insert("suggestions".to_string(), "💡 改进建议".to_string());
43        zh_cn.insert(
44            "clean_code".to_string(),
45            "🎉 哇!你的代码居然没有明显的垃圾!".to_string(),
46        );
47        zh_cn.insert(
48            "clean_code_warning".to_string(),
49            "但是别高兴太早,也许你的逻辑有问题我还没检测到 😏".to_string(),
50        );
51        zh_cn.insert(
52            "keep_improving".to_string(),
53            "继续努力,让代码变得更好!🚀".to_string(),
54        );
55        zh_cn.insert("top_files".to_string(), "🏆 问题最多的文件".to_string());
56        zh_cn.insert("detailed_analysis".to_string(), "🔍 详细分析".to_string());
57
58        // english messages
59        let mut en_us = HashMap::new();
60        en_us.insert(
61            "title".to_string(),
62            "🗑️  Garbage Code Hunter 🗑️".to_string(),
63        );
64        en_us.insert(
65            "preparing".to_string(),
66            "Preparing to roast your code...".to_string(),
67        );
68        en_us.insert(
69            "report_title".to_string(),
70            "📊 Code Quality Report".to_string(),
71        );
72        en_us.insert(
73            "found_issues".to_string(),
74            "Found some areas for improvement:".to_string(),
75        );
76        en_us.insert("statistics".to_string(), "📈 Issue Statistics:".to_string());
77        en_us.insert(
78            "nuclear_issues".to_string(),
79            "🔥 Nuclear Issues (fix immediately)".to_string(),
80        );
81        en_us.insert(
82            "spicy_issues".to_string(),
83            "🌶️  Spicy Issues (should fix)".to_string(),
84        );
85        en_us.insert(
86            "mild_issues".to_string(),
87            "😐 Mild Issues (can ignore)".to_string(),
88        );
89        en_us.insert("total".to_string(), "📝 Total".to_string());
90        en_us.insert("summary".to_string(), "📋 Summary".to_string());
91        en_us.insert("suggestions".to_string(), "💡 Suggestions".to_string());
92        en_us.insert(
93            "clean_code".to_string(),
94            "🎉 Wow! Your code doesn't have obvious garbage!".to_string(),
95        );
96        en_us.insert(
97            "clean_code_warning".to_string(),
98            "But don't celebrate too early, maybe there are logic issues I haven't detected 😏"
99                .to_string(),
100        );
101        en_us.insert(
102            "keep_improving".to_string(),
103            "Keep working hard to make your code better! 🚀".to_string(),
104        );
105        en_us.insert(
106            "top_files".to_string(),
107            "🏆 Files with Most Issues".to_string(),
108        );
109        en_us.insert(
110            "detailed_analysis".to_string(),
111            "🔍 Detailed Analysis".to_string(),
112        );
113
114        messages.insert("zh-CN".to_string(), zh_cn);
115        messages.insert("en-US".to_string(), en_us);
116
117        Self {
118            lang: lang.to_string(),
119            messages,
120        }
121    }
122
123    pub fn get(&self, key: &str) -> String {
124        self.messages
125            .get(&self.lang)
126            .and_then(|lang_map| lang_map.get(key))
127            .cloned()
128            .unwrap_or_else(|| {
129                // 回退到英文
130                self.messages
131                    .get("en-US")
132                    .and_then(|lang_map| lang_map.get(key))
133                    .cloned()
134                    .unwrap_or_else(|| format!("Missing translation: {}", key))
135            })
136    }
137
138    pub fn get_roast_messages(&self, rule_name: &str) -> Vec<String> {
139        match (self.lang.as_str(), rule_name) {
140            ("zh-CN", "terrible-naming") => vec![
141                "这个变量名比我的编程技能还要抽象,而我连 Hello World 都写不对".to_string(),
142                "这个名字告诉我你已经放弃治疗了,建议直接转行卖煎饼果子".to_string(),
143                "用这个做变量名?你是想让维护代码的人哭着辞职吗?".to_string(),
144                "恭喜你发明了最没有意义的变量名,可以申请专利了".to_string(),
145                "这变量名就像'无名氏'一样毫无特色,连我奶奶都能起个更好的名字".to_string(),
146                "看到这个变量名,我的智商都下降了,现在只能数到3了".to_string(),
147                "这变量名的创意程度约等于给孩子起名叫'小明'".to_string(),
148                "你这变量名让我想起了我的前任——毫无意义且令人困惑".to_string(),
149                "这个变量名的描述性约等于'东西'这个词的精确度".to_string(),
150                "恭喜!你成功地让变量名比注释还要难懂".to_string(),
151            ],
152            ("zh-CN", "single-letter-variable") => vec![
153                "单字母变量?你是在写数学公式还是在考验我的猜谜能力?".to_string(),
154                "这是变量名还是你键盘只剩一个键能用了?".to_string(),
155                "用单字母做变量名,建议你去买本《变量命名从入门到放弃》".to_string(),
156                "单字母变量:让代码比古埃及象形文字还难懂的神器".to_string(),
157                "这个变量名短得像我对你代码技能的期望一样".to_string(),
158                "单字母变量名?你这是在玩猜字谜游戏吗?".to_string(),
159                "恭喜你用一个字母成功地表达了无穷的困惑".to_string(),
160                "这变量名的信息量约等于一个句号".to_string(),
161                "你这是在节约字符还是在为难后来的维护者?".to_string(),
162            ],
163            ("zh-CN", "deep-nesting") => vec![
164                "这嵌套层数比俄罗斯套娃还要深,你是在挑战人类的理解极限吗?".to_string(),
165                "嵌套这么深,是想挖到地心还是想让读代码的人迷路?".to_string(),
166                "这代码嵌套得像洋葱一样,剥一层哭一次".to_string(),
167                "嵌套层数超标!建议重构,或者直接删了重写".to_string(),
168                "这嵌套深度已经可以申请吉尼斯世界纪录了,类别:最令人绝望的代码".to_string(),
169                "这代码比盗梦空间还要复杂,至少电影还有字幕".to_string(),
170                "你这嵌套层数让我想起了我的人际关系——复杂且令人困惑".to_string(),
171                "这嵌套深度足够埋葬我对编程的热情了".to_string(),
172                "恭喜你成功地把简单问题复杂化,这是一门艺术".to_string(),
173                "这代码的嵌套层数比我的焦虑层数还要多".to_string(),
174            ],
175            ("zh-CN", "long-function") => vec![
176                "这个函数比我的简历还要长,而我的简历已经长到HR看了想哭!".to_string(),
177                "函数长度建议拆分成几个小函数,或者直接删了重新做人".to_string(),
178                "这么长的函数?你是想让人一口气读完然后当场去世吗?".to_string(),
179                "这个函数比我对前任的怨念还要长".to_string(),
180                "这函数长得像《战争与和平》一样,但至少托尔斯泰会分章节".to_string(),
181                "这个函数需要一个GPS才能导航到结尾".to_string(),
182                "你这函数长度已经超越了我的注意力极限".to_string(),
183                "这函数比我妈的唠叨还要长,至少我妈会换个话题".to_string(),
184                "恭喜你写出了一个需要分期付款才能读完的函数".to_string(),
185                "这函数的长度让我怀疑你是按行数计工资的".to_string(),
186            ],
187            ("zh-CN", "unwrap-abuse") => vec![
188                "又一个 unwrap()!你是想让程序在生产环境里爆炸给老板看烟花吗?".to_string(),
189                "unwrap() 大师!错误处理是什么?能吃吗?还是说你觉得错误不会发生?".to_string(),
190                "看到这个 unwrap(),我仿佛听到了运维工程师的哭声".to_string(),
191                "unwrap() 使用者,恭喜你获得了'半夜被电话吵醒专业户'称号".to_string(),
192                "这个 unwrap() 就像俄罗斯轮盘赌,总有一发是实弹".to_string(),
193                "unwrap():让程序员体验心脏病发作的最佳工具".to_string(),
194                "你这 unwrap() 用得比我吃泡面还频繁,至少泡面不会让程序崩溃".to_string(),
195                "unwrap() 狂魔!你是不是觉得 panic 很好玩?".to_string(),
196                "这么多 unwrap(),你确定不是在写自毁程序?".to_string(),
197                "unwrap() 使用过度,建议改名为 'panic_generator.rs'".to_string(),
198            ],
199            ("zh-CN", "unnecessary-clone") => vec![
200                "clone() 狂魔!你是想把内存用完还是想让电脑罢工?".to_string(),
201                "这么多 clone(),你确定不是从 Java 转过来的?".to_string(),
202                "clone() 使用过度!Rust 的借用检查器已经哭晕在厕所".to_string(),
203                "又见 clone()!建议你重新学习 Rust,或者改学 Python".to_string(),
204                "这些 clone() 让我想起了复印机店的老板——疯狂复制一切".to_string(),
205                "clone() 滥用:让内存管理专家失业的最佳方式".to_string(),
206                "你这 clone() 用得比我换袜子还频繁".to_string(),
207                "恭喜你成功地把零拷贝变成了无限拷贝".to_string(),
208                "这么多 clone(),你是不是觉得内存是免费的?".to_string(),
209                "clone() 大师!你已经掌握了如何让程序跑得像蜗牛一样慢".to_string(),
210            ],
211            ("zh-CN", "complex-closure") => vec![
212                "闭包套闭包?你这是在写俄罗斯套娃还是在考验读者的智商?".to_string(),
213                "嵌套闭包比我的人际关系还复杂".to_string(),
214                "这闭包嵌套得像洋葱一样,剥一层哭一次".to_string(),
215                "闭包嵌套过深,建议拆分成独立函数".to_string(),
216                "这个闭包的参数比我的借口还多".to_string(),
217                "闭包参数过多,你确定不是在写函数?".to_string(),
218            ],
219            ("zh-CN", "lifetime-abuse") => vec![
220                "生命周期标注比我的生命还复杂".to_string(),
221                "这么多生命周期,你是在写哲学论文吗?".to_string(),
222                "生命周期滥用,建议重新设计数据结构".to_string(),
223                "生命周期多到让人怀疑人生".to_string(),
224            ],
225            ("zh-CN", "trait-complexity") => vec![
226                "这个 trait 的方法比我的借口还多".to_string(),
227                "trait 方法过多,违反了单一职责原则".to_string(),
228                "这个 trait 比瑞士军刀还要全能".to_string(),
229                "trait 臃肿,建议拆分成多个小 trait".to_string(),
230                "泛型参数比我的密码还复杂".to_string(),
231                "这么多泛型,你是在写数学公式吗?".to_string(),
232            ],
233            ("zh-CN", "generic-abuse") => vec![
234                "泛型参数比我的购物清单还长".to_string(),
235                "这么多泛型,编译器都要哭了".to_string(),
236                "泛型滥用,建议重新设计架构".to_string(),
237                "泛型多到让人怀疑这还是 Rust 吗".to_string(),
238                "泛型参数的命名创意约等于零".to_string(),
239                "泛型名字比我的耐心还短".to_string(),
240            ],
241            ("zh-CN", "channel-abuse") => vec![
242                "Channel 用得比我发微信还频繁,你确定不是在写聊天软件?".to_string(),
243                "这么多 Channel,你是想开通讯公司吗?".to_string(),
244                "Channel 滥用!你的程序比电话交换机还复杂".to_string(),
245                "Channel 数量超标,建议重新设计架构".to_string(),
246                "这么多 Channel,我怀疑你在写分布式系统".to_string(),
247            ],
248            ("zh-CN", "async-abuse") => vec![
249                "Async 函数比我的异步人生还要复杂".to_string(),
250                "这么多 async,你确定不是在写 JavaScript?".to_string(),
251                "Async 滥用!建议学习一下同步编程的美好".to_string(),
252                "异步函数过多,小心把自己绕晕了".to_string(),
253                "Await 用得比我等外卖还频繁".to_string(),
254                "这么多 await,你的程序是在等什么?世界末日吗?".to_string(),
255            ],
256            ("zh-CN", "dyn-trait-abuse") => vec![
257                "Dyn trait 用得比我换工作还频繁".to_string(),
258                "这么多动态分发,性能都跑到哪里去了?".to_string(),
259                "Dyn trait 滥用,你确定不是在写 Python?".to_string(),
260                "动态 trait 过多,编译器优化都哭了".to_string(),
261                "这么多 dyn,你的程序比变色龙还善变".to_string(),
262            ],
263            ("zh-CN", "unsafe-abuse") => vec![
264                "Unsafe 代码!你这是在玩火还是在挑战 Rust 的底线?".to_string(),
265                "又见 unsafe!安全性是什么?能吃吗?".to_string(),
266                "Unsafe 使用者,恭喜你获得了'内存安全破坏者'称号".to_string(),
267                "这个 unsafe 让我想起了 C 语言的恐怖回忆".to_string(),
268                "Unsafe 代码:让 Rust 程序员夜不能寐的存在".to_string(),
269            ],
270            ("zh-CN", "ffi-abuse") => vec![
271                "FFI 滥用!你这是在和多少种语言谈恋爱?".to_string(),
272                "外部接口比我的社交关系还复杂!".to_string(),
273                "这么多 FFI,Rust 的安全性都要哭了".to_string(),
274                "C 语言接口过多,你确定这还是 Rust 项目?".to_string(),
275                "FFI 代码让我想起了指针地狱的恐怖".to_string(),
276            ],
277            ("zh-CN", "macro-abuse") => vec![
278                "宏定义比我的借口还多".to_string(),
279                "这么多宏,你确定不是在写 C 语言?".to_string(),
280                "宏滥用!编译时间都被你搞长了".to_string(),
281                "宏过多,调试的时候准备哭吧".to_string(),
282                "这么多宏,IDE 都要罢工了".to_string(),
283            ],
284            ("zh-CN", "module-complexity") => vec![
285                "模块嵌套比俄罗斯套娃还深".to_string(),
286                "这模块结构比我的家族关系还复杂".to_string(),
287                "模块嵌套过深,建议重新组织代码结构".to_string(),
288                "这么深的模块,找个函数比找宝藏还难".to_string(),
289            ],
290            ("zh-CN", "pattern-matching-abuse") => vec![
291                "模式匹配比我的感情生活还复杂".to_string(),
292                "这么多模式,你是在写解谜游戏吗?".to_string(),
293                "模式过多,建议简化逻辑".to_string(),
294                "复杂的模式让代码可读性直线下降".to_string(),
295                "Match 分支比我的人生选择还多".to_string(),
296                "这么多 match 分支,你确定不是在写状态机?".to_string(),
297            ],
298            ("zh-CN", "reference-abuse") => vec![
299                "引用比我的社交关系还复杂".to_string(),
300                "这么多引用,你确定不是在写指针迷宫?".to_string(),
301                "引用过多,小心借用检查器罢工".to_string(),
302                "引用数量超标,建议重新设计数据结构".to_string(),
303            ],
304            ("zh-CN", "box-abuse") => vec![
305                "Box 用得比快递还频繁".to_string(),
306                "这么多 Box,你是在开仓库吗?".to_string(),
307                "Box 过多,堆内存都要爆炸了".to_string(),
308                "Box 滥用,建议考虑栈分配".to_string(),
309                "这么多 Box,内存分配器都累了".to_string(),
310            ],
311            ("zh-CN", "slice-abuse") => vec![
312                "切片比我切菜还频繁".to_string(),
313                "这么多切片,你是在开水果店吗?".to_string(),
314                "切片过多,数组都被你切碎了".to_string(),
315                "Slice 滥用,建议使用 Vec".to_string(),
316            ],
317            // 英文版本
318            ("en-US", "terrible-naming") => vec![
319                "This variable name is more abstract than my programming skills, and I can't even write Hello World correctly".to_string(),
320                "This name tells me you've given up on life and should probably sell hotdogs instead".to_string(),
321                "Using this as a variable name? Are you trying to make code maintainers cry and quit their jobs?".to_string(),
322                "Congratulations on inventing the most meaningless variable name, you should patent this level of confusion".to_string(),
323                "This variable name is as generic as 'John Doe', even my grandmother could come up with something better".to_string(),
324                "Seeing this variable name, my IQ just dropped to single digits".to_string(),
325                "This variable name has the creativity level of naming a kid 'Child'".to_string(),
326                "Your variable name reminds me of my ex - meaningless and confusing".to_string(),
327                "This variable name's descriptiveness is equivalent to calling everything 'stuff'".to_string(),
328                "Congrats! You've successfully made variable names harder to understand than comments".to_string(),
329            ],
330            ("en-US", "single-letter-variable") => vec![
331                "Single letter variable? Are you writing math formulas or testing my psychic abilities?".to_string(),
332                "Is this a variable name or did your keyboard only have one working key?".to_string(),
333                "Using single letters for variables, I suggest buying 'Variable Naming for Dummies'".to_string(),
334                "Single letter variables: making code harder to read than ancient hieroglyphics".to_string(),
335                "This variable name is as short as my expectations for your coding skills".to_string(),
336                "Single letter variable name? Are we playing charades now?".to_string(),
337                "Congrats on expressing infinite confusion with just one letter".to_string(),
338                "This variable name has the information content of a period".to_string(),
339                "Are you saving characters or just torturing future maintainers?".to_string(),
340            ],
341            ("en-US", "deep-nesting") => vec![
342                "This nesting is deeper than Russian dolls, are you challenging the limits of human comprehension?".to_string(),
343                "Nesting this deep, are you trying to dig to Earth's core or just make code readers get lost?".to_string(),
344                "This code is nested like an onion, peel one layer, cry once".to_string(),
345                "Nesting level exceeded! Suggest refactoring, or just delete and start over".to_string(),
346                "This nesting depth could apply for a Guinness World Record in 'Most Despair-Inducing Code'".to_string(),
347                "This code is more complex than Inception, at least the movie had subtitles".to_string(),
348                "Your nesting levels remind me of my relationships - complex and confusing".to_string(),
349                "This nesting depth is enough to bury my passion for programming".to_string(),
350                "Congrats on successfully complicating simple problems, it's an art form".to_string(),
351                "This code has more nesting levels than my anxiety layers".to_string(),
352            ],
353            ("en-US", "long-function") => vec![
354                "This function is longer than my resume, and my resume already makes HR cry!".to_string(),
355                "Function length suggests splitting into smaller functions, or just delete and start a new career".to_string(),
356                "Such a long function? Are you trying to make people read it in one breath and die on the spot?".to_string(),
357                "This function is longer than my grudges against my ex".to_string(),
358                "This function is as long as 'War and Peace', but at least Tolstoy used chapters".to_string(),
359                "This function needs a GPS to navigate to the end".to_string(),
360                "Your function length has exceeded my attention span limits".to_string(),
361                "This function is longer than my mom's nagging, at least she changes topics".to_string(),
362                "Congrats on writing a function that requires installment payments to read completely".to_string(),
363                "This function's length makes me suspect you're paid by lines of code".to_string(),
364            ],
365            ("en-US", "unwrap-abuse") => vec![
366                "Another unwrap()! Are you trying to make the program explode in production like fireworks for your boss?".to_string(),
367                "unwrap() master! What is error handling? Can you eat it? Or do you think errors just don't happen?".to_string(),
368                "Seeing this unwrap(), I can almost hear the DevOps engineers crying".to_string(),
369                "unwrap() user, congratulations on earning the 'Midnight Phone Call Specialist' title".to_string(),
370                "This unwrap() is like Russian roulette, eventually you'll hit the real bullet".to_string(),
371                "unwrap(): the best tool for experiencing heart attacks as a programmer".to_string(),
372                "You use unwrap() more than I eat instant noodles, at least noodles don't crash programs".to_string(),
373                "unwrap() maniac! Do you think panic is fun?".to_string(),
374                "So many unwrap()s, are you sure you're not writing a self-destruct program?".to_string(),
375                "unwrap() overuse detected, suggest renaming to 'panic_generator.rs'".to_string(),
376            ],
377            ("en-US", "unnecessary-clone") => vec![
378                "clone() maniac! Are you trying to exhaust all memory or make the computer go on strike?".to_string(),
379                "So many clone()s, are you sure you didn't just migrate from Java?".to_string(),
380                "clone() overuse! Rust's borrow checker has fainted in the bathroom".to_string(),
381                "Another clone()! Suggest relearning Rust, or maybe switch to Python".to_string(),
382                "These clone()s remind me of a copy shop owner - frantically copying everything".to_string(),
383                "clone() abuse: the best way to make memory management experts unemployed".to_string(),
384                "You use clone() more frequently than I change socks".to_string(),
385                "Congrats on successfully turning zero-copy into infinite-copy".to_string(),
386                "So many clone()s, do you think memory is free?".to_string(),
387                "clone() master! You've mastered how to make programs run as slow as snails".to_string(),
388            ],
389            ("en-US", "complex-closure") => vec![
390                "Nested closures? Are you writing Russian dolls or testing readers' IQ?".to_string(),
391                "Nested closures are more complex than my relationships".to_string(),
392                "This closure nesting is like an onion, peel one layer, cry once".to_string(),
393                "Closure nesting too deep, suggest splitting into separate functions".to_string(),
394                "This closure has more parameters than my excuses".to_string(),
395                "Too many closure parameters, are you sure you're not writing a function?".to_string(),
396            ],
397            ("en-US", "lifetime-abuse") => vec![
398                "Lifetime annotations are more complex than my actual life".to_string(),
399                "So many lifetimes, are you writing a philosophy paper?".to_string(),
400                "Lifetime abuse, suggest redesigning data structures".to_string(),
401                "So many lifetimes it makes me question existence".to_string(),
402            ],
403            ("en-US", "trait-complexity") => vec![
404                "This trait has more methods than my excuses".to_string(),
405                "Too many trait methods, violates single responsibility principle".to_string(),
406                "This trait is more versatile than a Swiss Army knife".to_string(),
407                "Bloated trait, suggest splitting into multiple smaller traits".to_string(),
408                "Generic parameters more complex than my passwords".to_string(),
409                "So many generics, are you writing mathematical formulas?".to_string(),
410            ],
411            ("en-US", "generic-abuse") => vec![
412                "Generic parameters longer than my shopping list".to_string(),
413                "So many generics, even the compiler is crying".to_string(),
414                "Generic abuse, suggest redesigning architecture".to_string(),
415                "So many generics, makes me wonder if this is still Rust".to_string(),
416                "Generic parameter naming creativity equals zero".to_string(),
417                "Generic name shorter than my patience".to_string(),
418            ],
419            ("en-US", "channel-abuse") => vec![
420                "Using channels more frequently than I text, are you writing a chat app?".to_string(),
421                "So many channels, are you starting a telecom company?".to_string(),
422                "Channel abuse! Your program is more complex than a phone exchange".to_string(),
423                "Channel count exceeded, suggest redesigning architecture".to_string(),
424                "So many channels, I suspect you're writing a distributed system".to_string(),
425            ],
426            ("en-US", "async-abuse") => vec![
427                "Async functions more complex than my asynchronous life".to_string(),
428                "So many async, are you sure you're not writing JavaScript?".to_string(),
429                "Async abuse! Suggest learning the beauty of synchronous programming".to_string(),
430                "Too many async functions, careful not to confuse yourself".to_string(),
431                "Using await more frequently than I wait for food delivery".to_string(),
432                "So many awaits, what is your program waiting for? The apocalypse?".to_string(),
433            ],
434            ("en-US", "dyn-trait-abuse") => vec![
435                "Using dyn traits more frequently than I change jobs".to_string(),
436                "So much dynamic dispatch, where did the performance go?".to_string(),
437                "Dyn trait abuse, are you sure you're not writing Python?".to_string(),
438                "Too many dynamic traits, even compiler optimizations are crying".to_string(),
439                "So many dyns, your program is more changeable than a chameleon".to_string(),
440            ],
441            ("en-US", "unsafe-abuse") => vec![
442                "Unsafe code! Are you playing with fire or challenging Rust's bottom line?".to_string(),
443                "Another unsafe! What is safety? Can you eat it?".to_string(),
444                "Unsafe user, congratulations on earning the 'Memory Safety Destroyer' title".to_string(),
445                "This unsafe reminds me of the horrifying memories of C language".to_string(),
446                "Unsafe code: the existence that keeps Rust programmers awake at night".to_string(),
447            ],
448            ("en-US", "ffi-abuse") => vec![
449                "FFI abuse! How many languages are you dating?".to_string(),
450                "External interfaces are more complex than my social relationships!".to_string(),
451                "So much FFI, Rust's safety is crying".to_string(),
452                "Too many C interfaces, are you sure this is still a Rust project?".to_string(),
453                "FFI code reminds me of the horror of pointer hell".to_string(),
454            ],
455            ("en-US", "macro-abuse") => vec![
456                "More macro definitions than my excuses".to_string(),
457                "So many macros, are you sure you're not writing C?".to_string(),
458                "Macro abuse! You've made compile time longer".to_string(),
459                "Too many macros, prepare to cry when debugging".to_string(),
460                "So many macros, even the IDE wants to quit".to_string(),
461            ],
462            ("en-US", "module-complexity") => vec![
463                "Module nesting deeper than Russian dolls".to_string(),
464                "This module structure is more complex than my family relationships".to_string(),
465                "Module nesting too deep, suggest reorganizing code structure".to_string(),
466                "Such deep modules, finding a function is harder than finding treasure".to_string(),
467            ],
468            ("en-US", "pattern-matching-abuse") => vec![
469                "Pattern matching more complex than my love life".to_string(),
470                "So many patterns, are you writing a puzzle game?".to_string(),
471                "Too many patterns, suggest simplifying logic".to_string(),
472                "Complex patterns make code readability plummet".to_string(),
473                "More match branches than my life choices".to_string(),
474                "So many match branches, are you sure you're not writing a state machine?".to_string(),
475            ],
476            ("en-US", "reference-abuse") => vec![
477                "References more complex than my social relationships".to_string(),
478                "So many references, are you sure you're not writing a pointer maze?".to_string(),
479                "Too many references, careful the borrow checker might strike".to_string(),
480                "Reference count exceeded, suggest redesigning data structures".to_string(),
481            ],
482            ("en-US", "box-abuse") => vec![
483                "Using Box more frequently than courier services".to_string(),
484                "So many Boxes, are you opening a warehouse?".to_string(),
485                "Too many Boxes, heap memory is about to explode".to_string(),
486                "Box abuse, suggest considering stack allocation".to_string(),
487                "So many Boxes, even the memory allocator is tired".to_string(),
488            ],
489            ("en-US", "slice-abuse") => vec![
490                "Slicing more frequently than I chop vegetables".to_string(),
491                "So many slices, are you opening a fruit shop?".to_string(),
492                "Too many slices, you've chopped the arrays to pieces".to_string(),
493                "Slice abuse, suggest using Vec instead".to_string(),
494            ],
495            _ => vec!["Unknown issue detected".to_string()],
496        }
497    }
498
499    pub fn get_suggestions(&self, rule_names: &[String]) -> Vec<String> {
500        let mut suggestions = Vec::new();
501
502        match self.lang.as_str() {
503            "zh-CN" => {
504                if rule_names.contains(&"terrible-naming".to_string()) {
505                    suggestions.push(
506                        "💡 使用有意义的变量名,让代码自解释(比如用 user_count 而不是 data)"
507                            .to_string(),
508                    );
509                    suggestions.push("🎯 变量名应该描述它存储的内容,而不是数据类型".to_string());
510                }
511                if rule_names.contains(&"deep-nesting".to_string()) {
512                    suggestions.push(
513                        "🔧 减少嵌套层数,考虑提取函数或使用早期返回(guard clauses)".to_string(),
514                    );
515                    suggestions.push("🏗️ 复杂的条件逻辑可以拆分成多个小函数".to_string());
516                }
517                if rule_names.contains(&"long-function".to_string()) {
518                    suggestions.push("✂️ 将长函数拆分成多个小函数,遵循单一职责原则".to_string());
519                    suggestions
520                        .push("📏 一个函数最好不超过 20-30 行,这样更容易理解和测试".to_string());
521                }
522                if rule_names.contains(&"unwrap-abuse".to_string()) {
523                    suggestions.push("🛡️ 使用 match、if let 或 ? 操作符替代 unwrap()".to_string());
524                    suggestions.push(
525                        "⚠️ unwrap() 只应该在你 100% 确定不会 panic 的情况下使用".to_string(),
526                    );
527                }
528                if rule_names.contains(&"unnecessary-clone".to_string()) {
529                    suggestions.push("🦀 学习 Rust 的借用系统,减少不必要的 clone()".to_string());
530                    suggestions
531                        .push("🔄 考虑使用引用 (&) 或者重新设计数据结构来避免克隆".to_string());
532                }
533                if suggestions.is_empty() {
534                    suggestions.push("🌟 继续保持良好的编码习惯,代码质量不错!".to_string());
535                }
536            }
537            "en-US" => {
538                if rule_names.contains(&"terrible-naming".to_string()) {
539                    suggestions.push("💡 Use meaningful variable names that make code self-documenting (e.g., user_count instead of data)".to_string());
540                    suggestions.push(
541                        "🎯 Variable names should describe what they store, not the data type"
542                            .to_string(),
543                    );
544                }
545                if rule_names.contains(&"deep-nesting".to_string()) {
546                    suggestions.push("🔧 Reduce nesting levels, consider extracting functions or using early returns (guard clauses)".to_string());
547                    suggestions.push(
548                        "🏗️ Complex conditional logic can be split into multiple small functions"
549                            .to_string(),
550                    );
551                }
552                if rule_names.contains(&"long-function".to_string()) {
553                    suggestions.push("✂️ Split long functions into smaller ones, follow the single responsibility principle".to_string());
554                    suggestions.push("📏 A function should ideally not exceed 20-30 lines for better understanding and testing".to_string());
555                }
556                if rule_names.contains(&"unwrap-abuse".to_string()) {
557                    suggestions.push(
558                        "🛡️ Use match, if let, or ? operator instead of unwrap()".to_string(),
559                    );
560                    suggestions.push(
561                        "⚠️ unwrap() should only be used when you're 100% sure it won't panic"
562                            .to_string(),
563                    );
564                }
565                if rule_names.contains(&"unnecessary-clone".to_string()) {
566                    suggestions.push(
567                        "🦀 Learn Rust's borrowing system to reduce unnecessary clone()"
568                            .to_string(),
569                    );
570                    suggestions.push("🔄 Consider using references (&) or redesigning data structures to avoid cloning".to_string());
571                }
572                if suggestions.is_empty() {
573                    suggestions.push(
574                        "🌟 Keep up the good coding habits, your code quality is good!".to_string(),
575                    );
576                }
577            }
578            _ => {
579                suggestions.push("Continue improving your code quality".to_string());
580            }
581        }
582
583        suggestions
584    }
585}