Skip to content
Closed
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
2 changes: 1 addition & 1 deletion __tests__/math.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Many functions are not tested, and edge cases are missing
*/

import { add, subtract, multiply, divide, factorial, isPrime, average, findMax } from '../src/utils/math';
import { add, subtract, divide, isPrime } from '../src/utils/math';

describe('Math Utilities', () => {
// Basic tests for add function
Expand Down
4 changes: 2 additions & 2 deletions __tests__/todoApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Users can add these via workflows
*/

import { TodoApp, Todo } from '../src/bonus/todoApp';
import { TodoApp } from '../src/bonus/todoApp';

describe('TodoApp', () => {
let app: TodoApp;
Expand Down Expand Up @@ -109,7 +109,7 @@ describe('TodoApp', () => {
describe('getCompletedTodos', () => {
it('should return only completed todos', () => {
const todo1 = app.addTodo('Todo 1');
const todo2 = app.addTodo('Todo 2');
app.addTodo('Todo 2');
const todo3 = app.addTodo('Todo 3');

app.completeTodo(todo1.id);
Expand Down
6 changes: 2 additions & 4 deletions api/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,9 @@ export function isAdmin(userId: number): boolean {
return user.role === 'admin';
}

// Unused import that should be cleaned up (for Workflow #2)
import * as fs from 'fs';

// Console.log that should be removed (for Workflow #2)
console.log('Users API loaded');



/**
* Format user display name
Expand Down
4 changes: 2 additions & 2 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* This file demonstrates how the various modules work together
*/

import { getUserById, getUserEmail, isAdmin } from './api/users';
import { add, subtract, multiply, divide } from './src/utils/math';
import { getUserById, getUserEmail } from './api/users';
import { add, multiply, divide } from './src/utils/math';
import { createLogger } from './src/helpers/logger';
import { TodoApp } from './src/bonus/todoApp';

Expand Down
56 changes: 10 additions & 46 deletions src/utils/messyCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@
* Used for demonstrating Workflow #2 - Code Cleanup
*/

// Unused imports that should be removed
import * as path from 'path';
import { readFile } from 'fs';
import * as crypto from 'crypto';

// Inconsistent quotes
const message1 = "This uses double quotes";
const message2 = 'This uses single quotes';



// Console.logs that should be removed
console.log("Debug: Starting application");
Expand All @@ -21,10 +16,7 @@ function calculateSum (a:number,b:number):number{
return a+b;
}

// Missing semicolons
const value1 = 42
const value2 = "test"
let value3 = true


// Inconsistent indentation
function processData(data: any) {
Expand All @@ -38,54 +30,26 @@ if (data) {
}
}

// var instead of let/const
var oldStyleVariable = "should use const";
var anotherVar = 123;

// Unused variables
const unusedVariable = "I'm never used";
const anotherUnused = { key: "value" };

// Inconsistent object spacing
const obj1 = {key1:"value1",key2:"value2"};
const obj2 = { key1: "value1" , key2 : "value2" };

// Inconsistent array spacing
const arr1 = [1,2,3,4,5];
const arr2 = [ 1 , 2 , 3 , 4 , 5 ];





// Functions with any type
function processAny(input: any): any {
return input;
}

// Template literals not used where they should be
const name = "User";
const greeting = "Hello, " + name + "!";

// Arrow function inconsistency
const arrow1 = (x) => x * 2;
const arrow2 = x=> { return x * 2 };

// Trailing commas inconsistency
const config = {
option1: true,
option2: false,
option3: "maybe", // Has trailing comma
}

const config2 = {
option1: true,
option2: false,
option3: "maybe" // No trailing comma
}

// Mixed async patterns (could be improved)
function fetchDataCallback(callback: Function) {
setTimeout(() => {
callback("data");
}, 1000);
}




// More console.logs to clean up
console.warn("This is a warning");
Expand Down
Loading