Skip to content

Conversation

Copy link

Copilot AI commented Nov 12, 2025

Cleaned up technical debt: removed unused files, fixed security vulnerability, reduced cognitive complexity.

Deletions

  • 5 empty files: python/point.py, python/tests/test_calculator.py, terraform/iac.tf, diag.mmd, rust/server.rs (incomplete, missing tcp module)
  • 3 empty directories: rust/, terraform/, python/tests/
  • Unused imports: Removed System.IO, System.Linq, Microsoft.Extensions.FileProviders from DotnetApp/Program.cs

Security Fix

Fixed SQL injection in python/sql.py:

# Before
query = "SELECT * FROM users WHERE username = '" + username + "'"
cursor.execute(query)

# After
query = "SELECT * FROM users WHERE username = %s"
cursor.execute(query, (username,))

Also fixed incomplete add_user() function (missing connect() call).

Code Simplification

Refactored TaskItem.CalculateTaskScore() using pattern matching to reduce cognitive complexity:

// Before: nested if/else with score accumulation
private int CalculatePriorityScore() {
    int score = 0;
    if (Priority <= 0) {
        score += 1;
    } else if (Priority == 1) {
        score += 10;
        if (Status == "pending") {
            score += 3;
        }
    }
    // ... more nesting
}

// After: switch expressions
private int CalculatePriorityScore() {
    return Priority switch {
        <= 0 => 1,
        1 => Status == "pending" ? 13 : 10,
        2 => CalculatePriority2Score(),
        _ => 1
    };
}

Net change: -98 lines (139 deleted, 41 added)

Original prompt

Can you celan up this repo and reduce any existing tech debt

Custom agent used: Janitor
Perform janitorial tasks on any codebase including cleanup, simplification, and tech debt remediation.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
E Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE


def add_user(username, password):
conn = mysql.connector.connect
conn = mysql.connector.connect(user='root', password='password', host='localhost', database='users')

Check failure

Code scanning / SonarCloud

Credentials should not be hard-coded High

Revoke and change this password, as it is compromised. See more on SonarQube Cloud
Copilot AI changed the title [WIP] Clean up repository and reduce technical debt Remove dead code, fix SQL injection, simplify complex logic Nov 12, 2025
Copilot AI requested a review from mpchenette November 12, 2025 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants