This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git


The following commit(s) were added to refs/heads/master by this push:
     new a72bbe62 Add Checkstyle rules
a72bbe62 is described below

commit a72bbe622ecbcf162852e0dad43598c9e92b3511
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat May 4 15:43:26 2024 -0400

    Add Checkstyle rules
---
 src/conf/checkstyle/checkstyle.xml              | 10 +++-------
 src/main/java/org/apache/commons/csv/Lexer.java | 18 ++++--------------
 2 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/src/conf/checkstyle/checkstyle.xml 
b/src/conf/checkstyle/checkstyle.xml
index 4ae1fec6..39b8e68c 100644
--- a/src/conf/checkstyle/checkstyle.xml
+++ b/src/conf/checkstyle/checkstyle.xml
@@ -23,22 +23,18 @@ limitations under the License.
 <!-- commons codec customization of default Checkstyle behavior -->
 <module name="Checker">
   <property name="localeLanguage" value="en" />
-
   <!-- Checks whether files end with a new line. -->
   <!-- See http://checkstyle.sf.net/config_misc.html#NewlineAtEndOfFile -->
   <module name="NewlineAtEndOfFile" />
-
   <!-- Verify that EVERY source file has the appropriate license -->
   <module name="Header">
     <property name="headerFile" value="${checkstyle.header.file}" />
   </module>
-
   <!-- Checks for Tab characters -->
   <!-- See 
http://checkstyle.sourceforge.net/config_whitespace.html#FileTabCharacter -->
   <module name="FileTabCharacter">
     <property name="fileExtensions" value="java,xml" />
   </module>
-
   <!-- Checks for white space at the end of the line -->
   <!-- See http://checkstyle.sourceforge.net/config_regexp.html -->
   <module name="RegexpSingleline">
@@ -46,7 +42,6 @@ limitations under the License.
     <property name="message" value="Line has trailing spaces." />
     <property name="fileExtensions" value="java" />
   </module>
-
   <!-- @author tags are deprecated -->
   <module name="RegexpSingleline">
     <property name="format" value="^\s+\*\s+@author\s" />
@@ -54,11 +49,9 @@ limitations under the License.
     <property name="fileExtensions" value="java" />
     <property name="severity" value="warning" />
   </module>
-
   <module name="LineLength">
     <property name="max" value="160"/>
   </module>
-
   <module name="TreeWalker">
     <module name="OperatorWrap">
       <property name="option" value="eol" />
@@ -69,6 +62,9 @@ limitations under the License.
       <property name="ordered" value="true"/>
       <property name="separated" value="true"/>
     </module>
+    <module name="WhitespaceAfter" />
+    <module name="WhitespaceAround" />
+    <module name="WhitespaceAroundCheck" />
   </module>
 
 </module>
diff --git a/src/main/java/org/apache/commons/csv/Lexer.java 
b/src/main/java/org/apache/commons/csv/Lexer.java
index 80bde6c7..1ffef81f 100644
--- a/src/main/java/org/apache/commons/csv/Lexer.java
+++ b/src/main/java/org/apache/commons/csv/Lexer.java
@@ -107,7 +107,7 @@ final class Lexer implements Closeable {
         return reader.getCurrentLineNumber();
     }
 
-    String getFirstEol(){
+    String getFirstEol() {
         return firstEol;
     }
 
@@ -138,7 +138,7 @@ final class Lexer implements Closeable {
         }
         reader.lookAhead(delimiterBuf);
         for (int i = 0; i < delimiterBuf.length; i++) {
-            if (delimiterBuf[i] != delimiter[i+1]) {
+            if (delimiterBuf[i] != delimiter[i + 1]) {
                 return false;
             }
         }
@@ -221,18 +221,12 @@ final class Lexer implements Closeable {
      * @throws IOException on stream access error.
      */
     Token nextToken(final Token token) throws IOException {
-
         // Get the last read char (required for empty line detection)
         int lastChar = reader.getLastChar();
-
         // read the next char and set eol
         int c = reader.read();
-        /*
-         * 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.
-         */
+        // 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.
         boolean eol = readEndOfLine(c);
-
         // empty line detection: eol AND (last char was EOL or beginning)
         if (ignoreEmptyLines) {
             while (eol && isStartOfLine(lastChar)) {
@@ -248,14 +242,12 @@ final class Lexer implements Closeable {
                 }
             }
         }
-
         // Did we reach EOF during the last iteration already? EOF
         if (isEndOfFile(lastChar) || !isLastTokenDelimiter && isEndOfFile(c)) {
             token.type = Token.Type.EOF;
             // don't set token.isReady here because no content
             return token;
         }
-
         if (isStartOfLine(lastChar) && isCommentStart(c)) {
             final String line = reader.readLine();
             if (line == null) {
@@ -268,17 +260,15 @@ final class Lexer implements Closeable {
             token.type = COMMENT;
             return token;
         }
-
         // Important: make sure a new char gets consumed in each iteration
         while (token.type == INVALID) {
             // ignore whitespaces at beginning of a token
             if (ignoreSurroundingSpaces) {
-                while (Character.isWhitespace((char)c) && !isDelimiter(c) && 
!eol) {
+                while (Character.isWhitespace((char) c) && !isDelimiter(c) && 
!eol) {
                     c = reader.read();
                     eol = readEndOfLine(c);
                 }
             }
-
             // ok, start of token reached: encapsulated, or token
             if (isDelimiter(c)) {
                 // empty token return TOKEN("")

Reply via email to