MCPcopy
hub / github.com/github/awesome-copilot / count_source_files

Function count_source_files

skills/quality-playbook/quality_gate.py:727–750  ·  view source on GitHub ↗

Count source files up to 4 dirs deep, excluding vendor/node_modules/etc.

(repo_dir)

Source from the content-addressed store, hash-verified

725
726
727def count_source_files(repo_dir):
728 """Count source files up to 4 dirs deep, excluding vendor/node_modules/etc."""
729 src_count = 0
730 exts = {".go", ".py", ".java", ".kt", ".rs", ".ts", ".js", ".scala",
731 ".c", ".h", ".agc"}
732 excluded = {"vendor", "node_modules", ".git", "quality"}
733
734 def walk(base, current_depth, max_depth):
735 nonlocal src_count
736 try:
737 for entry in os.scandir(base):
738 name = entry.name
739 if entry.is_dir(follow_symlinks=False):
740 if current_depth < max_depth and name not in excluded:
741 walk(entry.path, current_depth + 1, max_depth)
742 elif entry.is_file(follow_symlinks=False):
743 dot = name.rfind(".")
744 if dot >= 0 and name[dot:] in exts:
745 src_count += 1
746 except (OSError, PermissionError):
747 pass
748
749 walk(str(repo_dir), 1, 4)
750 return src_count
751
752
753# --- Section checks ---

Callers 1

check_use_casesFunction · 0.85

Calls 1

walkFunction · 0.70

Tested by

no test coverage detected