From a999708297674b41bbd89e71d924087675a6abc0 Mon Sep 17 00:00:00 2001 From: Justin Tay Date: Thu, 3 Nov 2016 22:02:23 +0800 Subject: [PATCH] Fix codacy error level problems (#196) * Fix: Avoid reassigning parameters such as 'endDateTime' * Fix: Avoid reassigning parameters such as 'endTime' * Fix: Avoid reassigning parameters such as 'args' * Fix: Use explicit scoping instead of the default package private level * Fix: Use explicit scoping instead of the default package private level --- src/main/java/seedu/agendum/logic/commands/AddCommand.java | 5 +++-- .../java/seedu/agendum/logic/commands/ScheduleCommand.java | 5 +++-- src/main/java/seedu/agendum/logic/parser/Parser.java | 4 ++-- src/main/java/seedu/agendum/ui/MainWindow.java | 2 +- src/main/java/seedu/agendum/ui/UiManager.java | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/main/java/seedu/agendum/logic/commands/AddCommand.java b/src/main/java/seedu/agendum/logic/commands/AddCommand.java index 67a86e5c8dd8..91c4fb9272ea 100644 --- a/src/main/java/seedu/agendum/logic/commands/AddCommand.java +++ b/src/main/java/seedu/agendum/logic/commands/AddCommand.java @@ -63,13 +63,14 @@ public AddCommand(String name, Optional deadlineDate) */ public AddCommand(String name, Optional startDateTime, Optional endDateTime) throws IllegalValueException { + Optional balancedEndDateTime = endDateTime; if (startDateTime.isPresent() && endDateTime.isPresent()) { - endDateTime = Optional.of(DateTimeUtils.balanceStartAndEndDateTime(startDateTime.get(), endDateTime.get())); + balancedEndDateTime = Optional.of(DateTimeUtils.balanceStartAndEndDateTime(startDateTime.get(), endDateTime.get())); } this.toAdd = new Task( new Name(name), startDateTime, - endDateTime + balancedEndDateTime ); } diff --git a/src/main/java/seedu/agendum/logic/commands/ScheduleCommand.java b/src/main/java/seedu/agendum/logic/commands/ScheduleCommand.java index ab5f90fb4ed3..6711743c9f21 100644 --- a/src/main/java/seedu/agendum/logic/commands/ScheduleCommand.java +++ b/src/main/java/seedu/agendum/logic/commands/ScheduleCommand.java @@ -37,12 +37,13 @@ public class ScheduleCommand extends Command { //@@author A0133367E public ScheduleCommand(int targetIndex, Optional startTime, Optional endTime) { + Optional balancedEndTime = endTime; if (startTime.isPresent() && endTime.isPresent()) { - endTime = Optional.of(DateTimeUtils.balanceStartAndEndDateTime(startTime.get(), endTime.get())); + balancedEndTime = Optional.of(DateTimeUtils.balanceStartAndEndDateTime(startTime.get(), endTime.get())); } this.targetIndex = targetIndex; this.newStartDateTime = startTime; - this.newEndDateTime = endTime; + this.newEndDateTime = balancedEndTime; } @Override diff --git a/src/main/java/seedu/agendum/logic/parser/Parser.java b/src/main/java/seedu/agendum/logic/parser/Parser.java index e1941b80dbc5..1739674e2cbe 100644 --- a/src/main/java/seedu/agendum/logic/parser/Parser.java +++ b/src/main/java/seedu/agendum/logic/parser/Parser.java @@ -392,9 +392,9 @@ private Set parseIndexes(String args) { return taskIds; } - args = args.replaceAll("[ ]+", ",").replaceAll(",+", ","); + String replacedArgs = args.replaceAll("[ ]+", ",").replaceAll(",+", ","); - String[] taskIdStrings = args.split(","); + String[] taskIdStrings = replacedArgs.split(","); for (String taskIdString : taskIdStrings) { if (taskIdString.matches("\\d+")) { taskIds.add(Integer.parseInt(taskIdString)); diff --git a/src/main/java/seedu/agendum/ui/MainWindow.java b/src/main/java/seedu/agendum/ui/MainWindow.java index 39b2f097932d..1443f13aa8f4 100644 --- a/src/main/java/seedu/agendum/ui/MainWindow.java +++ b/src/main/java/seedu/agendum/ui/MainWindow.java @@ -169,7 +169,7 @@ public void handle(KeyEvent evt) { /** * Loads the ui elements */ - void fillInnerParts() { + public void fillInnerParts() { upcomingTasksPanel = UpcomingTasksPanel.load(primaryStage, getUpcomingTasksPlaceHolder(), logic.getFilteredTaskList(), new UpcomingTasksPanel()); completedTasksPanel = CompletedTasksPanel.load(primaryStage, getCompletedTasksPlaceHolder(), diff --git a/src/main/java/seedu/agendum/ui/UiManager.java b/src/main/java/seedu/agendum/ui/UiManager.java index 57c4e93cbefb..4166ad0dfdde 100644 --- a/src/main/java/seedu/agendum/ui/UiManager.java +++ b/src/main/java/seedu/agendum/ui/UiManager.java @@ -74,7 +74,7 @@ private Image getImage(String imagePath) { return new Image(MainApp.class.getResourceAsStream(imagePath)); } - void showAlertDialogAndWait(Alert.AlertType type, String title, String headerText, String contentText) { + private void showAlertDialogAndWait(Alert.AlertType type, String title, String headerText, String contentText) { showAlertDialogAndWait(mainWindow.getPrimaryStage(), type, title, headerText, contentText); }