Repository: mem0ai/mem0
File: embedchain/loaders/github.py (Python)

Code before:
                data = mdx_loader.load_data(file_path)
            elif data_type == "json":
                data = json_loader.load_data(file_path)
            else:
                data = unstructured_loader.load_data(file_path)

            return data.get("data", [])


        def _is_file_empty(file_path):
            return os.path.getsize(file_path) == 0


        def _is_whitelisted(file_path):
            whitelisted_extensions = ['md', 'txt', 'html', 'json', 'py', 'js', 'jsx', 'ts', 'tsx', 'mdx', 'rst']
            _, file_extension = os.path.splitext(file_path)
            return file_extension[1:] in whitelisted_extensions


        def _add_repo_files(repo_path: str):
            with concurrent.futures.ThreadPoolExecutor() as executor:
                future_to_file = {
                    executor.submit(_load_file, os.path.join(root, filename)): os.path.join(root, filename)
                    for root, _, files in os.walk(repo_path)
                    for filename in files
                    if (_is_whitelisted(os.path.join(root, filename)) and not _is_file_empty(os.path.join(root, filename)))
                }  # noqa: E501
                for future in tqdm(concurrent.futures.as_completed(future_to_file), total=len(future_to_file)):
                    file = future_to_file[future]
                    try:
                        results = future.result()
                        if results:
                            data.extend(results)
                            data_urls.extend([result.get("meta_data").get("url") for result in results])
                    except Exception as e:
                        logging.warn(f"Failed to process {file}: {e}")


        source_hash = hashlib.sha256(repo_url.encode()).hexdigest()
        repo_path = f"/tmp/{source_hash}"
        _fetch_or_clone_repo(repo_url=repo_url, local_path=repo_path)
        _add_repo_files(repo_path)
        doc_id = hashlib.sha256((repo_url + ", ".join(data_urls)).encode()).hexdigest()
        return {
            "doc_id": doc_id,
            "data": data,
        }


Review comment (suggestion):
```suggestion
                    if (_is_whitelisted(os.path.join(root, filename)) and not _is_file_empty(os.path.join(root, filename))). # noqa:E501
```

Code after:
            if data_type == "mdx":
                data = mdx_loader.load_data(file_path)
            elif data_type == "json":
                data = json_loader.load_data(file_path)
            else:
                data = unstructured_loader.load_data(file_path)

            return data.get("data", [])

        def _is_file_empty(file_path):
            return os.path.getsize(file_path) == 0

        def _is_whitelisted(file_path):
            whitelisted_extensions = ["md", "txt", "html", "json", "py", "js", "jsx", "ts", "tsx", "mdx", "rst"]
            _, file_extension = os.path.splitext(file_path)
            return file_extension[1:] in whitelisted_extensions

        def _add_repo_files(repo_path: str):
            with concurrent.futures.ThreadPoolExecutor() as executor:
                future_to_file = {
                    executor.submit(_load_file, os.path.join(root, filename)): os.path.join(root, filename)
                    for root, _, files in os.walk(repo_path)
                    for filename in files
                    if _is_whitelisted(os.path.join(root, filename))
                    and not _is_file_empty(os.path.join(root, filename))  # noqa:E501
                }
                for future in tqdm(concurrent.futures.as_completed(future_to_file), total=len(future_to_file)):
                    file = future_to_file[future]
                    try:
                        results = future.result()
                        if results:
                            data.extend(results)
                            data_urls.extend([result.get("meta_data").get("url") for result in results])
                    except Exception as e:
                        logging.warn(f"Failed to process {file}: {e}")

        source_hash = hashlib.sha256(repo_url.encode()).hexdigest()
        repo_path = f"/tmp/{source_hash}"
        _fetch_or_clone_repo(repo_url=repo_url, local_path=repo_path)
        _add_repo_files(repo_path)
        doc_id = hashlib.sha256((repo_url + ", ".join(data_urls)).encode()).hexdigest()
        return {
            "doc_id": doc_id,
            "data": data,
        }