noellimx / duke Goto Github PK
View Code? Open in Web Editor NEWThis project forked from nus-tic2002-2021/duke
This project forked from nus-tic2002-2021/duke
@noellimx We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, to help you improve the iP code further.
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.
No easy-to-detect issues ๐
Example from src/main/java/duke/Ui.java
lines 18-18
:
private Boolean _loop = true;
Example from src/main/java/duke/task/model/Task.java
lines 10-10
:
private Boolean _done;
Example from src/test/java/duke/mock/mockTask/MockTask.java
lines 6-6
:
private Boolean done = false;
Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
No easy-to-detect issues ๐
Example from src/main/java/duke/command/commandFactory/CommandFactory.java
lines 1-1
:
package duke.command.commandFactory;
Example from src/main/java/duke/command/commandFactory/UiCommandFactory.java
lines 1-1
:
package duke.command.commandFactory;
Example from src/main/java/duke/command/errorCommand/CommandExecutionError.java
lines 1-1
:
package duke.command.errorCommand;
Suggestion: Follow the package naming convention specified by the coding standard.
Example from src/test/java/duke/TaskManager_Test.java
lines 10-10
:
public class TaskManager_Test extends TestStream {
Example from src/test/java/duke/level/Increment_00_Test.java
lines 19-19
:
public class Increment_00_Test extends TestStream {
Example from src/test/java/duke/level/Increment_04_Test.java
lines 27-27
:
public class Increment_04_Test extends TestStream {
Suggestion: Follow the class naming convention specified by the coding standard.
No easy-to-detect issues ๐
Example from src/main/java/duke/dukeUtility/prettify/Prettify.java
lines 27-85
:
public static String prettifyTaskMgr(TaskManager taskMgr) {
Task[] tl = taskMgr.getAllAsArray();
StringBuilder generating = new StringBuilder();
int taskQty = taskMgr.getSize();
generating.append((taskQty + " task" + (taskQty > 1 ? "s" : "") + " in list" + System.lineSeparator()));
/* header values */
String headerId = String.format(".%-4s ", "id#");
String headerDoneStatus = "Done ";
String headerTaskType = "Type ";
String headerDescription = "Task Description ";
String headerChronology = "Chronology";
/* append headers */
generating.append(headerId);
generating.append(headerDoneStatus);
generating.append(headerTaskType);
generating.append(headerDescription);
generating.append(headerChronology);
generating.append("\n");
/* column width references */
int lengthColId = headerId.length();
int lengthColTaskType = headerTaskType.length();
int lengthColDoneStatus = headerDoneStatus.length();
int lengthColDesc = headerDescription.length();
// body
for (Task t : tl) {
// fill column Id
String idValue = String.format("%4d", t.getTaskId()).replace(" ", "0");
String columnId = fillCell(idValue, lengthColId);
// fill column Done Status
String doneStatusValue = String.format("[%s]", t.isDone() ? "X" : " ");
String columnDoneStatus = fillCell(doneStatusValue, lengthColDoneStatus);
// fill column Task Type Status
String taskTypeSymbolValue = String.format("[%s]", getTaskTypeSymbol(t));
String columnTaskType = fillCell(taskTypeSymbolValue, lengthColTaskType);
// fill column Description
String descValueLong = t.getTaskDescription();
String descValue = descValueLong.substring(0, Math.min(descValueLong.length(), lengthColDesc - 1));
String columnDescription = fillCell(descValue, lengthColDesc);
// fill column Chronology
String columnChronology = t.getChronologyString();
generating.append(columnId);
generating.append(columnDoneStatus);
generating.append(columnTaskType);
generating.append(columnDescription);
generating.append(columnChronology);
generating.append(System.lineSeparator());
}
String generated = generating.toString();
return generated;
}
Example from src/test/java/duke/level/Increment_04_Test.java
lines 227-289
:
public void TestLevel4_Greet_AddEachEvent_List_Exit() throws Exception{
String task0ToDoDescription = "todo_desc asfasfasf";
String task1DeadlineDescription = "deadline_desc ndfrgndfndfn";
String task1DeadlineByString = "someDeadline";
String task2EventDescription = "event_desc_abc 213t12 3b52";
String task2EventFromDateString = "fromday";
String task2EventToDateString = "today";
String storeToDoCommand0 = generateTextCommandLineAddToDo(PROMPT_UNDER_TEST_ADD_TO_DO, task0ToDoDescription);
String storeDeadlineCommand1 = generateTextCommandLineAddDeadline(PROMPT_UNDER_TEST_ADD_DEADLINE, task1DeadlineDescription,DELIMITER_DEADLINE_DEADLINE,task1DeadlineByString);
String storeEventCommand2 = generateTextCommandLineAddEvent(PROMPT_UNDER_TEST_ADD_EVENT, task2EventDescription,DELIMITER_EVENT_FROM,task2EventFromDateString,DELIMITER_EVENT_TO,task2EventToDateString);
String listCommand = generateTextCommandList(PROMPT_UNDER_TEST_LIST);
String exitCommand = generateTextCommandExit(PROMPT_UNDER_TEST_EXIT_LOOP);
StringBuilder commandBuilder = new StringBuilder();
commandBuilder.append(storeToDoCommand0);
commandBuilder.append(storeDeadlineCommand1);
commandBuilder.append(storeEventCommand2);
commandBuilder.append(listCommand);
commandBuilder.append(exitCommand);
System.setIn(new ByteArrayInputStream(commandBuilder.toString().getBytes()));
/*
* Should display:
* Entry Message
* Input Loop Message
* "Added todo" message
* "Added deadline" message
* "Added event" message
* tabled tasks list
* exit loop
* terminate
*/
StringBuilder expectedResponseBuilder = new StringBuilder();
MockToDo expectedToDo = new MockToDo(task0ToDoDescription, 0,false);
MockDeadline expectedDeadline = new MockDeadline(task1DeadlineDescription, 1, false, task1DeadlineByString);
MockEvent expectedEvent = new MockEvent(task2EventDescription, 2, false, task2EventFromDateString,task2EventToDateString);
expectedResponseBuilder.append(getMsgUnderTestEntry());
expectedResponseBuilder.append(getMsgUnderTestBeginInputLoop());
expectedResponseBuilder.append(getMsgUnderTestResponseToDoAdded(task0ToDoDescription));
expectedResponseBuilder.append(getMsgUnderTestResponseDeadlineAdded(task1DeadlineDescription));
expectedResponseBuilder.append(getMsgUnderTestResponseEventAdded(task2EventDescription));
MockTask[] MockEvents = {expectedToDo,expectedDeadline,expectedEvent};
expectedResponseBuilder.append(getMsgUnderTestResponseListAll(getPrettifyUnderTestList(MockEvents)));
expectedResponseBuilder.append(getMsgUnderTestExitLoop());
expectedResponseBuilder.append(getMsgUnderTestTerminate());
String expectedOutputResponse = expectedResponseBuilder.toString();
Main.run(this.getPrintStream(), new TaskManager());
assertEquals(expectedOutputResponse, this.getOutput());
}
Example from src/test/java/duke/testHelper/help/PrettifyUnderTest.java
lines 42-101
:
public static String getPrettifyUnderTestList(MockTask... mockTasks) {
int taskQty = mockTasks.length;
StringBuilder generating = new StringBuilder();
generating.append((taskQty + " task" + (taskQty > 1 ? "s" : "") + " in list" + System.lineSeparator()));
/* header values */
String headerId = String.format(".%-4s ", "id#");
String headerDoneStatus = "Done ";
String headerTaskType = "Type ";
String headerDescription = "Task Description ";
String headerChronology = "Chronology";
/* append headers */
generating.append(headerId);
generating.append(headerDoneStatus);
generating.append(headerTaskType);
generating.append(headerDescription);
generating.append(headerChronology);
generating.append(System.lineSeparator());
/* column width references */
int lengthColId = headerId.length();
int lengthColTaskType = headerTaskType.length();
int lengthColDoneStatus = headerDoneStatus.length();
int lengthColDesc = headerDescription.length();
for (int i = 0; i < taskQty; i++) {
MockTask task = mockTasks[i];
// fill column Id
String idValue = String.format("%4d", task.getId()).replace(" ", "0");
String columnId = fillCellUnderTest(idValue, lengthColId);
// fill column Done Status
String doneStatusValue = String.format("[%s]", task.getDone() ? "X" : " ");
String columnDoneStatus = fillCellUnderTest(doneStatusValue, lengthColDoneStatus);
// fill column Task Type Status
String taskTypeSymbolValue = String.format("[%s]", getTaskCharCodeUnderTest(task));
String columnTaskType = fillCellUnderTest(taskTypeSymbolValue, lengthColTaskType);
// fill column Description
String descValueLong = task.getDesc();
String descValue = descValueLong.substring(0, Math.min(descValueLong.length(), lengthColDesc - 1));
String columnDescription = fillCellUnderTest(descValue, lengthColDesc);
// fill column Chronology
String columnChronology = getTaskChronologyString(task);
generating.append(columnId);
generating.append(columnDoneStatus);
generating.append(columnTaskType);
generating.append(columnDescription);
generating.append(columnChronology);
generating.append(System.lineSeparator());
}
String generated = generating.toString();
return generated;
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
No easy-to-detect issues ๐
No easy-to-detect issues ๐
โน๏ธ The bot account @nus-se-bot used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact [email protected]
if you want to follow up on this post.
@noellimx We did an automated analysis of your code to detect potential areas to improve the code quality. We are sharing the results below, so that you can avoid similar problems in your tP code (which will be graded more strictly for code quality).
IMPORTANT: Note that the script looked for just a few easy-to-detect problems only, and at-most three example are given i.e., there can be other areas/places to improve.
No easy-to-detect issues ๐
Example from src/main/java/duke/Ui.java
lines 18-18
:
private Boolean loop = true;
Example from src/main/java/duke/task/model/Task.java
lines 12-12
:
private Boolean done;
Example from src/test/java/duke/mock/mocktask/MockTask.java
lines 6-6
:
private Boolean done = false;
Suggestion: Follow the given naming convention for boolean variables/methods (e.g., use a boolean-sounding prefix).You may ignore the above if you think the name already follows the convention (the script can report false positives in some cases)
No easy-to-detect issues ๐
No easy-to-detect issues ๐
Example from src/main/java/duke/dukeutility/helper.java
lines 3-3
:
public class helper {
Suggestion: Follow the class naming convention specified by the coding standard.
No easy-to-detect issues ๐
Example from src/main/java/duke/Ui.java
lines 163-215
:
protected void displayCommandResponse(Command c) throws Exception {
ResponseType rt = c.getResponseType();
if (rt == ResponseType.EXIT_LOOP) {
this.setLoop(false);
this.printExitLoop();
} else if (rt == ResponseType.ECHO) {
this.printEchoMessage(c.getArgs().get(1));
} else if (rt == ResponseType.ERROR_COMMAND_EXECUTION) {
this.printResponseTemplate(c.getArgs().get(2));
} else if (rt == ResponseType.TASK_CREATE_TODO) {
this.printResponseAddedToDo(c.getArgs().get(1), c.getArgs().get(2));
} else if (rt == ResponseType.TASK_CREATE_DEADLINE) {
this.printResponseAddedDeadline(c.getArgs().get(1), c.getArgs().get(2));
} else if (rt == ResponseType.TASK_CREATE_EVENT) {
this.printResponseAddedEvent(c.getArgs().get(1), c.getArgs().get(2));
} else if (rt == ResponseType.TASK_LIST_ALL) {
this.getPrintStream().print(c.getArgs().get(1));
} else if (rt == ResponseType.TASK_LIST_FIND) {
this.getPrintStream().print(
"Query keyword in description: " + c.getArgs().get(2) + System.lineSeparator() + c.getArgs().get(1));
} else if (rt == ResponseType.TASK_UPDATE_COMPLETE) {
this.printResponseTemplate(String.join(" ", c.getArgs()));
} else if (rt == ResponseType.ERROR_REQUEST_UNKNOWN) {
this.printResponseUnknownRequest();
} else if (rt == ResponseType.TASK_NOT_FOUND) {
this.printResponseTaskNotFound(c.getArgs().get(1));
} else if (rt == ResponseType.TASK_DELETE_TASK) {
this.printResponseTaskDeleted(c.getArgs().get(1));
} else if (rt == ResponseType.ERROR_REQUEST_INVALID_SYNTAX) {
this.printResponseInvalidCommand(c.getArgs().get(1));
} else if (rt == ResponseType.ERROR_REQUEST_INVALID_PARAMETERS) {
this.printResponseTaskRequestInvalidParameters(c.getArgs().get(1));
} else if (rt == ResponseType.FILE_SAVED) {
this.printResponseTaskFileSaved(c.getArgs().get(1));
} else if (rt == ResponseType.ERROR_INVALID_READ_FILE_PATH) {
this.printResponseTaskReadPathInvalid();
} else if (rt == ResponseType.FILE_READ) {
this.printReadSuccess(c.getArgs().get(2));
} else if (rt == ResponseType.TASK_UPDATE_INCOMPLETE) {
this.printResponseTemplate(String.join(" ", c.getArgs()));
} else if (rt == ResponseType.TASK_PROJECTION) {
this.getPrintStream().print(
"Tasks for the next " + c.getArgs().get(2) + " days: " + System.lineSeparator() + c.getArgs().get(1));
} else if (rt == ResponseType.TASK_STATS_ALL) {
this.getPrintStream().print(
"Task Summary " + System.lineSeparator() + c.getArgs().get(1));
} else if (rt == ResponseType.SCAN_DUPLICATE_DESCRIPTION) {
this.getPrintStream().print(
"Duplicates \"[Description]\":[...ids] " + System.lineSeparator() + c.getArgs().get(1));
} else {
throw new Exception("Unhandled response type [" + rt + "].");
}
}
Example from src/main/java/duke/command/commandfactory/UiCommandFactory.java
lines 57-91
:
public Command executeTextCommand(String text, TaskManager taskManager, FileResourceManager frm) {
try {
if (isRequestExitLoop(text)) {
return this.executeCommandExitLoop();
} else if (isRequestList(text)) {
return new CommandListAll(taskManager);
} else if (isRequestMarkTaskAsDone(text)) {
return this.executeCommandMarkTaskAsDone(text, taskManager);
} else if (isRequestMarkTaskAsIncomplete(text)) {
return this.executeCommandMarkTaskAsIncomplete(text, taskManager);
} else if (isRequestAddToDo(text)) {
return this.executeCommandAddToDo(text, taskManager);
} else if (isRequestAddDeadline(text)) {
return this.executeCommandAddDeadline(text, taskManager);
} else if (isRequestAddEvent(text)) {
return this.executeCommandAddEvent(text, taskManager);
} else if (isRequestDeleteTask(text)) {
return this.executeCommandDeleteTask(text, taskManager);
} else if (isRequestSave(text)) {
return frm.executeCommandSave(taskManager);
} else if (isRequestFind(text)) {
return this.executeCommandFindByKeywordInDescription(text, taskManager);
} else if (isRequestProjection(text)) {
return this.executeCommandProjection(text, taskManager);
} else if (isRequestStatisticsAll(text)) {
return new CommandStatsAll(taskManager);
} else if (isRequestScanDuplicates(text)) {
return new CommandScanDuplicateDescriptions(taskManager);
} else {
return new CommandUnknownRequest(text);
}
} catch (Exception e) {
return new CommandExecutionError(e, "command execution @ cli");
}
}
Example from src/main/java/duke/dukeutility/prettify/Prettify.java
lines 93-171
:
public static String getStatisticsAll(ArrayList<Task> tasks) {
// Tabulate
int col = 0;
int colDone = col++;
int colNotDone = col++;
int row = 0;
int rowToDo = row++;
int rowDeadline = row++;
int rowEvent = row++;
Integer[][] stats = new Integer[col][row];
for (Integer[] ints : stats) {
Arrays.fill(ints, 0);
}
for (Task t : tasks) {
Integer thisRow = null;
if (t instanceof ToDo) {
thisRow = rowToDo;
} else if (t instanceof Deadline) {
thisRow = rowDeadline;
} else if (t instanceof Event) {
thisRow = rowEvent;
}
Integer thisCol = null;
if (t.isDone()) {
thisCol = colDone;
} else {
thisCol = colNotDone;
}
assert (thisCol != null);
assert (thisRow != null);
if (thisCol != null && thisRow != null) {
stats[thisCol][thisRow]++;
}
}
int rowHeader = row++;
int colTaskType = col++;
String[][] table = new String[col][row];
for (String[] tableRow : table) {
Arrays.fill(tableRow, "");
}
table[0][rowHeader] = "Task Type ";
table[0][rowToDo] = "To Do";
table[0][rowDeadline] = "Deadline";
table[0][rowEvent] = "Event";
table[2][rowHeader] = "Incomplete ";
table[2][rowToDo] = stats[colNotDone][rowToDo].toString();
table[2][rowDeadline] = stats[colNotDone][rowDeadline].toString();
table[2][rowEvent] = stats[colNotDone][rowEvent].toString();
table[1][rowHeader] = "Complete ";
table[1][rowToDo] = stats[colDone][rowToDo].toString();
table[1][rowDeadline] = stats[colDone][rowDeadline].toString();
table[1][rowEvent] = stats[colDone][rowEvent].toString();
int[] colLength = new int[col];
colLength[colTaskType] = getMaxLength(table[colTaskType]);
colLength[colNotDone] = getMaxLength(table[colNotDone]);
colLength[colDone] = getMaxLength(table[colDone]);
for (int c = 0; c < col; c++) {
for (int r = 0; r < row; r++) {
table[c][r] = fillCell(table[c][r], colLength[c]);
}
}
StringBuilder lines = new StringBuilder();
lines.append(String.join("", getRowValue(table, rowHeader)) + System.lineSeparator());
lines.append(String.join("", getRowValue(table, rowToDo)) + System.lineSeparator());
lines.append(String.join("", getRowValue(table, rowDeadline)) + System.lineSeparator());
lines.append(String.join("", getRowValue(table, rowEvent)) + System.lineSeparator());
return lines.toString();
}
Suggestion: Consider applying SLAP (and other abstraction mechanisms) to shorten methods. You may ignore this suggestion if you think a longer method is justified in a particular case.
No easy-to-detect issues ๐
Example from src/main/java/duke/FileResourceManager.java
lines 68-72
:
/**
* Import tasks from this import path.
*
* @return
*/
Example from src/main/java/duke/FileResourceManager.java
lines 98-103
:
/**
* Save tasks in taskManager to this fileResourceManager's export path.
*
* @param taskManager task manager
* @return
*/
Example from src/main/java/duke/FileResourceManager.java
lines 133-138
:
/**
* Import tasks to task manager
*
* @param tasks json array of tasks
* @param taskManager task manager to import to.
*/
Suggestion: Ensure method/class header comments follow the format specified in the coding standard, in particular, the phrasing of the overview statement
โน๏ธ The bot account @nus-se-bot used to post this issue is un-manned. Do not reply to this post (as those replies will not be read). Instead, contact [email protected]
if you want to follow up on this post.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.