Skip to content

Commit f9b4b68

Browse files
Merge pull request #210 from microsoft/psl-codequlity-cmv2
fix: fixed CodQL issues for Container Migration.
2 parents 7bc1fff + 8477b3e commit f9b4b68

29 files changed

Lines changed: 68 additions & 231 deletions

scripts/validate_bicep_params.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def parse_parameters_env_vars(json_path: Path) -> dict[str, list[str]]:
110110
data = json.loads(sanitized)
111111
params = data.get("parameters", {})
112112
except json.JSONDecodeError:
113-
pass
113+
pass # File is not valid JSON after azd variable substitution; fall through to regex scan
114114

115115
# Walk each top-level parameter and scan its entire serialized value
116116
# for ${VAR} references from the original text.

src/backend-api/src/app/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _register_dependencies(self):
133133
)
134134
.add_singleton(ILoggerService, ConsoleLoggerService)
135135
.add_transient(IHttpService, HttpClientService)
136-
.add_singleton(IDataService, lambda: InMemoryDataService())
136+
.add_singleton(IDataService, InMemoryDataService)
137137
)
138138

139139
def run(self, host: str = "0.0.0.0", port: int = 8000, reload: bool = True):

src/backend-api/src/app/libs/base/SKLogicBase.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def _init_agent(self):
8181
"""
8282
raise NotImplementedError("This method should be overridden in subclasses")
8383

84-
async def execute(func_params: dict[str, any]):
84+
async def execute(self, func_params: dict[str, any]):
8585
raise NotImplementedError("Execute method not implemented")
8686

8787
@overload
@@ -92,7 +92,7 @@ async def execute_thread(
9292
thread: AgentThread | AssistantAgentThread | AzureAIAgentThread = None,
9393
) -> tuple[str, AgentThread | AssistantAgentThread | AzureAIAgentThread]:
9494
"""When response_format is None, returns string response."""
95-
...
95+
pass
9696

9797
@overload
9898
async def execute_thread(
@@ -102,7 +102,7 @@ async def execute_thread(
102102
thread: AgentThread | AssistantAgentThread | AzureAIAgentThread = None,
103103
) -> tuple[T, AgentThread | AssistantAgentThread | AzureAIAgentThread]:
104104
"""When response_format is provided, returns typed Pydantic BaseModel response."""
105-
...
105+
pass
106106

107107
@abstractmethod
108108
async def execute_thread(

src/backend-api/src/app/libs/base/fastapi_protocol.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ class FastAPIWithContext(Protocol):
1616
app_context: AppContext
1717

1818
# Include essential FastAPI methods for type checking
19-
def include_router(self, *args, **kwargs) -> None: ...
19+
def include_router(self, *args, **kwargs) -> None:
20+
pass
2021

2122

2223
def add_app_context_to_fastapi(

src/backend-api/src/tests/application/test_dependency_injection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ def test_factory_registration():
126126
app_context = AppContext()
127127

128128
# Register with factory function
129-
app_context.add_singleton(IDataService, lambda: InMemoryDataService())
129+
app_context.add_singleton(IDataService, InMemoryDataService)
130130

131131
data_service = app_context.get_service(IDataService)
132132
assert isinstance(data_service, InMemoryDataService)

src/frontend/frontend_server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dotenv import load_dotenv
55
from fastapi import FastAPI, Request
66
from fastapi.middleware.cors import CORSMiddleware
7-
from fastapi.responses import FileResponse, HTMLResponse, JSONResponse
7+
from fastapi.responses import FileResponse, JSONResponse
88
from fastapi.staticfiles import StaticFiles
99

1010
# Load environment variables from .env file
@@ -42,7 +42,6 @@ async def serve_index():
4242
async def get_config(request: Request):
4343
# Only serve config to same-origin requests by checking the Referer/Origin
4444
origin = request.headers.get("origin") or ""
45-
referer = request.headers.get("referer") or ""
4645
host = request.headers.get("host") or ""
4746
if origin and not origin.endswith(host):
4847
return JSONResponse(status_code=403, content={"detail": "Forbidden"})

src/frontend/src/api/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ export const renderErrorSection = (batchSummary, expandedSections, setExpandedSe
414414

415415
export const renderErrorContent = (batchSummary) => {
416416
// Group errors by file
417-
const errorFiles = batchSummary.files.filter(file => file.error_count && file.error_count);
417+
const errorFiles = batchSummary.files.filter(file => file.error_count > 0);
418418
if (errorFiles.length === 0) {
419419
return (
420420
<div className={useStyles().errorItem}>

src/frontend/src/commonComponents/ProgressModal/progressModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ const ProgressModal: React.FC<ProgressModalProps> = ({
4141
}) => {
4242
// Calculate progress percentage based on step (stable step-level identifier)
4343
const getProgressPercentage = () => {
44+
if (processingCompleted) return 100;
4445
if (migrationError) return 0; // Show 0% progress for errors
45-
if (processingCompleted && !migrationError) return 100;
4646
if (!apiData) return 0;
4747

4848
// Use apiData.step (stable: "analysis", "design", "yaml_conversion", "documentation")

src/frontend/src/components/batchHistoryPanel.tsx

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface BatchHistoryItem {
2121
status: string;
2222
}
2323
const HistoryPanel: React.FC<HistoryPanelProps> = ({ isOpen, onClose }) => {
24-
const headers = {}
24+
const headers = {};
2525
const [batchHistory, setBatchHistory] = useState<BatchHistoryItem[]>([]);
2626
const [loading, setLoading] = useState(false);
2727
const [error, setError] = useState<string | null>(null);
@@ -81,46 +81,6 @@ const HistoryPanel: React.FC<HistoryPanelProps> = ({ isOpen, onClose }) => {
8181
}
8282
};
8383

84-
// Function to categorize batches
85-
const categorizeBatches = () => {
86-
const now = new Date();
87-
const userTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
88-
89-
// Get start of "Today", "Past 7 days", and "Past 30 days" in LOCAL time
90-
const todayStart = new Date(now.getFullYear(), now.getMonth(), now.getDate());
91-
const past7DaysStart = new Date(todayStart);
92-
const past30DaysStart = new Date(todayStart);
93-
94-
past7DaysStart.setDate(todayStart.getDate() - 7);
95-
past30DaysStart.setDate(todayStart.getDate() - 30);
96-
97-
const todayBatches: BatchHistoryItem[] = [];
98-
const past7DaysBatches: BatchHistoryItem[] = [];
99-
const past30DaysBatches: BatchHistoryItem[] = [];
100-
101-
batchHistory.forEach(batch => {
102-
// Convert UTC timestamp to user's local date
103-
const updatedAtUTC = new Date(batch.created_at);
104-
const updatedAtLocal = new Date(updatedAtUTC.toLocaleString("en-US", { timeZone: userTimeZone }));
105-
106-
// Extract only the local **date** part for comparison
107-
const updatedDate = new Date(updatedAtLocal.getFullYear(), updatedAtLocal.getMonth(), updatedAtLocal.getDate());
108-
109-
// Categorize based on **exact day comparison**
110-
if (updatedDate.getTime() === todayStart.getTime()) {
111-
todayBatches.push(batch);
112-
} else if (updatedDate.getTime() >= past7DaysStart.getTime()) {
113-
past7DaysBatches.push(batch);
114-
} else if (updatedDate.getTime() >= past30DaysStart.getTime()) {
115-
past30DaysBatches.push(batch);
116-
}
117-
});
118-
119-
return { todayBatches, past7DaysBatches, past30DaysBatches };
120-
};
121-
122-
// const { todayBatches, past7DaysBatches, past30DaysBatches } = categorizeBatches();
123-
12484
const deleteBatchFromHistory = (batchId: string) => {
12585
// Get the current URL path
12686
const currentPath = window.location.pathname;

src/frontend/src/components/bottomBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Button, Card, Dropdown, DropdownProps, Option } from "@fluentui/react-components"
2-
import React, { useState } from "react"
2+
import React from "react"
33
import { useNavigate } from "react-router-dom"
44

55
// Define possible upload states

0 commit comments

Comments
 (0)