Skip to content

Commit 6711054

Browse files
committed
Add Checstyle FinalParameters
1 parent 055695d commit 6711054

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

src/conf/checkstyle/checkstyle.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ limitations under the License.
4343
<module name="TreeWalker">
4444
<module name="AvoidStarImport" />
4545
<module name="FinalLocalVariable" />
46+
<module name="FinalParameters" />
4647
<module name="IllegalImport" />
4748
<module name="ImportOrder">
4849
<property name="option" value="top" />

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

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -402,34 +402,35 @@ private Token parseEncapsulatedToken(final Token token) throws IOException {
402402
* </ul>
403403
*
404404
* @param token the current token
405-
* @param ch the current character
405+
* @param ch the current character
406406
* @return the filled token
407407
* @throws IOException on stream access error
408408
* @throws CSVException Thrown on invalid input.
409409
*/
410-
private Token parseSimpleToken(final Token token, int ch) throws IOException {
410+
private Token parseSimpleToken(final Token token, final int ch) throws IOException {
411411
// Faster to use while(true)+break than while(token.type == INVALID)
412+
int cur = ch;
412413
while (true) {
413-
if (readEndOfLine(ch)) {
414+
if (readEndOfLine(cur)) {
414415
token.type = Token.Type.EORECORD;
415416
break;
416417
}
417-
if (isEndOfFile(ch)) {
418+
if (isEndOfFile(cur)) {
418419
token.type = Token.Type.EOF;
419420
token.isReady = true; // There is data at EOF
420421
break;
421422
}
422-
if (isDelimiter(ch)) {
423+
if (isDelimiter(cur)) {
423424
token.type = Token.Type.TOKEN;
424425
break;
425426
}
426427
// continue
427-
if (isEscape(ch)) {
428+
if (isEscape(cur)) {
428429
appendNextEscapedCharacterToToken(token);
429430
} else {
430-
token.content.append((char) ch);
431+
token.content.append((char) cur);
431432
}
432-
ch = reader.read(); // continue
433+
cur = reader.read(); // continue
433434
}
434435

435436
if (ignoreSurroundingSpaces) {
@@ -444,26 +445,27 @@ private Token parseSimpleToken(final Token token, int ch) throws IOException {
444445
*
445446
* @return true if the given or next character is a line-terminator
446447
*/
447-
boolean readEndOfLine(int ch) throws IOException {
448+
boolean readEndOfLine(final int ch) throws IOException {
448449
// check if we have \r\n...
449-
if (ch == Constants.CR && reader.peek() == Constants.LF) {
450+
int cur = ch;
451+
if (cur == Constants.CR && reader.peek() == Constants.LF) {
450452
// note: does not change ch outside of this method!
451-
ch = reader.read();
453+
cur = reader.read();
452454
// Save the EOL state
453455
if (firstEol == null) {
454456
this.firstEol = Constants.CRLF;
455457
}
456458
}
457459
// save EOL state here.
458460
if (firstEol == null) {
459-
if (ch == Constants.LF) {
461+
if (cur == Constants.LF) {
460462
this.firstEol = LF_STRING;
461-
} else if (ch == Constants.CR) {
463+
} else if (cur == Constants.CR) {
462464
this.firstEol = CR_STRING;
463465
}
464466
}
465467

466-
return ch == Constants.LF || ch == Constants.CR;
468+
return cur == Constants.LF || cur == Constants.CR;
467469
}
468470

469471
// TODO escape handling needs more work

0 commit comments

Comments
 (0)