forked from dotandev/hintents
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemojis.py
More file actions
112 lines (98 loc) · 3.49 KB
/
emojis.py
File metadata and controls
112 lines (98 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import os
import sys
import argparse
# Comprehensive list of slop emojis and their preferred text replacements
replacements = {
"✅": "[OK]",
"❌": "[FAIL]",
"✓": "[OK]",
"✗": "[FAIL]",
"⚡": "[READY]",
"🚀": "[START]",
"🔍": "[SEARCH]",
"➡️": "->",
"⬅️": "<-",
"🎯": "[TARGET]",
"📍": "[LOC]",
"🔧": "[TOOL]",
"📊": "[STATS]",
"📋": "[LIST]",
"▶️": "[PLAY]",
"📖": "[DOC]",
"👋": "[HELLO]",
"📡": "[NET]",
"✨": "*",
"🔥": "[CRITICAL]",
"💡": "[INFO]",
"🚧": "[WORK-IN-PROGRESS]",
"🧪": "[TEST]",
"🔒": "[SECURE]",
"🔓": "[UNSECURE]",
"🔗": "[LINK]",
"🛠️": "[FIX]",
"📦": "[PKG]",
"🚀": "[DEPLOY]",
"🚨": "[ALERT]",
"🧹": "[CLEANUP]",
"📝": "[LOG]",
"🛡️": "[GUARD]",
"🤖": "[BOT]",
"🐛": "[BUG]",
"🏷️": "[TAG]",
"🎨": "[UI]",
"🏁": "[DONE]",
"🏥": "[HEALTH]",
"🏠": "[HOME]",
"🏗️": "[BUILD]",
"🚢": "[SHIP]",
"🧬": "[GEN]",
"🧪": "[TEST]",
"🌡️": "[METRIC]",
}
def clean_file(filepath, check_only=False):
try:
with open(filepath, 'r', encoding='utf-8') as f:
content = f.read()
new_content = content
found_emojis = []
for emoji, replacement in replacements.items():
if emoji in content:
found_emojis.append(emoji)
new_content = new_content.replace(emoji, replacement)
if content != new_content:
if check_only:
print(f"FAILED: Redundant emojis found in {filepath}: {', '.join(found_emojis)}")
return True
with open(filepath, 'w', encoding='utf-8') as f:
f.write(new_content)
print(f"FIXED: Updated {filepath}")
return False
except Exception as e:
print(f"Error processing {filepath}: {e}")
return False
def main():
parser = argparse.ArgumentParser(description="Scan and remove redundant emojis and slop from the codebase.")
parser.add_argument("path", nargs="?", default=".", help="Directory to scan (default: current directory)")
parser.add_argument("--check", action="store_true", help="Exit with error code if emojis are found without modifying files")
parser.add_argument("--fix", action="store_true", help="Automatically fix found emojis (default behavior if --check is not set)")
args = parser.parse_args()
is_check_mode = args.check and not args.fix
found_any = False
extensions = {".md", ".go", ".ts", ".js", ".tsx", ".jsx", ".toml", ".yml", ".yaml", ".json"}
exclude_dirs = {".git", "node_modules", "vendor", "dist", "out", "coverage", ".next", ".vscode"}
for root, dirs, files in os.walk(args.path):
# Prune excluded directories
dirs[:] = [d for d in dirs if d not in exclude_dirs]
for file in files:
if any(file.endswith(ext) for ext in extensions):
filepath = os.path.join(root, file)
if clean_file(filepath, check_only=is_check_mode):
found_any = True
if is_check_mode and found_any:
print("\nStatic check failed: Redundant emojis/slop detected in codebase.")
print("Please run 'python emojis.py --fix' to clean the codebase.")
sys.exit(1)
if not found_any:
print("No redundant emojis found.")
if __name__ == "__main__":
main()