Skip to content

Commit a72bbe6

Browse files
committed
Add Checkstyle rules
1 parent 23a264e commit a72bbe6

2 files changed

Lines changed: 7 additions & 21 deletions

File tree

src/conf/checkstyle/checkstyle.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,35 @@ limitations under the License.
2323
<!-- commons codec customization of default Checkstyle behavior -->
2424
<module name="Checker">
2525
<property name="localeLanguage" value="en" />
26-
2726
<!-- Checks whether files end with a new line. -->
2827
<!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
2928
<module name="NewlineAtEndOfFile" />
30-
3129
<!-- Verify that EVERY source file has the appropriate license -->
3230
<module name="Header">
3331
<property name="headerFile" value="${checkstyle.header.file}" />
3432
</module>
35-
3633
<!-- Checks for Tab characters -->
3734
<!-- See http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter -->
3835
<module name="FileTabCharacter">
3936
<property name="fileExtensions" value="java,xml" />
4037
</module>
41-
4238
<!-- Checks for white space at the end of the line -->
4339
<!-- See http://checkstyle.sourceforge.net/config_regexp.html -->
4440
<module name="RegexpSingleline">
4541
<property name="format" value="\s+$" />
4642
<property name="message" value="Line has trailing spaces." />
4743
<property name="fileExtensions" value="java" />
4844
</module>
49-
5045
<!-- @author tags are deprecated -->
5146
<module name="RegexpSingleline">
5247
<property name="format" value="^\s+\*\s+@author\s" />
5348
<property name="message" value="Deprecated @author tag" />
5449
<property name="fileExtensions" value="java" />
5550
<property name="severity" value="warning" />
5651
</module>
57-
5852
<module name="LineLength">
5953
<property name="max" value="160"/>
6054
</module>
61-
6255
<module name="TreeWalker">
6356
<module name="OperatorWrap">
6457
<property name="option" value="eol" />
@@ -69,6 +62,9 @@ limitations under the License.
6962
<property name="ordered" value="true"/>
7063
<property name="separated" value="true"/>
7164
</module>
65+
<module name="WhitespaceAfter" />
66+
<module name="WhitespaceAround" />
67+
<module name="WhitespaceAroundCheck" />
7268
</module>
7369

7470
</module>

src/main/java/org/apache/commons/csv/Lexer.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ long getCurrentLineNumber() {
107107
return reader.getCurrentLineNumber();
108108
}
109109

110-
String getFirstEol(){
110+
String getFirstEol() {
111111
return firstEol;
112112
}
113113

@@ -138,7 +138,7 @@ boolean isDelimiter(final int ch) throws IOException {
138138
}
139139
reader.lookAhead(delimiterBuf);
140140
for (int i = 0; i < delimiterBuf.length; i++) {
141-
if (delimiterBuf[i] != delimiter[i+1]) {
141+
if (delimiterBuf[i] != delimiter[i + 1]) {
142142
return false;
143143
}
144144
}
@@ -221,18 +221,12 @@ private char mapNullToDisabled(final Character c) {
221221
* @throws IOException on stream access error.
222222
*/
223223
Token nextToken(final Token token) throws IOException {
224-
225224
// Get the last read char (required for empty line detection)
226225
int lastChar = reader.getLastChar();
227-
228226
// read the next char and set eol
229227
int c = reader.read();
230-
/*
231-
* Note: The following call will swallow LF if c == CR. But we don't need to know if the last char was CR or LF
232-
* - they are equivalent here.
233-
*/
228+
// Note: The following call will swallow LF if c == CR. But we don't need to know if the last char was CR or LF - they are equivalent here.
234229
boolean eol = readEndOfLine(c);
235-
236230
// empty line detection: eol AND (last char was EOL or beginning)
237231
if (ignoreEmptyLines) {
238232
while (eol && isStartOfLine(lastChar)) {
@@ -248,14 +242,12 @@ Token nextToken(final Token token) throws IOException {
248242
}
249243
}
250244
}
251-
252245
// Did we reach EOF during the last iteration already? EOF
253246
if (isEndOfFile(lastChar) || !isLastTokenDelimiter && isEndOfFile(c)) {
254247
token.type = Token.Type.EOF;
255248
// don't set token.isReady here because no content
256249
return token;
257250
}
258-
259251
if (isStartOfLine(lastChar) && isCommentStart(c)) {
260252
final String line = reader.readLine();
261253
if (line == null) {
@@ -268,17 +260,15 @@ Token nextToken(final Token token) throws IOException {
268260
token.type = COMMENT;
269261
return token;
270262
}
271-
272263
// Important: make sure a new char gets consumed in each iteration
273264
while (token.type == INVALID) {
274265
// ignore whitespaces at beginning of a token
275266
if (ignoreSurroundingSpaces) {
276-
while (Character.isWhitespace((char)c) && !isDelimiter(c) && !eol) {
267+
while (Character.isWhitespace((char) c) && !isDelimiter(c) && !eol) {
277268
c = reader.read();
278269
eol = readEndOfLine(c);
279270
}
280271
}
281-
282272
// ok, start of token reached: encapsulated, or token
283273
if (isDelimiter(c)) {
284274
// empty token return TOKEN("")

0 commit comments

Comments
 (0)