Skip to content

Commit e6c2dc4

Browse files
authored
Update checkstyle version to v8.32 (#41)
As the checkstyle version is 3 years out of date, let's update the version to the latest available to benefit from the improvements. Let's * Replace deprecated checks. * Move LineLength check out of TreeWalker. * Add check for invalid JavaDoc position. * Fix checkstyle violations in existing code.
1 parent 4886f81 commit e6c2dc4

16 files changed

+52
-35
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repositories {
1616
}
1717

1818
checkstyle {
19-
toolVersion = '8.1'
19+
toolVersion = '8.29'
2020
}
2121

2222
test {

config/checkstyle/checkstyle.xml

+10-31
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,14 @@
2929
<property name="file" value="${config_loc}/suppressions.xml"/>
3030
</module>
3131

32+
<module name="LineLength">
33+
<!-- Checks if a line is too long. -->
34+
<property name="max" value="120"/>
35+
</module>
3236

3337
<!-- All Java AST specific tests live under TreeWalker module. -->
3438
<module name="TreeWalker">
3539

36-
<!-- Required for SuppressionCommentFilter to work -->
37-
<module name="FileContentsHolder"/>
38-
3940
<!-- Required to allow exceptions in code style -->
4041
<module name="SuppressionCommentFilter">
4142
<property name="offCommentFormat" value="CHECKSTYLE.OFF\: ([\w\|]+)"/>
@@ -158,11 +159,6 @@
158159
<!-- Checks if a catch block is empty and does not contain any comments. -->
159160
<module name="EmptyCatchBlock"/>
160161

161-
<module name="LineLength">
162-
<!-- Checks if a line is too long. -->
163-
<property name="max" value="120"/>
164-
</module>
165-
166162
<module name="LeftCurly">
167163
<!-- Checks for placement of the left curly brace ('{'). -->
168164
<property name="severity" value="warning"/>
@@ -387,37 +383,20 @@
387383

388384
<!-- Checks that every public method (excluding getters, setters and constructors) has a header comment. -->
389385
<module name="JavadocMethod">
390-
<!-- Checks public methods that have more than 1 line of code.
391-
Single line of code methods are often due to refactor for readability.
392-
-->
393-
<property name="minLineCount" value="1"/>
394386
<property name="allowedAnnotations" value="Override, Test, BeforeAll, BeforeEach, AfterAll, AfterEach, Subscribe"/>
395387
<property name="scope" value="public"/>
396-
<property name="allowUndeclaredRTE" value="true"/>
397-
<property name="allowThrowsTagsForSubclasses" value="true"/>
388+
<property name="validateThrows" value="false"/>
398389
<property name="allowMissingParamTags" value="true"/>
399-
<property name="allowMissingThrowsTags" value="true"/>
400390
<property name="allowMissingReturnTag" value="true"/>
401-
<property name="allowMissingPropertyJavadoc" value="true"/>
402-
<property name="ignoreMethodNamesRegex" value="(set.*|get.*)"/>
403391
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/>
404392
</module>
405-
<!-- Checks that every non-trivial private method (excluding getters, setters and constructors) has a header comment. -->
406-
<module name="JavadocMethod">
407-
<!-- Checks private methods that have more than 3 lines of code.
408-
We define methods that have more than 3 lines of code as non-trivial.
409-
-->
410-
<property name="minLineCount" value="3"/>
411-
<property name="allowedAnnotations" value="Override, Test, BeforeAll, BeforeEach, AfterAll, AfterEach, Subscribe"/>
412-
<property name="scope" value="private"/>
413-
<property name="allowUndeclaredRTE" value="true"/>
414-
<property name="allowThrowsTagsForSubclasses" value="true"/>
415-
<property name="allowMissingParamTags" value="true"/>
416-
<property name="allowMissingThrowsTags" value="true"/>
417-
<property name="allowMissingReturnTag" value="true"/>
393+
394+
<module name="InvalidJavadocPosition"/>
395+
396+
<module name="MissingJavadocMethodCheck">
397+
<property name="minLineCount" value="1"/>
418398
<property name="allowMissingPropertyJavadoc" value="true"/>
419399
<property name="ignoreMethodNamesRegex" value="(set.*|get.*)"/>
420-
<property name="tokens" value="METHOD_DEF, ANNOTATION_FIELD_DEF"/>
421400
</module>
422401

423402
</module>

config/checkstyle/suppressions.xml

+1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66

77
<suppressions>
88
<suppress checks="JavadocType" files=".*Test\.java"/>
9+
<suppress checks="MissingJavadocMethodCheck" files=".*Test\.java"/>
910
</suppressions>

src/main/java/seedu/address/commons/core/GuiSettings.java

+6
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,18 @@ public class GuiSettings implements Serializable {
1717
private final double windowHeight;
1818
private final Point windowCoordinates;
1919

20+
/**
21+
* Constructs a {@code GuiSettings} with the default height, width and position.
22+
*/
2023
public GuiSettings() {
2124
windowWidth = DEFAULT_WIDTH;
2225
windowHeight = DEFAULT_HEIGHT;
2326
windowCoordinates = null; // null represent no coordinates
2427
}
2528

29+
/**
30+
* Constructs a {@code GuiSettings} with the specified height, width and position.
31+
*/
2632
public GuiSettings(double windowWidth, double windowHeight, int xPosition, int yPosition) {
2733
this.windowWidth = windowWidth;
2834
this.windowHeight = windowHeight;

src/main/java/seedu/address/commons/core/Version.java

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ public class Version implements Comparable<Version> {
2222
private final int patch;
2323
private final boolean isEarlyAccess;
2424

25+
/**
26+
* Constructs a {@code Version} with the given version details.
27+
*/
2528
public Version(int major, int minor, int patch, boolean isEarlyAccess) {
2629
this.major = major;
2730
this.minor = minor;

src/main/java/seedu/address/commons/util/AppUtil.java

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
*/
1111
public class AppUtil {
1212

13+
/**
14+
* Gets an {@code Image} from the specified path.
15+
*/
1316
public static Image getImage(String imagePath) {
1417
requireNonNull(imagePath);
1518
return new Image(MainApp.class.getResourceAsStream(imagePath));

src/main/java/seedu/address/logic/LogicManager.java

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public class LogicManager implements Logic {
2828
private final Storage storage;
2929
private final AddressBookParser addressBookParser;
3030

31+
/**
32+
* Constructs a {@code LogicManager} with the given {@code Model} and {@code Storage}.
33+
*/
3134
public LogicManager(Model model, Storage storage) {
3235
this.model = model;
3336
this.storage = storage;

src/main/java/seedu/address/storage/StorageManager.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ public class StorageManager implements Storage {
2020
private AddressBookStorage addressBookStorage;
2121
private UserPrefsStorage userPrefsStorage;
2222

23-
23+
/**
24+
* Creates a {@code StorageManager} with the given {@code AddressBookStorage} and {@code UserPrefStorage}.
25+
*/
2426
public StorageManager(AddressBookStorage addressBookStorage, UserPrefsStorage userPrefsStorage) {
2527
super();
2628
this.addressBookStorage = addressBookStorage;

src/main/java/seedu/address/ui/CommandBox.java

+3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ public class CommandBox extends UiPart<Region> {
2121
@FXML
2222
private TextField commandTextField;
2323

24+
/**
25+
* Creates a {@code CommandBox} with the given {@code CommandExecutor}.
26+
*/
2427
public CommandBox(CommandExecutor commandExecutor) {
2528
super(FXML);
2629
this.commandExecutor = commandExecutor;

src/main/java/seedu/address/ui/MainWindow.java

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ public class MainWindow extends UiPart<Stage> {
5050
@FXML
5151
private StackPane statusbarPlaceholder;
5252

53+
/**
54+
* Creates a {@code MainWindow} with the given {@code Stage} and {@code Logic}.
55+
*/
5356
public MainWindow(Stage primaryStage, Logic logic) {
5457
super(FXML, primaryStage);
5558

src/main/java/seedu/address/ui/PersonCard.java

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public class PersonCard extends UiPart<Region> {
4141
@FXML
4242
private FlowPane tags;
4343

44+
/**
45+
* Creates a {@code PersonCode} with the given {@code Person} and index to display.
46+
*/
4447
public PersonCard(Person person, int displayedIndex) {
4548
super(FXML);
4649
this.person = person;

src/main/java/seedu/address/ui/PersonListPanel.java

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public class PersonListPanel extends UiPart<Region> {
2020
@FXML
2121
private ListView<Person> personListView;
2222

23+
/**
24+
* Creates a {@code PersonListPanel} with the given {@code ObservableList}.
25+
*/
2326
public PersonListPanel(ObservableList<Person> personList) {
2427
super(FXML);
2528
personListView.setItems(personList);

src/main/java/seedu/address/ui/StatusBarFooter.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ public class StatusBarFooter extends UiPart<Region> {
1717
@FXML
1818
private Label saveLocationStatus;
1919

20-
20+
/**
21+
* Creates a {@code StatusBarFooter} with the given {@code Path}.
22+
*/
2123
public StatusBarFooter(Path saveLocation) {
2224
super(FXML);
2325
saveLocationStatus.setText(Paths.get(".").resolve(saveLocation).toString());

src/main/java/seedu/address/ui/UiManager.java

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public class UiManager implements Ui {
2525
private Logic logic;
2626
private MainWindow mainWindow;
2727

28+
/**
29+
* Creates a {@code UiManager} with the given {@code Logic}.
30+
*/
2831
public UiManager(Logic logic) {
2932
super();
3033
this.logic = logic;

src/test/java/seedu/address/logic/parser/ArgumentTokenizerTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public void tokenize_multipleArguments() {
106106
assertPreambleEmpty(argMultimap);
107107
assertArgumentAbsent(argMultimap, pSlash);
108108

109-
/** Also covers: testing for prefixes not specified as a prefix **/
109+
/* Also covers: testing for prefixes not specified as a prefix */
110110

111111
// Prefixes not previously given to the tokenizer should not return any values
112112
argsString = unknownPrefix + "some value";

src/test/java/seedu/address/testutil/PersonBuilder.java

+3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ public class PersonBuilder {
2727
private Address address;
2828
private Set<Tag> tags;
2929

30+
/**
31+
* Creates a {@code PersonBuilder} with the default details.
32+
*/
3033
public PersonBuilder() {
3134
name = new Name(DEFAULT_NAME);
3235
phone = new Phone(DEFAULT_PHONE);

0 commit comments

Comments
 (0)