import os
def check_large_files(directory, min_lines=500):
large_files = []
for root, _, files in os.walk(directory):
for file in files:
if not file.endswith('.rs'): continue
file_path = os.path.join(root, file)
try:
with open(file_path, 'r', encoding='utf-8') as f:
line_count = sum(1 for _ in f)
if line_count > min_lines:
large_files.append({
'path': file_path,
'lines': line_count,
'relative_path': os.path.relpath(file_path, directory)
})
except Exception as e:
print(f"Error reading {file_path}: {e}")
return large_files
if __name__ == '__main__':
src_dir = os.path.join(os.path.dirname(__file__), '..', 'src')
large_files = check_large_files(src_dir)
print(f"Found {len(large_files)} files with more than 500 lines:")
for file in sorted(large_files, key=lambda x: x['lines'], reverse=True):
print(f"{file['relative_path']}: {file['lines']} lines")