Skip to content

Commit

Permalink
fix codacy suggestions (#112)
Browse files Browse the repository at this point in the history
* remove unused imports and use .equals instead of ==

* Remove unused code

* remove unwanted comments

* Fixed a regression

* Fix another regression

* Fix failing tests

* underscores
  • Loading branch information
rachx authored and burnflare committed Oct 29, 2016
1 parent 0b5b116 commit 332d47c
Show file tree
Hide file tree
Showing 28 changed files with 137 additions and 156 deletions.
4 changes: 2 additions & 2 deletions src/main/java/seedu/agendum/MainApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void init() throws Exception {

model = initModelManager(storage, userPrefs);

logic = new LogicManager(model, storage);
logic = new LogicManager(model);

ui = new UiManager(logic, config, userPrefs);

Expand Down Expand Up @@ -85,7 +85,7 @@ private Model initModelManager(Storage storage, UserPrefs userPrefs) {
initialData = new ToDoList();
}

return new ModelManager(initialData, userPrefs);
return new ModelManager(initialData);
}

private void initLogging(Config config) {
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/seedu/agendum/commons/core/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ public class Config {
private String toDoListFilePath = DEFAULT_SAVE_LOCATION;
private String toDoListName = "MyToDoList";

public Config() {
}

public String getAppTitle() {
return appTitle;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
public class IncorrectCommandAttemptedEvent extends BaseEvent {

public IncorrectCommandAttemptedEvent(Command command) {}
public IncorrectCommandAttemptedEvent() {}

@Override
public String toString() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/agendum/logic/LogicManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class LogicManager extends ComponentManager implements Logic {
private final Model model;
private final Parser parser;

public LogicManager(Model model, Storage storage) {
public LogicManager(Model model) {
this.model = model;
this.parser = new Parser();
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/seedu/agendum/logic/commands/AddCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
import seedu.agendum.model.task.*;

import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.Optional;
import java.util.Set;

/**
* Adds a task to the to do list.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/agendum/logic/commands/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ public void setData(Model model) {
* Raises an event to indicate an attempt to execute an incorrect command
*/
protected void indicateAttemptToExecuteIncorrectCommand() {
EventsCenter.getInstance().post(new IncorrectCommandAttemptedEvent(this));
EventsCenter.getInstance().post(new IncorrectCommandAttemptedEvent());
}
}
1 change: 0 additions & 1 deletion src/main/java/seedu/agendum/logic/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class Parser {
private static final String[] TIME_TOKENS = new String[] { ARGS_FROM, ARGS_TO, ARGS_BY };

//@@author
public Parser() {}

/**
* Parses user input into command for execution.
Expand Down
1 change: 0 additions & 1 deletion src/main/java/seedu/agendum/model/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import seedu.agendum.model.task.Task;
import seedu.agendum.model.task.UniqueTaskList;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/agendum/model/ModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ModelManager() {
this(new ToDoList(), new UserPrefs());
}

public ModelManager(ReadOnlyToDoList initialData, UserPrefs userPrefs) {
public ModelManager(ReadOnlyToDoList initialData) {
toDoList = new ToDoList(initialData);
filteredTasks = new FilteredList<>(toDoList.getTasks());
sortedTasks = filteredTasks.sorted();
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/seedu/agendum/model/ToDoList.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package seedu.agendum.model;

import javafx.collections.ObservableList;
import seedu.agendum.model.task.Name;
import seedu.agendum.model.task.ReadOnlyTask;
import seedu.agendum.model.task.Task;
import seedu.agendum.model.task.UniqueTaskList;

import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/seedu/agendum/model/task/UniqueTaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/
public class UniqueTaskList implements Iterable<Task> {
private static final Logger logger = LogsCenter.getLogger(UniqueTaskList.class);
private final ObservableList<Task> internalList = FXCollections.observableArrayList();

/**
* Signals that an operation would have violated the 'no duplicates' property of the list.
Expand All @@ -35,8 +36,6 @@ protected DuplicateTaskException() {
*/
public static class TaskNotFoundException extends Exception {}

private final ObservableList<Task> internalList = FXCollections.observableArrayList();

/**
* Constructs empty TaskList.
*/
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/seedu/agendum/ui/AllTasksPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ public void scrollTo(int index) {

class allTasksListViewCell extends ListCell<ReadOnlyTask> {

public allTasksListViewCell() {
}

@Override
protected void updateItem(ReadOnlyTask task, boolean empty) {
super.updateItem(task, empty);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/agendum/ui/CommandBoxHistory.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String getPreviousCommand() {
if(!iterator.hasNext()) {
lastQuery = EMPTY_QUERY;
return EMPTY_COMMAND;
} else if(lastQuery == NEXT_QUERY) {
} else if(lastQuery.equals(NEXT_QUERY)) {
iterator.next();
}
lastQuery = PREVIOUS_QUERY;
Expand All @@ -57,7 +57,7 @@ public String getNextCommand() {
if (!iterator.hasPrevious()) {
lastQuery = EMPTY_QUERY;
return EMPTY_COMMAND;
} else if(lastQuery == PREVIOUS_QUERY) {
} else if(lastQuery.equals(PREVIOUS_QUERY)) {
iterator.previous();
}
lastQuery = NEXT_QUERY;
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/seedu/agendum/ui/CompletedTasksPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
* Panel contains the list of completed tasks
*/
public class CompletedTasksPanel extends UiPart {
private final Logger logger = LogsCenter.getLogger(CompletedTasksPanel.class);
private static final String FXML = "CompletedTasksPanel.fxml";
private AnchorPane panel;
private AnchorPane placeHolderPane;
Expand Down Expand Up @@ -78,9 +77,6 @@ public void scrollTo(int index) {

class completedTasksListViewCell extends ListCell<ReadOnlyTask> {

public completedTasksListViewCell() {
}

@Override
protected void updateItem(ReadOnlyTask task, boolean empty) {
super.updateItem(task, empty);
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/seedu/agendum/ui/OtherTasksPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@
* Panel contains the list of other tasks
*/
public class OtherTasksPanel extends UiPart {
private final Logger logger = LogsCenter.getLogger(OtherTasksPanel.class);
private static final String FXML = "OtherTasksPanel.fxml";
private AnchorPane panel;
private AnchorPane placeHolderPane;

@FXML
private ListView<ReadOnlyTask> otherTasksListView;

public OtherTasksPanel() {
super();
}

@Override
public void setNode(Node node) {
panel = (AnchorPane) node;
Expand Down Expand Up @@ -77,9 +72,6 @@ public void scrollTo(int index) {

class otherTasksListViewCell extends ListCell<ReadOnlyTask> {

public otherTasksListViewCell() {
}

@Override
protected void updateItem(ReadOnlyTask task, boolean empty) {
super.updateItem(task, empty);
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/seedu/agendum/ui/UiPart.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ public abstract class UiPart {
*/
Stage primaryStage;

public UiPart(){

}

/**
* Raises the event via {@link EventsCenter#post(BaseEvent)}
* @param event
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/guitests/CommandBoxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@
public class CommandBoxTest extends ToDoListGuiTest {

@Test
public void commandBox_commandSucceeds_textCleared() {
public void commandBoxCommandSucceedsTextCleared() {
commandBox.runCommand(td.benson.getAddCommand());
assertEquals(commandBox.getCommandInput(), "");
}

@Test
public void commandBox_commandFails_textStays(){
public void commandBoxCommandFailsTextStays(){
commandBox.runCommand("invalid command");
assertEquals(commandBox.getCommandInput(), "invalid command");
//TODO: confirm the text box color turns to red
}

@Test
public void commandBox_CommandHistory_notExists() {
public void commandBoxCommandHistoryNotExists() {
commandBox.scrollToPreviousCommand();
assertEquals(commandBox.getCommandInput(), "");
commandBox.scrollToPreviousCommand();
Expand All @@ -31,7 +31,7 @@ public void commandBox_CommandHistory_notExists() {
}

@Test
public void commandBox_CommandHistory_exists() {
public void commandBoxCommandHistoryExists() {
String addCommand = "add commandhistorytestevent";
commandBox.runCommand(addCommand);
commandBox.runCommand("undo");
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/seedu/agendum/commons/core/VersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ public class VersionTest {
public ExpectedException thrown = ExpectedException.none();

@Test
public void versionParsing_acceptableVersionString_parsedVersionCorrectly() {
public void versionParsingAcceptableVersionStringParsedVersionCorrectly() {
verifyVersionParsedCorrectly("V0.0.0ea", 0, 0, 0, true);
verifyVersionParsedCorrectly("V3.10.2", 3, 10, 2, false);
verifyVersionParsedCorrectly("V100.100.100ea", 100, 100, 100, true);
}

@Test
public void versionParsing_wrongVersionString_throwIllegalArgumentException() {
public void versionParsingWrongVersionStringThrowIllegalArgumentException() {
thrown.expect(IllegalArgumentException.class);
Version.fromString("This is not a version string");
}

@Test
public void versionConstructor_correctParameter_valueAsExpected() {
public void versionConstructorCorrectParameterValueAsExpected() {
Version version = new Version(19, 10, 20, true);

assertEquals(19, version.getMajor());
Expand All @@ -35,7 +35,7 @@ public void versionConstructor_correctParameter_valueAsExpected() {
}

@Test
public void versionToString_validVersion_correctStringRepresentation() {
public void versionToStringValidVersionCorrectStringRepresentation() {
// boundary at 0
Version version = new Version(0, 0, 0, true);
assertEquals("V0.0.0ea", version.toString());
Expand All @@ -50,7 +50,7 @@ public void versionToString_validVersion_correctStringRepresentation() {
}

@Test
public void versionComparable_validVersion_compareToIsCorrect() {
public void versionComparableValidVersionCompareToIsCorrect() {
Version one, another;

// Tests equality
Expand Down Expand Up @@ -109,7 +109,7 @@ public void versionComparable_validVersion_compareToIsCorrect() {
}

@Test
public void versionComparable_validVersion_hashCodeIsCorrect() {
public void versionComparableValidVersionHashCodeIsCorrect() {
Version version = new Version(100, 100, 100, true);
assertEquals(100100100, version.hashCode());

Expand All @@ -118,7 +118,7 @@ public void versionComparable_validVersion_hashCodeIsCorrect() {
}

@Test
public void versionComparable_validVersion_equalIsCorrect() {
public void versionComparableValidVersionEqualIsCorrect() {
Version one, another;

one = new Version(0, 0, 0, false);
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/agendum/commons/util/AppUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ public class AppUtilTest {


@Test
public void getImage_exitingImage(){
public void getImageExitingImage(){
assertNotNull(AppUtil.getImage("/images/agendum_icon.png"));
}


@Test
public void getImage_nullGiven_assertionError(){
public void getImageNullGivenAssertionError(){
thrown.expect(AssertionError.class);
AppUtil.getImage(null);
}
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/seedu/agendum/commons/util/ConfigUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ public class ConfigUtilTest {
public TemporaryFolder testFolder = new TemporaryFolder();

@Test
public void read_null_assertionFailure() throws DataConversionException {
public void readNullAssertionFailure() throws DataConversionException {
thrown.expect(AssertionError.class);
read(null);
}

@Test
public void read_missingFile_emptyResult() throws DataConversionException {
public void readMissingFileEmptyResult() throws DataConversionException {
assertFalse(read("NonExistentFile.json").isPresent());
}

@Test
public void read_notJasonFormat_exceptionThrown() throws DataConversionException {
public void readNotJasonFormatExceptionThrown() throws DataConversionException {

thrown.expect(DataConversionException.class);
read("NotJasonFormatConfig.json");
Expand All @@ -49,7 +49,7 @@ public void read_notJasonFormat_exceptionThrown() throws DataConversionException
}

@Test
public void read_fileInOrder_successfullyRead() throws DataConversionException {
public void readFileInOrderSuccessfullyRead() throws DataConversionException {

Config expected = getTypicalConfig();

Expand All @@ -58,13 +58,13 @@ public void read_fileInOrder_successfullyRead() throws DataConversionException {
}

@Test
public void read_valuesMissingFromFile_defaultValuesUsed() throws DataConversionException {
public void readValuesMissingFromFileDefaultValuesUsed() throws DataConversionException {
Config actual = read("EmptyConfig.json").get();
assertEquals(new Config(), actual);
}

@Test
public void read_extraValuesInFile_extraValuesIgnored() throws DataConversionException {
public void readExtraValuesInFileExtraValuesIgnored() throws DataConversionException {
Config expected = getTypicalConfig();
Config actual = read("ExtraValuesConfig.json").get();

Expand All @@ -87,19 +87,19 @@ private Optional<Config> read(String configFileInTestDataFolder) throws DataConv
}

@Test
public void save_nullConfig_assertionFailure() throws IOException {
public void saveNullConfigAssertionFailure() throws IOException {
thrown.expect(AssertionError.class);
save(null, "SomeFile.json");
}

@Test
public void save_nullFile_assertionFailure() throws IOException {
public void saveNullFileAssertionFailure() throws IOException {
thrown.expect(AssertionError.class);
save(new Config(), null);
}

@Test
public void saveConfig_allInOrder_success() throws DataConversionException, IOException {
public void saveConfigAllInOrderSuccess() throws DataConversionException, IOException {
Config original = getTypicalConfig();

String configFilePath = testFolder.getRoot() + File.separator + "TempConfig.json";
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/agendum/commons/util/StringUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ public void isUnsignedPositiveInteger() {
}

@Test
public void getDetails_exceptionGiven(){
public void getDetailsExceptionGiven(){
assertThat(StringUtil.getDetails(new FileNotFoundException("file not found")),
containsString("java.io.FileNotFoundException: file not found"));
}

@Test
public void getDetails_nullGiven_assertionError(){
public void getDetailsNullGivenAssertionError(){
thrown.expect(AssertionError.class);
StringUtil.getDetails(null);
}
Expand Down
Loading

0 comments on commit 332d47c

Please sign in to comment.