Skip to content

Commit

Permalink
Merge pull request #9 from jasonqiu212/branch-A-Checkstyle
Browse files Browse the repository at this point in the history
Add checkstyle
  • Loading branch information
jasonqiu212 committed Sep 15, 2022
2 parents 0c2d9ba + 2a88332 commit 25df4b7
Show file tree
Hide file tree
Showing 16 changed files with 508 additions and 41 deletions.
5 changes: 5 additions & 0 deletions build.gradle
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'application'
id 'com.github.johnrengelman.shadow' version '5.1.0'
id 'checkstyle'
}

repositories {
Expand Down Expand Up @@ -51,6 +52,10 @@ shadowJar {
archiveClassifier = null
}

checkstyle {
toolVersion = '10.2'
}

run {
standardInput = System.in
}
435 changes: 435 additions & 0 deletions config/checkstyle/checkstyle.xml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions config/checkstyle/suppressions.xml
@@ -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>
4 changes: 2 additions & 2 deletions src/main/java/cheese/command/FindCommand.java
@@ -1,12 +1,12 @@
package cheese.command;

import java.util.ArrayList;

import cheese.data.TaskList;
import cheese.storage.Storage;
import cheese.task.Task;
import cheese.ui.Response;

import java.util.ArrayList;

/**
* Represents a user command to find a task by searching for a keyword.
*/
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/cheese/data/TaskList.java
@@ -1,11 +1,11 @@
package cheese.data;

import java.util.ArrayList;

import cheese.exception.CheeseException;
import cheese.parser.Parser;
import cheese.task.Task;

import java.util.ArrayList;

/**
* Represents a list of tasks that supports adding tasks, deleting tasks, and marking tasks as
* complete/incomplete.
Expand Down Expand Up @@ -83,6 +83,13 @@ public Task markTaskAsNotDone(int taskIndex) throws CheeseException {
return task;
}

/**
* Delays task deadline by 1 day.
*
* @param taskIndex Index of task to snooze.
* @return Task that is snoozed.
* @throws CheeseException If index is not in the range of task list.
*/
public Task snoozeTask(int taskIndex) throws CheeseException {
Task task = getTask(taskIndex);
task.snooze();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/cheese/storage/Storage.java
@@ -1,17 +1,17 @@
package cheese.storage;

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

import cheese.data.TaskList;
import cheese.exception.CheeseException;
import cheese.task.Deadline;
import cheese.task.Event;
import cheese.task.Task;
import cheese.task.Todo;

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

/**
* Represents a storage that interacts with <code>Cheese</code>'s save file.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cheese/task/Deadline.java
@@ -1,10 +1,10 @@
package cheese.task;

import java.time.LocalDateTime;

import cheese.storage.Storage;
import cheese.utils.DateTimeUtils;

import java.time.LocalDateTime;

/**
* Represents a deadline with description, complete/incomplete status, and deadline.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cheese/task/Event.java
@@ -1,10 +1,10 @@
package cheese.task;

import java.time.LocalDateTime;

import cheese.storage.Storage;
import cheese.utils.DateTimeUtils;

import java.time.LocalDateTime;

/**
* Represents an event with description, complete/incomplete status, and time interval.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cheese/task/Task.java
Expand Up @@ -12,8 +12,6 @@ public abstract class Task {
/** Whether task is complete or incomplete. */
private boolean isDone;

public abstract void snooze();

/**
* Constructs an instance of <code>Task</code>.
*
Expand All @@ -35,6 +33,8 @@ protected Task(boolean isDone, String description) {
this.description = description;
}

public abstract void snooze();

public void setDone() {
isDone = true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/cheese/ui/Main.java
@@ -1,5 +1,7 @@
package cheese.ui;

import java.io.IOException;

import cheese.Cheese;
import cheese.ui.controller.MainWindow;
import javafx.application.Application;
Expand All @@ -8,8 +10,6 @@
import javafx.scene.layout.AnchorPane;
import javafx.stage.Stage;

import java.io.IOException;

/**
* Represents a GUI for Cheese using FXML.
*/
Expand Down
21 changes: 14 additions & 7 deletions src/main/java/cheese/ui/Response.java
@@ -1,10 +1,10 @@
package cheese.ui;

import java.util.ArrayList;

import cheese.data.TaskList;
import cheese.task.Task;

import java.util.ArrayList;

/**
* Contains the responses given by Cheese.
*/
Expand All @@ -15,7 +15,8 @@ public class Response {
* @return Message to display to welcome user.
*/
public static String getWelcomeMessage() {
return "Woof! I'm Cheese, your puppy assistant.\n" + "What can I do for you?";
return "Woof! I'm Cheese, your puppy assistant.\n"
+ "What can I do for you?";
}

/**
Expand All @@ -26,7 +27,9 @@ public static String getWelcomeMessage() {
* @return Message to display after adding task.
*/
public static String getAddTaskMessage(Task addedTask, int newListSize) {
return "Gotcha! I have a paw-fect memory!\n" + " " + addedTask + "\n" + "You have " + newListSize + " task(s) in the list.";
return "Gotcha! I have a paw-fect memory!\n"
+ " " + addedTask + "\n"
+ "You have " + newListSize + " task(s) in the list.";
}

/**
Expand All @@ -37,7 +40,9 @@ public static String getAddTaskMessage(Task addedTask, int newListSize) {
* @return Message to display after deleting task.
*/
public static String getDeleteTaskMessage(Task deletedTask, int remainingListSize) {
return "Gotcha master! I'll forget about this task!\n" + " " + deletedTask + "\n" + "You have " + remainingListSize + " task(s) remaining.";
return "Gotcha master! I'll forget about this task!\n"
+ " " + deletedTask + "\n"
+ "You have " + remainingListSize + " task(s) remaining.";
}

/**
Expand All @@ -57,7 +62,8 @@ public static String getMarkTaskAsDoneMessage(Task taskDone) {
* @return Message to display after marking task as incomplete.
*/
public static String getMarkTaskAsNotDoneMessage(Task taskNotDone) {
return "Okay master, I've marked this task as incomplete.\n" + " " + taskNotDone;
return "Okay master, I've marked this task as incomplete.\n"
+ " " + taskNotDone;
}

/**
Expand All @@ -67,7 +73,8 @@ public static String getMarkTaskAsNotDoneMessage(Task taskNotDone) {
* @return Message to display after snoozing task.
*/
public static String getSnoozeTaskMessage(Task taskSnoozed) {
return "Gotcha! I've snoozed this task by 1 day. Wanna go for a walk now??\n" + " " + taskSnoozed;
return "Gotcha! I've snoozed this task by 1 day. Wanna go for a walk now??\n"
+ " " + taskSnoozed;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/cheese/ui/controller/DialogBox.java
@@ -1,5 +1,8 @@
package cheese.ui.controller;

import java.io.IOException;
import java.util.Collections;

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
Expand All @@ -11,9 +14,6 @@
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;

import java.io.IOException;
import java.util.Collections;

/**
* Controls dialog box consisting of an ImageView to represent the speaker's face and a label
* containing text from the speaker.
Expand Down
22 changes: 11 additions & 11 deletions src/main/java/cheese/ui/controller/MainWindow.java
Expand Up @@ -14,6 +14,14 @@
*/
public class MainWindow extends AnchorPane {

/** Image to represent the user. */
private Image userImage =
new Image(this.getClass().getResourceAsStream("/images/User.png"));

/** Image to represent Cheese. */
private Image cheeseImage =
new Image(this.getClass().getResourceAsStream("/images/Cheese.png"));

/** Scroll pane to contain the chat. */
@FXML
private ScrollPane scrollPane;
Expand All @@ -29,22 +37,14 @@ public class MainWindow extends AnchorPane {
/** An instance of <code>Cheese</code>. */
private Cheese cheese;

/** Image to represent the user. */
private final Image IMAGE_USER =
new Image(this.getClass().getResourceAsStream("/images/User.png"));

/** Image to represent Cheese. */
private final Image IMAGE_CHEESE =
new Image(this.getClass().getResourceAsStream("/images/Cheese.png"));

/**
* Initializes the main window.
*/
@FXML
public void initialize() {
scrollPane.vvalueProperty().bind(dialogContainer.heightProperty());
this.dialogContainer.getChildren()
.add(DialogBox.getCheeseDialog(Response.getWelcomeMessage(), IMAGE_CHEESE));
.add(DialogBox.getCheeseDialog(Response.getWelcomeMessage(), cheeseImage));
}

/**
Expand All @@ -64,8 +64,8 @@ public void setCheese(Cheese c) {
private void handleUserInput() {
String input = userInput.getText();
String response = cheese.getResponse(input);
dialogContainer.getChildren().addAll(DialogBox.getUserDialog(input, IMAGE_USER),
DialogBox.getCheeseDialog(response, IMAGE_CHEESE));
dialogContainer.getChildren().addAll(DialogBox.getUserDialog(input, userImage),
DialogBox.getCheeseDialog(response, cheeseImage));
userInput.clear();
}
}
6 changes: 3 additions & 3 deletions src/main/java/cheese/utils/DateTimeUtils.java
Expand Up @@ -17,7 +17,7 @@ public class DateTimeUtils {

/**
* Parses string to date time using input formatter.
*
*
* @param dateTime String to parse.
* @return Parsed date time.
*/
Expand All @@ -27,7 +27,7 @@ public static LocalDateTime parseString(String dateTime) {

/**
* Parses date time to string using output formatter.
*
*
* @param dateTime Date time to parse.
* @return Parsed string representing date time.
*/
Expand All @@ -37,7 +37,7 @@ public static String parseLocalDateTimeToOutput(LocalDateTime dateTime) {

/**
* Parses date time to string using input formatter.
*
*
* @param dateTime Date time to parse.
* @return Parsed string representing date time.
*/
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/cheese/data/TaskListTest.java
@@ -1,7 +1,9 @@
package cheese.data;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

import cheese.task.Deadline;
import cheese.task.Event;
import cheese.task.Todo;
Expand Down
1 change: 1 addition & 0 deletions src/test/java/cheese/task/TodoTest.java
@@ -1,6 +1,7 @@
package cheese.task;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class TodoTest {
Expand Down

0 comments on commit 25df4b7

Please sign in to comment.