Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 34 additions & 76 deletions DotnetApp/Models/TaskItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,108 +20,66 @@ public class TaskItem

public int CalculateTaskScore()
{
int score = 0;

score += CalculatePriorityScore();
score += CalculateStatusScore(score);
int priorityScore = CalculatePriorityScore();
int statusScore = CalculateStatusScore(priorityScore);

return Math.Max(0, score);
return Math.Max(0, priorityScore + statusScore);
}

private int CalculatePriorityScore()
{
int score = 0;

if (Priority <= 0)
{
score += 1;
}
else if (Priority == 1)
{
score += 10;
if (Status == "pending")
{
score += 3;
}
}
else if (Priority == 2)
{
score += 5;
if (Status == "in-progress" && !IsCompleted)
{
score += 2;
if ((DateTime.UtcNow - CreatedAt).TotalDays > 7)
{
score += 3;
}
}
}
else
{
score += 1;
}
if (Priority <= 0) return 1;
if (Priority == 1) return CalculateHighPriorityScore();
if (Priority == 2) return CalculateMediumPriorityScore();
return 1;
}

private int CalculateHighPriorityScore()
{
int score = 10;
if (Status == "pending") score += 3;
return score;
}

private int CalculateStatusScore(int currentScore)
private int CalculateMediumPriorityScore()
{
int score = 0;

switch (Status.ToLower())
int score = 5;
if (Status == "in-progress" && !IsCompleted)
{
case "pending":
score += CalculatePendingScore(currentScore);
break;
case "in-progress":
score += CalculateInProgressScore();
break;
default:
if (!IsCompleted && Priority < 3)
{
score += 3;
}
break;
score += 2;
if ((DateTime.UtcNow - CreatedAt).TotalDays > 7) score += 3;
}

return score;
}

private int CalculatePendingScore(int currentScore)
private int CalculateStatusScore(int priorityScore)
{
int score = 0;

if ((DateTime.UtcNow - CreatedAt).TotalDays > 14)
return Status.ToLower() switch
{
score += currentScore * 2;
if (Priority < 3)
{
score += 5;
}
}
"pending" => CalculatePendingScore(priorityScore),
"in-progress" => CalculateInProgressScore(),
_ => (!IsCompleted && Priority < 3) ? 3 : 0
};
}

private int CalculatePendingScore(int priorityScore)
{
if ((DateTime.UtcNow - CreatedAt).TotalDays <= 14) return 0;

int score = priorityScore * 2;
if (Priority < 3) score += 5;
return score;
}

private int CalculateInProgressScore()
{
int score = 0;
if (IsCompleted) return -5;

if (IsCompleted)
{
score -= 5;
}
else
int score = 0;
foreach (var word in Title.Split(' '))
{
foreach (var word in Title.Split(' '))
{
if (word.Length > 10)
{
score += 1;
}
}
if (word.Length > 10) score += 1;
}

return score;
}
}
Expand Down
4 changes: 1 addition & 3 deletions DotnetApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.IO;
using System.Linq;
using Microsoft.Extensions.FileProviders;
using System.Linq;
using DotnetApp.Services;
using DotnetApp.Models;

Expand Down
Empty file removed python/point.py
Empty file.
10 changes: 5 additions & 5 deletions python/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
def search_user(username):
conn = mysql.connector.connect(user='root', password='password', host='localhost', database='users')
cursor = conn.cursor()
query = "SELECT * FROM users WHERE username = '" + username + "'"
query = "SELECT * FROM users WHERE username = %s"

# Execute the query and process the results
cursor.execute(query)
cursor.execute(query, (username,))
result = cursor.fetchall()
cursor.close()
conn.close()
return result

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
cursor = conn.cursor()
query = "INSERT INTO users (username, password) VALUES ('" + username + "', '" + password + "')"
query = "INSERT INTO users (username, password) VALUES (%s, %s)"

# Execute the query
cursor.execute(query)
cursor.execute(query, (username, password))
conn.commit()
cursor.close()
conn.close()
Expand Down
Empty file removed python/tests/test_calculator.py
Empty file.
Empty file removed terraform/iac.tf
Empty file.
30 changes: 12 additions & 18 deletions web-utils/src/list-utils.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
// List utilities for client-side rendering (with intentional issues for lint demo)
var foo = 1 // missing semicolon, uses var
let bar = 2
let unused = 3
// List utilities for client-side rendering
const foo = 1;
const bar = 2;

export function areEqual(a, b) {
if (a == b) { // eqeqeq violation
console.log("Equal!\n"); // double quotes
if (a === b) {
console.log('Equal!\n');
}
}

export function renderList(items) {
let bar = 'shadowed';
console.log(bar)
const localBar = 'local';
console.log(localBar);

// undefined variable usage
console.log(result)
const arr = [1, 2, 3];
arr.push(4);

// prefer-const violation
let arr = [1,2,3]
arr.push(4)

// mixed spaces and tabs
for (var i = 0; i < items.length; i++) {
console.log(items[i])
for (let i = 0; i < items.length; i++) {
console.log(items[i]);
}

areEqual(foo, bar)
areEqual(foo, bar);
}
3 changes: 0 additions & 3 deletions web-utils/src/math-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,3 @@ export function sum(nums) {
if (!Array.isArray(nums)) return 0;
return nums.reduce((acc, n) => acc + n, 0);
}

greet('World');
console.log('Sum:', sum([1, 2, 3]));