Skip to content

Commit 62b08d3

Browse files
Merge pull request #302 from microsoft/psl-codequality
fix: Fixed code quality issues.
2 parents 79badcb + 9c6b21e commit 62b08d3

23 files changed

Lines changed: 40 additions & 165 deletions

File tree

docs/DeploymentGuide.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ If you're not using one of the above options for opening the project, then you'l
124124
2. Download the project code:
125125

126126
```shell
127-
azd init -t microsoft/Modernize-your-Code-Solution-Accelerator/
127+
azd init -t microsoft/Modernize-your-Code-Solution-Accelerator
128128
```
129129

130130
3. Open the project folder in your terminal or editor.
@@ -164,7 +164,7 @@ To adjust quota settings, follow these [steps](../docs/AzureGPTQuotaSettings.md)
164164

165165
<summary><b>Reusing an Existing Log Analytics Workspace</b></summary>
166166

167-
Guide to get your [Existing Workspace ID](/docs/re-use-log-analytics.md)
167+
Guide to get your [Existing Workspace ID](./re-use-log-analytics.md)
168168

169169
</details>
170170

@@ -217,7 +217,7 @@ Rename `azure.yaml` to `azure_original.yaml` and `azure_custom.yaml` to `azure.y
217217
218218
Go to `infra` directory
219219
220-
Rename `main.bicep` to `main_original.bicep` and `main_custom.bicep` to `main.bicep`. Continue with the [deploying steps](https://github.com/microsoft/Modernize-your-code-solution-accelerator/blob/main/docs/DeploymentGuide.md#deploying-with-azd).
220+
Rename `main.bicep` to `main_original.bicep` and `main_custom.bicep` to `main.bicep`. Continue with the [deploying steps](#deploying-with-azd).
221221
222222
### 🛠️ Troubleshooting
223223
If you encounter any issues during the deployment process, please refer [troubleshooting](../docs/TroubleShootingSteps.md) document for detailed steps and solutions.

src/backend/api/api_routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ async def batch_status_updates(
279279
try:
280280
await websocket.receive_text()
281281
except asyncio.TimeoutError:
282+
# TimeoutError is ignored to keep the WebSocket connection open without receiving data
282283
pass
283284

284285
except WebSocketDisconnect:

src/backend/common/database/cosmosdb.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,10 +352,6 @@ async def update_batch_entry(
352352
batch["file_count"] = file_count
353353

354354
await self.batch_container.replace_item(item=batch_id, body=batch)
355-
# if isinstance(status, ProcessStatus):
356-
# self.logger.info(f"Updated batch {batch_id} to status {status.value}")
357-
# else:
358-
# self.logger.info(f"Updated batch {batch_id} to status {status}")
359355

360356
return batch
361357
except Exception as e:

src/backend/common/services/batch_service.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,8 @@ async def delete_batch(self, batch_id: UUID, user_id: str):
175175

176176
self.logger.info(f"Successfully deleted batch with ID: {batch_id}")
177177
return {"message": "Batch deleted successfully", "batch_id": str(batch_id)}
178+
else:
179+
return {"message": "Batch not found", "batch_id": str(batch_id)}
178180

179181
async def delete_file(self, file_id: UUID, user_id: str):
180182
"""Delete a file and its logs, and update batch file count."""

src/backend/common/storage/blob_azure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def upload_file(
5252
raise
5353
try:
5454
# Upload the file
55-
upload_results = blob_client.upload_blob( # noqa: F841
55+
blob_client.upload_blob(
5656
file_content,
5757
content_type=content_type,
5858
metadata=metadata,

src/backend/sql_agents/convert_script.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ async def convert_script(
6666

6767
# orchestrate the chat
6868
current_migration = "No migration"
69-
is_complete: bool = False
70-
while not is_complete:
69+
while True:
7170
await comms_manager.group_chat.add_chat_message(
7271
ChatMessageContent(role=AuthorRole.USER, content=source_script)
7372
)
@@ -274,9 +273,7 @@ async def convert_script(
274273
break
275274

276275
if comms_manager.group_chat.is_complete:
277-
is_complete = True
278-
279-
break
276+
break
280277

281278
migrated_query = current_migration
282279

src/backend/sql_agents/helpers/comms_manager.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ async def select_agent(self, agents, history):
7979
),
8080
None,
8181
)
82+
# No matching case found, so explicitly return None
83+
return None
8284

8385
# class for termination strategy
8486
class ApprovalTerminationStrategy(TerminationStrategy):
@@ -270,17 +272,3 @@ async def cleanup(self):
270272

271273
except Exception as e:
272274
self.logger.error("Error during cleanup: %s", str(e))
273-
274-
def __del__(self):
275-
"""Destructor to ensure cleanup if not explicitly called."""
276-
try:
277-
# Only attempt cleanup if there's an active event loop
278-
loop = asyncio.get_running_loop()
279-
if loop and not loop.is_closed():
280-
# Schedule cleanup as a task
281-
loop.create_task(self.cleanup())
282-
except RuntimeError:
283-
# No event loop running, can't clean up asynchronously
284-
self.logger.warning("No event loop available for cleanup in destructor")
285-
except Exception as e:
286-
self.logger.error("Error in destructor cleanup: %s", str(e))

src/backend/sql_agents/tools/src/Program.cs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4+
using System.Linq;
45
using Microsoft.SqlServer.TransactSql.ScriptDom;
56
using Newtonsoft.Json;
67

@@ -42,18 +43,14 @@ static void Main(string[] args)
4243

4344
IList<ParseError> errors = ParseSqlQuery(sqlQuery);
4445

45-
var errorList = new List<Dictionary<string, object>>();
46-
47-
foreach (var error in errors)
48-
{
49-
var errorDict = new Dictionary<string, object>
46+
var errorList = errors
47+
.Select(error => new Dictionary<string, object>
5048
{
5149
{ "Line", error.Line },
5250
{ "Column", error.Column },
5351
{ "Error", error.Message }
54-
};
55-
errorList.Add(errorDict);
56-
}
52+
})
53+
.ToList();
5754

5855
string jsonOutput = JsonConvert.SerializeObject(errorList, Formatting.Indented);
5956
Console.WriteLine(jsonOutput);

src/frontend/frontend_server.py

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

1010
# Load environment variables from .env file

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);
418418
if (errorFiles.length === 0) {
419419
return (
420420
<div className={useStyles().errorItem}>

0 commit comments

Comments
 (0)