def METHOD_NAME(
    args: CoverageAnalyzeTargetsGenerateConfig,
    results: dict[str, t.Any],
    collection_search_re: t.Optional[t.Pattern] = None,
) -> None:
    """Remove invalid filenames from the given result set."""
    path_checker = PathChecker(args, collection_search_re)
    for path in list(results.keys()):
        if not path_checker.check_path(path):
            del results[path]