Skip to content

Commit

Permalink
Merge pull request #162 from Lin-Shuang-Shuang/branch-CodeQuality
Browse files Browse the repository at this point in the history
Improve code quality
  • Loading branch information
Lin-Shuang-Shuang authored Apr 14, 2024
2 parents 1e719f5 + b8275e2 commit 0165212
Show file tree
Hide file tree
Showing 44 changed files with 230 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import seedu.address.model.project.Project;

/**
* Adds a project to the DevPlanPro.
* Adds a comment to the DevPlanPro.
*/
public class AddCommentCommand extends Command {

Expand All @@ -36,7 +36,7 @@ public class AddCommentCommand extends Command {
private Comment comment;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an AddCommentCommand to add to the specified {@code Project}
*/
public AddCommentCommand(Project project, Member member, String comment) {
requireNonNull(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import seedu.address.model.project.Project;

/**
* Adds a task to a project.
* Adds a person to a project.
*/
public class AddPersonCommand extends Command {

Expand All @@ -28,7 +28,7 @@ public class AddPersonCommand extends Command {
private final Member member;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an AddPersonCommand to add the specified {@code Project}
*/
public AddPersonCommand(Member member, Project project) {
requireNonNull(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class AddProjectCommand extends Command {
private final Project toAdd;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an AddProjectCommand to add the specified {@code Project}
*/
public AddProjectCommand(Project project) {
requireNonNull(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class AddTaskCommand extends Command {
private final Project taskProject;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an AddTaskCommand to add the specified {@code Project}
*/
public AddTaskCommand(Task task, Project taskProject) {
requireNonNull(task);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class AssignPersonCommand extends Command {
private final Member member;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an AssignPersonCommand to add the specified {@code Task}
*/
public AssignPersonCommand(String member, Task task, Project project) {
requireNonNull(task);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import seedu.address.model.project.Project;

/**
* Adds a task to a project.
* Assign a team of members to a project.
*/
public class AssignTeamCommand extends Command {

Expand All @@ -32,7 +32,7 @@ public class AssignTeamCommand extends Command {
private final List<Member> team;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an AssignTeamCommand to add the specified {@code Project}
*/
public AssignTeamCommand(List<String> team, Project project) {
requireNonNull(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class DeletePersonCommand extends Command {
private final Project memberProject;

/**
* Creates a DeleteTaskCommand to delete the specified task in a project
* Creates a DeletePersonCommand to delete the specified task in a Project
*/
public DeletePersonCommand(Member member, Project memberProject) {
requireNonNull(member);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import seedu.address.model.tag.Tag;

/**
* Edits the details of an existing person in the address book.
* Edits the details of an existing project in the DevPlanPro.
*/
public class EditCommand extends Command {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


/**
* Edits the name of an existing project in the address book.
* Edits the name of an existing project in the DevPlanPro.
*/
public class EditProjectNameCommand extends RenameCommand {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package seedu.address.logic.commands;

import static java.util.Objects.requireNonNull;
import static seedu.address.logic.commands.AddTaskCommand.MESSAGE_DUPLICATE_TASK;

import seedu.address.commons.util.ToStringBuilder;
import seedu.address.logic.Messages;
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.person.Name;
import seedu.address.model.person.NameEqualsPredicate;
import seedu.address.model.project.Project;
import seedu.address.model.project.Task;

Expand All @@ -30,7 +32,7 @@ public class EditTaskNameCommand extends RenameCommand {
private final Task targetTask;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an EditTaskNameCommand to add the specified {@code Task}
*/
public EditTaskNameCommand(Name newName, Project currentProject, Task currentTask) {
requireNonNull(newName);
Expand All @@ -57,8 +59,18 @@ public CommandResult execute(Model model) throws CommandException {
Messages.format(targetTask),
Messages.format(targetPerson)));

Check warning on line 60 in src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java#L59-L60

Added lines #L59 - L60 were not covered by tests
}
Task duplicateTask = new Task(changeTo.fullName);

Check warning on line 62 in src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java#L62

Added line #L62 was not covered by tests
if (targetPerson.hasTask(duplicateTask)) {
throw new CommandException(String.format(

Check warning on line 64 in src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java#L64

Added line #L64 was not covered by tests
MESSAGE_DUPLICATE_TASK,
Messages.format(duplicateTask),
Messages.format(targetPerson)));

Check warning on line 67 in src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java#L66-L67

Added lines #L66 - L67 were not covered by tests
}
Task toBeChanged = targetPerson.findTask(targetTask.getName());
toBeChanged.setName(changeTo);
model.updateCurrentProject(

Check warning on line 71 in src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java#L69-L71

Added lines #L69 - L71 were not covered by tests
new NameEqualsPredicate(
model.getCurrentProject().get(0).getName().fullName));
return new CommandResult(String.format(

Check warning on line 74 in src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/EditTaskNameCommand.java#L73-L74

Added lines #L73 - L74 were not covered by tests
MESSAGE_SUCCESS,
Messages.format(targetTask),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SetDeadlineProjectCommand extends SetDeadlineCommand {
private final String datePattern = "\\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\b \\d{1,2} \\d{4}\\b";

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an SetDeadlineProjectCommand to add the specified {@code Project}
*/
public SetDeadlineProjectCommand(String deadline, Project project) {
requireNonNull(project);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class SetDeadlineTaskCommand extends SetDeadlineCommand {
private final String datePattern = "\\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\b \\d{1,2} \\d{4}\\b";

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an SetDeadlineTaskCommand to add the specified {@code Task}
*/
public SetDeadlineTaskCommand(String deadline, Task task, Project project) {
requireNonNull(task);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class SetProjectCategoryCommand extends Command {
private final String category;

/**
* Creates an SetProjectCategoryCommand to add the specified {@code project}
* Creates an SetProjectCategoryCommand to add the specified {@code Project}
*/

public SetProjectCategoryCommand(String categoryName, Project project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import seedu.address.model.project.Project;

/**
* Adds a task to a project.
* Set a status to a project.
*/
public class SetProjectStatusCommand extends SetStatusCommand {

Expand All @@ -25,7 +25,7 @@ public class SetProjectStatusCommand extends SetStatusCommand {
private final Project project;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an SetProjectStatusCommand to add the specified {@code Project}
*/
public SetProjectStatusCommand(String status, Project project) {
super(status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import seedu.address.commons.util.ToStringBuilder;

/**
* Adds a status to a task.
* Adds a status to a task or project.
*/
public abstract class SetStatusCommand extends Command {

Expand All @@ -16,7 +16,7 @@ public abstract class SetStatusCommand extends Command {
private final String status;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an SetStatusCommand
*/
public SetStatusCommand(String status) {
requireNonNull(status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import seedu.address.model.project.Task;

/**
* Adds a task to a project.
* Set a status to a task in a project.
*/
public class SetTaskStatusCommand extends SetStatusCommand {

Expand All @@ -28,7 +28,7 @@ public class SetTaskStatusCommand extends SetStatusCommand {
private final Project project;

/**
* Creates an AddCommand to add the specified {@code Person}
* Creates an SetTaskStatusCommand to add the specified {@code Task}
*/
public SetTaskStatusCommand(String status, Task task, Project project) {
super(status);
Expand All @@ -41,36 +41,29 @@ public SetTaskStatusCommand(String status, Task task, Project project) {
@Override
public CommandResult execute(Model model) throws CommandException {
requireNonNull(model);

if (!model.hasProject(project)) {
throw new CommandException(String.format(

Check warning on line 45 in src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java#L45

Added line #L45 was not covered by tests
MESSAGE_PROJECT_NOT_FOUND,
Messages.format(project)));

Check warning on line 47 in src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java#L47

Added line #L47 was not covered by tests
}

Project statusProject = model.findProject(project.getName());

Check warning on line 49 in src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java#L49

Added line #L49 was not covered by tests

if (!statusProject.hasTask(task)) {
throw new CommandException(String.format(

Check warning on line 51 in src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java#L51

Added line #L51 was not covered by tests
MESSAGE_TASK_NOT_FOUND,
Messages.format(task),
Messages.format(project)));

Check warning on line 54 in src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java#L53-L54

Added lines #L53 - L54 were not covered by tests
}

Task statusTask = statusProject.findTask(task.getName());
String resultString = "";

Check warning on line 57 in src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java#L56-L57

Added lines #L56 - L57 were not covered by tests

if (isCompleted()) {
statusTask.setComplete();
resultString = String.format(MESSAGE_SUCCESS, Messages.format(statusTask), "complete");

Check warning on line 60 in src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java#L59-L60

Added lines #L59 - L60 were not covered by tests

} else if (isIncompleted()) {
statusTask.setIncomplete();
resultString = String.format(MESSAGE_SUCCESS, Messages.format(statusTask), "incomplete");

Check warning on line 63 in src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java#L62-L63

Added lines #L62 - L63 were not covered by tests
} else {
throw new CommandException(String.format(MESSAGE_WRONG_FORMAT_STATUS));

Check warning on line 65 in src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java#L65

Added line #L65 was not covered by tests
}

model.updateCurrentProject(

Check warning on line 67 in src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/commands/SetTaskStatusCommand.java#L67

Added line #L67 was not covered by tests
new NameEqualsPredicate(
model.getCurrentProject().get(0).getName().fullName));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,19 @@


/**
* Parses input arguments and creates a new AddProjectCommand object
* Parses input arguments and creates a new AddCommentCommand object
*/
public class AddCommentCommandParser implements Parser<AddCommentCommand> {

/**
* Parses the given {@code String} of arguments in the context of the AddProjectCommand
* and returns an AddProjectCommand object for execution.
* Parses the given {@code String} of arguments in the context of the AddCommentCommand
* and returns an AddCommentCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public AddCommentCommand parse(String args) throws ParseException {
try {
if (!args.contains(" /from ")) { // Check if the input correctly uses "/to"
throw new ParseException(String.format(
MESSAGE_INVALID_COMMAND_FORMAT,
AddCommentCommand.MESSAGE_USAGE));
}
if (!args.contains(" /to ")) { // Check if the input correctly uses "/to"
if (!args.contains(" /from ") || !args.contains(" /to ")) {
// Check if the input correctly uses "/to" or "/from"
throw new ParseException(String.format(
MESSAGE_INVALID_COMMAND_FORMAT,
AddCommentCommand.MESSAGE_USAGE));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import seedu.address.model.project.Project;

/**
* Parses input arguments and creates a new AddTaskCommand object
* Parses input arguments and creates a new AddPersonCommand object
*/
public class AddPersonCommandParser implements Parser<AddPersonCommand> {

/**
* Parses the given {@code String} of arguments in the context of the AddTaskCommand
* and returns an AddTaskCommand object for execution.
* Parses the given {@code String} of arguments in the context of the AddPersonCommand
* and returns an AddPersonCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public AddPersonCommand parse(String args) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@


/**
* Parses input arguments and creates a new AddCommand object
* Parses input arguments and creates a new AssignPersonCommand object
*/
public class AssignPersonCommandParser implements Parser<AssignPersonCommand> {

/**
* Parses the given {@code String} of arguments in the context of the AddCommand
* and returns an AddCommand object for execution.
* Parses the given {@code String} of arguments in the context of the AssignPersonCommand
* and returns an AssignPersonCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public AssignPersonCommand parse(String args) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@


/**
* Parses input arguments and creates a new AddCommand object
* Parses input arguments and creates a new AssignTeamCommand object
*/
public class AssignTeamCommandParser implements Parser<AssignTeamCommand> {

/**
* Parses the given {@code String} of arguments in the context of the AddCommand
* and returns an AddCommand object for execution.
* Parses the given {@code String} of arguments in the context of the AssignTeamCommand
* and returns an AssignTeamCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public AssignTeamCommand parse(String args) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import seedu.address.model.project.Project;

/**
* Parses input arguments and creates a new DeleteCommand object
* Parses input arguments and creates a new DeletePersonCommand object
*/
public class DeletePersonCommandParser implements Parser<DeletePersonCommand> {

/**
* Parses the given {@code String} of arguments in the context of the DeleteCommand
* and returns a DeleteCommand object for execution.
* Parses the given {@code String} of arguments in the context of the DeletePersonCommand
* and returns a DeletePersonCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public DeletePersonCommand parse(String args) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
public class DeleteProjectCommandParser implements Parser<DeleteProjectCommand> {

/**
* Parses the given {@code String} of arguments in the context of the DeleteCommand
* and returns a DeleteCommand object for execution.
* Parses the given {@code String} of arguments in the context of the DeleteProjectCommand
* and returns a DeleteProjectCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public DeleteProjectCommand parse(String args) throws ParseException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import seedu.address.model.person.CategoryEqualsPredicate;

/**
* Parses input arguments and creates a new FindCommand object
* Parses input arguments and creates a new FilterCategoryCommand object
*/
public class FilterCategoryCommandParser implements Parser<FilterCategoryCommand> {

Check warning on line 12 in src/main/java/seedu/address/logic/parser/FilterCategoryCommandParser.java

View check run for this annotation

Codecov / codecov/patch

src/main/java/seedu/address/logic/parser/FilterCategoryCommandParser.java#L12

Added line #L12 was not covered by tests

/**
* Parses the given {@code String} of arguments in the context of the FindCommand
* and returns a FindCommand object for execution.
* Parses the given {@code String} of arguments in the context of the FilterCategoryCommand
* and returns a FilterCategoryCommand object for execution.
* @throws ParseException if the user input does not conform the expected format
*/
public FilterCategoryCommand parse(String args) throws ParseException {
Expand Down
Loading

0 comments on commit 0165212

Please sign in to comment.