From 4f0bfec2fbcc8a1708f3aa04c7c55df48c638b0d Mon Sep 17 00:00:00 2001 From: StillKnotKnown Date: Tue, 27 Jan 2026 22:19:05 +0200 Subject: [PATCH] fix(codeql): remove unused imports and variables - Remove unused imports (datetime, timezone, Path, AsyncMock, MagicMock, RequestException) from test_glab_client.py - Remove unused imports (AsyncMock, MagicMock) from test_gitlab_webhook_operations.py - Remove unused imports (Path) from test_gitlab_types.py - Remove unused imports (Path, AsyncMock, MagicMock) from test_gitlab_triage_engine.py - Remove unused imports (datetime, timedelta) from tests/test_github_bot_detection.py - Remove unused 'author' variable in runner.py triage function These changes resolve CodeQL alerts about unused code while maintaining all necessary functionality. BotDetector parameter warnings are false positives - the parameters are correct for each module (GitHub vs GitLab). --- apps/backend/__tests__/test_gitlab_triage_engine.py | 3 +-- apps/backend/__tests__/test_gitlab_types.py | 2 -- apps/backend/__tests__/test_gitlab_webhook_operations.py | 2 +- apps/backend/__tests__/test_glab_client.py | 6 ++---- apps/backend/runners/gitlab/runner.py | 1 - tests/test_github_bot_detection.py | 3 +-- 6 files changed, 5 insertions(+), 12 deletions(-) diff --git a/apps/backend/__tests__/test_gitlab_triage_engine.py b/apps/backend/__tests__/test_gitlab_triage_engine.py index 4725410e..62098d9c 100644 --- a/apps/backend/__tests__/test_gitlab_triage_engine.py +++ b/apps/backend/__tests__/test_gitlab_triage_engine.py @@ -5,8 +5,7 @@ Tests for GitLab Triage Engine Tests for AI-driven issue triage and categorization. """ -from pathlib import Path -from unittest.mock import AsyncMock, MagicMock, patch +from unittest.mock import patch import pytest diff --git a/apps/backend/__tests__/test_gitlab_types.py b/apps/backend/__tests__/test_gitlab_types.py index 0bc145c1..0facad8b 100644 --- a/apps/backend/__tests__/test_gitlab_types.py +++ b/apps/backend/__tests__/test_gitlab_types.py @@ -5,8 +5,6 @@ Tests for GitLab TypedDict Definitions Tests for type definitions and TypedDict usage. """ -from pathlib import Path - import pytest try: diff --git a/apps/backend/__tests__/test_gitlab_webhook_operations.py b/apps/backend/__tests__/test_gitlab_webhook_operations.py index dad138b4..28e14929 100644 --- a/apps/backend/__tests__/test_gitlab_webhook_operations.py +++ b/apps/backend/__tests__/test_gitlab_webhook_operations.py @@ -5,7 +5,7 @@ Tests for GitLab Webhook Operations Tests for webhook listing, creation, updating, and deletion. """ -from unittest.mock import AsyncMock, MagicMock, patch +from unittest.mock import MagicMock, patch import pytest diff --git a/apps/backend/__tests__/test_glab_client.py b/apps/backend/__tests__/test_glab_client.py index ebcc372b..4bd8bbf5 100644 --- a/apps/backend/__tests__/test_glab_client.py +++ b/apps/backend/__tests__/test_glab_client.py @@ -7,12 +7,10 @@ Tests for GitLab client timeout, retry, and async operations. import asyncio import json -from datetime import datetime, timezone -from pathlib import Path from unittest.mock import AsyncMock, MagicMock, Mock, patch import pytest -from requests.exceptions import ConnectionError, RequestException, Timeout +from requests.exceptions import ConnectionError, Timeout class TestGitLabClient: @@ -154,7 +152,7 @@ class TestGitLabClientRetry: import time with patch.object(client, "_make_request", mock_request): - result = client.get_mr(123) + client.get_mr(123) # Check delays between retries increase (exponential backoff) if len(call_times) > 2: diff --git a/apps/backend/runners/gitlab/runner.py b/apps/backend/runners/gitlab/runner.py index 0e56ea9d..9c072e69 100644 --- a/apps/backend/runners/gitlab/runner.py +++ b/apps/backend/runners/gitlab/runner.py @@ -301,7 +301,6 @@ async def cmd_triage(args) -> int: for issue in issues: title = issue.get("title", "").lower() description = issue.get("description", "").lower() - author = issue.get("author", {}).get("username", "") # Check for spam if any(word in title for word in ["test", "spam", "xxx"]): diff --git a/tests/test_github_bot_detection.py b/tests/test_github_bot_detection.py index 2e9f6f3f..84157042 100644 --- a/tests/test_github_bot_detection.py +++ b/tests/test_github_bot_detection.py @@ -7,9 +7,8 @@ Tests the BotDetector class to ensure it correctly prevents infinite loops. import json import sys -from datetime import datetime, timedelta from pathlib import Path -from unittest.mock import MagicMock, patch +from unittest.mock import patch import pytest