rust/chat_sanitizer/src/bad_words.rs
changeset 14505 ba29aa03db87
parent 14503 831ecafd74c6
--- a/rust/chat_sanitizer/src/bad_words.rs	Fri Dec 28 03:10:05 2018 +0300
+++ b/rust/chat_sanitizer/src/bad_words.rs	Fri Dec 28 22:47:17 2018 +0100
@@ -19,13 +19,17 @@
 }
 
 impl<T> MessageChecker<T> for BadWordsChecker<T> {
-    fn check(&self, player_id: T, message: &str) -> Severity {
+    fn check(&self, _player_id: T, message: &str) -> Severity {
         let msg = normalized_message(message);
 
         // silly implementation, allows bad messages with a single good word
-        for badword in &self.blacklist {
-            if msg.contains(badword) {
-                if !self.whitelist.iter().any(|goodword| msg.contains(goodword)) {
+        for bad_word in &self.blacklist {
+            if msg.contains(bad_word) {
+                if !self
+                    .whitelist
+                    .iter()
+                    .any(|good_word| msg.contains(good_word))
+                {
                     return Severity::Warn;
                 }
             }
@@ -48,7 +52,7 @@
         // this one fails
         //assert_eq!(checker.check(0, "poop 'fsck -y' poop"), Severity::Warn);
 
-        // ideally this one shouldn't fail
+        // ideally this one shouldn't fail, need a better confusables check
         // assert_eq!(checker.check(0, "P00P"), Severity::Warn);
     }
 }