From dcf580ba33d9f65074d8dfb1f9523d5d79c1a719 Mon Sep 17 00:00:00 2001 From: Suhaib Mujahid Date: Fri, 28 Feb 2025 09:52:17 -0500 Subject: [PATCH] [searchfox_api] Ignore the search results that are scattered in too many files --- bugbug/code_search/searchfox_api.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bugbug/code_search/searchfox_api.py b/bugbug/code_search/searchfox_api.py index 86030781cc..7025d8f4cd 100644 --- a/bugbug/code_search/searchfox_api.py +++ b/bugbug/code_search/searchfox_api.py @@ -5,6 +5,7 @@ import io import json +import logging import re from typing import Iterable, Literal @@ -20,6 +21,8 @@ ) from bugbug.repository import SOURCE_CODE_TYPES_TO_EXT +logger = logging.getLogger(__name__) + def get_line_number(elements: Iterable[HtmlElement], position: Literal["start", "end"]): if position == "start": @@ -201,6 +204,13 @@ def search(commit_hash, symbol_name): definitions.append(value) paths = list(set(definition["path"] for definition in definitions)) + if len(paths) > 10: + logger.warning( + "Too many paths found for symbol %s: %d paths. Skipping this symbol.", + symbol_name, + len(paths), + ) + return [] return sum((get_functions(commit_hash, path, symbol_name) for path in paths), [])