MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / detect_supported_languages

Function detect_supported_languages

codewiki/cli/utils/validation.py:156–207  ·  view source on GitHub ↗

Detect supported programming languages in a directory. Args: directory: Directory to scan Returns: List of (language, file_count) tuples

(directory: Path)

Source from the content-addressed store, hash-verified

154
155 Returns:
156 List of (language, file_count) tuples
157 """
158 language_extensions = {
159 "Python": [".py"],
160 "Java": [".java"],
161 "JavaScript": [".js", ".jsx"],
162 "TypeScript": [".ts", ".tsx"],
163 "C": [".c", ".h"],
164 "C++": [".cpp", ".hpp", ".cc", ".hh", ".cxx", ".hxx"],
165 "C#": [".cs"],
166 "PHP": [".php", ".phtml", ".inc"],
167 "Kotlin": [".kt", ".kts"],
168 "Ruby": [".rb"],
169 "Scala": [".scala", ".sc"],
170 }
171
172 # Directories to exclude from counting
173 excluded_dirs = {
174 "node_modules",
175 "__pycache__",
176 ".git",
177 "build",
178 "dist",
179 ".venv",
180 "venv",
181 "env",
182 ".env",
183 "target",
184 "bin",
185 "obj",
186 ".pytest_cache",
187 ".mypy_cache",
188 ".tox",
189 "coverage",
190 "htmlcov",
191 ".eggs",
192 "*.egg-info",
193 "vendor",
194 "bower_components",
195 ".idea",
196 ".vscode",
197 ".gradle",
198 ".mvn",
199 }
200
201 def should_exclude_file(file_path: Path) -> bool:
202 """Check if file is in an excluded directory."""
203 parts = file_path.parts
204 return any(excluded_dir in parts for excluded_dir in excluded_dirs)
205
206 language_counts = {}
207
208 for language, extensions in language_extensions.items():
209 count = 0
210 for ext in extensions:

Callers 1

validate_repositoryFunction · 0.90

Calls 1

should_exclude_fileFunction · 0.85

Tested by

no test coverage detected