Skip to content

Commit

Permalink
Add checkstyle.xml and suppressions.xml
Browse files Browse the repository at this point in the history
Created a new config and checkstyle folder to store both xml files.

Updated the coding standard of respective java files with respect to the output of the xml files.
  • Loading branch information
ChanWeiJie committed Jan 29, 2022
1 parent 8b468ef commit ea3fce8
Show file tree
Hide file tree
Showing 17 changed files with 489 additions and 62 deletions.
403 changes: 403 additions & 0 deletions config/checkstyle/checkstyle.xml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions config/checkstyle/suppressions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0"?>

<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">

<suppressions>
<suppress checks="JavadocType" files=".*Test\.java"/>
<suppress checks="MissingJavadocMethodCheck" files=".*Test\.java"/>
</suppressions>
2 changes: 1 addition & 1 deletion src/main/java/duke/command/AddCommand.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package duke.command;

import duke.task.Task;
import duke.functionality.TaskList;
import duke.task.Task;

/**
* Represents the add command. A <code>AddCommand</code> object corresponds to adding that specified task
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/command/Command.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package duke.command;

import duke.task.Task;
import duke.functionality.TaskList;
import duke.task.Task;

/**
* Represents the commands inputted by a user. The Command class cannot be instantiated as it is an abstract class.
*/
public abstract class Command{
public abstract class Command {
protected Task task;
protected Integer index;
protected String word;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/duke/command/ExitCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
/**
* Represents the exit command. A <code>ExitCommand</code> object corresponds to exiting the Duke program.
*/
public class ExitCommand extends Command{
public class ExitCommand extends Command {

/**
* Constructor for ExitCommand class.
*/
public ExitCommand() {
super(null, null,null);
super(null, null, null);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/command/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Represents the find command. A <code>FindCommand</code> object corresponds to finding similar tasks
* in the taskList of TaskList class.
*/
public class FindCommand extends Command{
public class FindCommand extends Command {

/**
* Constructor of FindCommand.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/command/MarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class MarkCommand extends Command {
* @param number an indicator to the index of the taskList in TaskList class.
*/
public MarkCommand(Integer number) {
super(null, number,null);
super(null, number, null);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/command/PrintCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* Represents the print command. A <code>PrintCommand</code> object allows users to see all task in Duke TaskBot.
*/
public class PrintCommand extends Command{
public class PrintCommand extends Command {

/**
* Constructor for PrintCommand class.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/command/UnmarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Represents the unmark command. A <code>UnmarkCommand</code> object allows users to set the corresponding task as
* not done.
*/
public class UnmarkCommand extends Command{
public class UnmarkCommand extends Command {

/**
* Constructor for the UnmarkCommand class.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/duke/exception/DukeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Represents the Exceptions the Duke program would handle. A <code> DukeException </code> object corresponds
* to the exceptions specified and handled by Duke.
*/
public class DukeException extends Exception{
public class DukeException extends Exception {

/**
* Constructor for DukeException class.
Expand Down
26 changes: 16 additions & 10 deletions src/main/java/duke/functionality/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;


import duke.command.*;
import duke.command.AddCommand;
import duke.command.Command;
import duke.command.DeleteCommand;
import duke.command.ExitCommand;
import duke.command.FindCommand;
import duke.command.MarkCommand;
import duke.command.PrintCommand;
import duke.command.UnmarkCommand;
import duke.exception.DukeException;
import duke.exception.IncompleteCommandException;
import duke.exception.InvalidCommandException;
import duke.task.Deadline;
import duke.task.Event;
import duke.task.Todo;
import duke.exception.IncompleteCommandException;
import duke.exception.InvalidCommandException;

/**
* Represents the Parsing capabilities of the Duke project. A <code> Parse </code> object corresponds
Expand All @@ -29,8 +35,8 @@ public class Parser {
* @param input date specified by user input. Eg, "2020-06-06".
* @return formatted date.
*/
public static LocalDate formatDate(String input){
DateTimeFormatter dtf = DateTimeFormatter.ofPattern( "yyyy-MM-dd");
public static LocalDate formatDate(String input) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate date = LocalDate.parse(input, dtf);
return date;
}
Expand All @@ -41,7 +47,7 @@ public static LocalDate formatDate(String input){
* @return formatted time.
*/
public static LocalTime formatTime(String input) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern( "HHmm");
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HHmm");
LocalTime time = LocalTime.parse(input, dtf);
return time;
}
Expand All @@ -52,7 +58,7 @@ public static LocalTime formatTime(String input) {
* @return date but as a String.
*/
public static String dateToString(LocalDate input) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern( "yyyy-MM-dd");
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
String date = input.format(dtf);
return date;
}
Expand All @@ -63,7 +69,7 @@ public static String dateToString(LocalDate input) {
* @return time but as a String.
*/
public static String timeToString(LocalTime input) {
DateTimeFormatter dtf = DateTimeFormatter.ofPattern( "HHmm");
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("HHmm");
String time = input.format(dtf);
return time;
}
Expand Down Expand Up @@ -144,7 +150,7 @@ public static Command parse(String input) throws DukeException {
} else if (command.equals("delete")) {
return new DeleteCommand(Integer.parseInt(inputSplit[1]));

} else if(command.equals("find")) {
} else if (command.equals("find")) {
return new FindCommand(inputSplit[1]);

} else {
Expand Down
21 changes: 10 additions & 11 deletions src/main/java/duke/functionality/Storage.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package duke.functionality;

import duke.task.Deadline;
import duke.task.Event;
import duke.task.Task;
import duke.task.Todo;

import java.util.Scanner;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

import duke.task.Deadline;
import duke.task.Event;
import duke.task.Task;
import duke.task.Todo;

/**
* Represents the Storage capabilities of the Duke project. A <code> Storage </code> object corresponds
Expand All @@ -25,7 +24,7 @@ public class Storage {
* @param pwd user's current working directory.
* @param path path to "/data/TaskData.txt".
*/
public Storage(String pwd, String path){
public Storage(String pwd, String path) {
Storage.pwd = pwd;
Storage.path = path;
}
Expand Down Expand Up @@ -110,21 +109,21 @@ public static String craftOutput(Task task) {
String output = "";
String doneIcon = task.getStatusIcon();
if (task instanceof Todo) {
if(doneIcon.equals("X")) {
if (doneIcon.equals("X")) {
output = "T|1|" + task.getDescription();
} else {
output = "T|0|" + task.getDescription();
}
} else if (task instanceof Deadline) {
if(doneIcon.equals("X")) {
if (doneIcon.equals("X")) {
output = "D|1|" + task.getDescription() + "|" + Parser.dateToString(((Deadline) task).getDate())
+ "|" + Parser.timeToString(((Deadline) task).getTime());
} else {
output = "D|0|" + task.getDescription() + "|" + Parser.dateToString(((Deadline) task).getDate())
+ "|" + Parser.timeToString(((Deadline) task).getTime());
}
} else if (task instanceof Event) {
if(doneIcon.equals("X")) {
if (doneIcon.equals("X")) {
output = "E|1|" + task.getDescription() + "|" + Parser.dateToString(((Event) task).getDate())
+ "|" + Parser.timeToString(((Event) task).getStartTime())
+ "|" + Parser.timeToString(((Event) task).getEndTime());
Expand Down
16 changes: 10 additions & 6 deletions src/main/java/duke/functionality/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public void deleteTask(int taskNum) {
* @param taskNum an indicator to the index of taskList.
*/
public void markTask(int taskNum) {
String message = "Nice! I've marked this task as done:\n" ;
String message = "Nice! I've marked this task as done:\n";
int actualTaskNum = taskNum - 1; //minus 1 as list index is from 0
Task task = taskList.get(actualTaskNum); // get the task from the array
task.setTaskDone();
Expand All @@ -60,11 +60,11 @@ public void unMarkTask(int taskNum) {
/**
* Returns nothing, but prints out all task in taskList.
*/
public void printList(){
public void printList() {
String message = "Here are the tasks in your list:";
System.out.println(message);

for(int i = 0; i < numOfTask; i++){
for (int i = 0; i < numOfTask; i++) {
String output = i + 1 + "." + taskList.get(i).toString();
System.out.println(output);
}
Expand All @@ -82,19 +82,23 @@ public void addToList(Task task) {
System.out.println(message + task.toString() + "\nNow you have " + numOfTask + " tasks in the list.");
}

/**
* Returns nothing, but prints all task that contains that matches the specified word.
* @param word keyword input from user
*/
public void findWord(String word) {
String message = "Here are the matching tasks in your list:\n";
System.out.print(message);
int counter = 1;
for(int i = 0; i < numOfTask; i++) {
for (int i = 0; i < numOfTask; i++) {
Task task = taskList.get(i);
if(task.getDescription().contains(word)) {
if (task.getDescription().contains(word)) {
String output = counter + "." + task;
counter++;
System.out.println(output);
}
}
if(counter == 1) {
if (counter == 1) {
System.out.println("OOPS!, there are no matching task with the word provided.");
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/duke/functionality/Ui.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package duke.functionality;

import duke.exception.BlankCommandException;

import java.util.Scanner;

import duke.exception.BlankCommandException;

/**
* Represents the User Interface of the Duke project. A <code> Ui </code> object corresponds
* to all user interface displays. Such as the messages.
*/
public class Ui {
private final String GREETING = "Hello! I'm TaskJamie\nWhat can i do for you?";
private final String ENDING = "Bye. Hope to see you again soon!";
private static final String GREETING = "Hello! I'm TaskJamie\nWhat can i do for you?";
private static final String ENDING = "Bye. Hope to see you again soon!";

/**
* Returns nothing, but prints out the greeting message of Duke TaskBot.
Expand All @@ -36,7 +36,9 @@ public void showError(String error) {
/**
* Returns nothing, but prints out the error messages when loading in the text file.
*/
public void showLoadingError(String error) { System.out.println(error); }
public void showLoadingError(String error) {
System.out.println(error);
}

/**
* Returns a full command gotten from user input.
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/duke/main/Duke.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import java.io.IOException;

import duke.command.Command;
import duke.exception.DukeException;
import duke.functionality.Parser;
import duke.functionality.Storage;
import duke.functionality.TaskList;
import duke.functionality.Ui;
import duke.exception.DukeException;

/**
* Represents the starting point of the Duke project. A <code> Duke </code> object corresponds
Expand Down Expand Up @@ -41,7 +41,7 @@ public Duke(String pwd, String filePath) {
public void run() {
this.ui.showGreeting();
boolean isExit = false;
while(!isExit) {
while (!isExit) {
try {
String fullCommand = ui.readCommand();
Command c = Parser.parse(fullCommand);
Expand All @@ -60,6 +60,6 @@ public void run() {
*/
public static void main(String[] args) {
String home = System.getProperty("user.home");
new Duke(home,"/data/TaskData.txt").run();
new Duke(home, "/data/TaskData.txt").run();
}
}
Loading

0 comments on commit ea3fce8

Please sign in to comment.