Skip to content

Commit dc9fe96

Browse files
eugenepehdamithc
authored andcommitted
[nus-cs2103-AY2122S1#319] Checkstyle: enforce separators' placement in line wraps (#368)
Our coding standard for Java requires separators' placement in line wraps to follow specific rules, such as having comma (,) stay attached to the token that precedes it and having the dot (.) in a new line. These rules are not enforced by checkstyle. Let's teach Checkstyle to be stricter about line wrapping around some symbols by adding the relevant SeparatorWrap rules.
1 parent c730a68 commit dc9fe96

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

config/checkstyle/checkstyle.xml

+11
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,17 @@
322322
<property name="message" value="Trailing whitespace"/>
323323
</module>
324324

325+
<module name="SeparatorWrap">
326+
<!-- Checks that the ".", "@" is at the next line in a line wrap. -->
327+
<property name="tokens" value="DOT, AT"/>
328+
<property name="option" value="nl"/>
329+
</module>
330+
<module name="SeparatorWrap">
331+
<!-- Checks that the ",", "]", "[", "...", ";", "(" is at the previous end of line in a line wrap. -->
332+
<property name="tokens" value="COMMA, RBRACK, ARRAY_DECLARATOR, ELLIPSIS, SEMI, LPAREN"/>
333+
<property name="option" value="eol"/>
334+
</module>
335+
325336
<module name="Indentation">
326337
<property name="caseIndent" value="0" />
327338
</module>

src/main/java/seedu/address/model/person/UniquePersonList.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ public Iterator<Person> iterator() {
103103
public boolean equals(Object other) {
104104
return other == this // short circuit if same object
105105
|| (other instanceof UniquePersonList // instanceof handles nulls
106-
&& this.internalList.equals(
107-
((UniquePersonList) other).internalList));
106+
&& this.internalList.equals(((UniquePersonList) other).internalList));
108107
}
109108

110109
@Override

src/main/java/seedu/address/model/tag/UniqueTagList.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ public UnmodifiableObservableList<Tag> asObservableList() {
150150
public boolean equals(Object other) {
151151
return other == this // short circuit if same object
152152
|| (other instanceof UniqueTagList // instanceof handles nulls
153-
&& this.internalList.equals(
154-
((UniqueTagList) other).internalList));
153+
&& this.internalList.equals(((UniqueTagList) other).internalList));
155154
}
156155

157156
public boolean equalsOrderInsensitive(UniqueTagList other) {

src/test/java/seedu/address/ui/TestFxmlObject.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public void setText(String text) {
2727

2828
@Override
2929
public boolean equals(Object other) {
30-
return other == this ||
31-
(other instanceof TestFxmlObject
30+
return other == this // short circuit if same object
31+
|| (other instanceof TestFxmlObject // instanceof handles nulls
3232
&& this.text.equals(((TestFxmlObject) other).getText()));
3333
}
3434

0 commit comments

Comments
 (0)