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

leerho pushed a commit to branch fix_checkstyle_issues
in repository https://gitbox.apache.org/repos/asf/datasketches-memory.git

commit 394f0428782266a958588da372784e7216ecd7e4
Author: Lee Rhodes <[email protected]>
AuthorDate: Tue May 14 12:37:04 2024 -0700

    Fixed some checkstyle configuration errors.
    
    Aligned checkstyle config with DS-Java checkstyle config.
    Fixed some minor issues identified by checkstyle.
---
 .../apache/datasketches/memory/package-info.java   | 23 +++++++++++++++
 .../datasketches/memory/internal/UnsafeUtil.java   |  2 +-
 .../apache/datasketches/memory/internal/Utf8.java  |  2 +-
 tools/MemoryCheckstyle.xml                         | 34 ++++++++++++++++++----
 tools/suppressions.xml                             | 29 ++++++++++++++++++
 5 files changed, 83 insertions(+), 7 deletions(-)

diff --git 
a/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/package-info.java
 
b/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/package-info.java
new file mode 100644
index 0000000..3dd75d5
--- /dev/null
+++ 
b/datasketches-memory-java11/src/main/java/org/apache/datasketches/memory/package-info.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author Lee Rhodes
+ */
+package org.apache.datasketches.memory;
diff --git 
a/datasketches-memory-java8/src/main/java/org/apache/datasketches/memory/internal/UnsafeUtil.java
 
b/datasketches-memory-java8/src/main/java/org/apache/datasketches/memory/internal/UnsafeUtil.java
index 0a99211..c911edd 100644
--- 
a/datasketches-memory-java8/src/main/java/org/apache/datasketches/memory/internal/UnsafeUtil.java
+++ 
b/datasketches-memory-java8/src/main/java/org/apache/datasketches/memory/internal/UnsafeUtil.java
@@ -137,7 +137,7 @@ public final class UnsafeUtil {
       p0 = Integer.parseInt(parts[0]); //the first number group
       p1 = (parts.length > 1) ? Integer.parseInt(parts[1]) : 0; //2nd number 
group, or 0
     } catch (final NumberFormatException | ArrayIndexOutOfBoundsException  e) {
-      throw new IllegalArgumentException("Improper Java -version string: " + 
jdkVer + "\n" + e);
+      throw new IllegalArgumentException("Improper Java -version string: " + 
jdkVer + Util.LS + e);
     }
     //checkJavaVersion(jdkVer, p0, p1); //TODO Optional to omit this.
     return new int[] {p0, p1};
diff --git 
a/datasketches-memory-java8/src/main/java/org/apache/datasketches/memory/internal/Utf8.java
 
b/datasketches-memory-java8/src/main/java/org/apache/datasketches/memory/internal/Utf8.java
index d8fb52d..9500c2b 100644
--- 
a/datasketches-memory-java8/src/main/java/org/apache/datasketches/memory/internal/Utf8.java
+++ 
b/datasketches-memory-java8/src/main/java/org/apache/datasketches/memory/internal/Utf8.java
@@ -410,7 +410,7 @@ final class Utf8 {
    *
    * @see <a href="https://en.wikipedia.org/wiki/UTF-8";>Wikipedia: UTF-8</a>
    */
-  private static class DecodeUtil {
+  private static final class DecodeUtil {
 
     /**
      * Returns whether this is a single-byte UTF-8 encoding.
diff --git a/tools/MemoryCheckstyle.xml b/tools/MemoryCheckstyle.xml
index fd631a7..a17a7e0 100644
--- a/tools/MemoryCheckstyle.xml
+++ b/tools/MemoryCheckstyle.xml
@@ -36,9 +36,17 @@ under the License.
   <property name="charset" value="UTF-8"/>
   <property name="severity" value="warning"/>
   <property name="fileExtensions" value="java"/>
+  <property name="basedir" value="${basedir}"/>
 
+  <!-- Exclude all module-info.java files 
+       
https://checkstyle.org/filefilters/beforeexecutionexclusionfilefilter.html#BeforeExecutionExclusionFileFilter
 -->
   <module name="BeforeExecutionExclusionFileFilter">
-    <property name="fileNamePattern" 
value="src[\\/]test[\\/]java[\\/].+$|module\-info\.java.+$"/>
+    <property name="fileNamePattern" value="module\-info\.java$"/>
+  </module>
+
+  <!-- Exclude all src/test/... files -->
+  <module name="BeforeExecutionExclusionFileFilter">
+    <property name="fileNamePattern" value=".*[\\/]src[\\/]test[\\/].*$"/>
   </module>
 
   <module name="FileTabCharacter">
@@ -54,7 +62,7 @@ under the License.
   <!-- Size Violations -->
   <module name="LineLength">
     <property name="severity" value="warning"/>
-    <property name="max" value="120"/>
+    <property name="max" value="140"/>
     <property name="ignorePattern" value="^package.*|^import.*|a 
href|href|http://|https://|ftp://"/>
     <!-- <metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" 
value="inherit"/> -->
   </module>
@@ -68,7 +76,18 @@ under the License.
   <!-- ******************************************************** -->
   
   <module name="TreeWalker">
-    
+
+    <!-- Be able to ignore violations with @SuppressWarnings -->
+    <!-- See https://checkstyle.org/filters/suppresswarningsfilter.html -->
+    <module name="SuppressWarningsHolder"/>
+  
+    <!--
+      <module name="SuppressionFilter">
+      <property name="file" value="basedir/tools/suppressions.xml"/>
+      <property name="optional" value="false"/>
+      </module>
+    -->
+
     <!-- Annotations -->
     <module name="AnnotationLocation">
       <property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, 
METHOD_DEF, CTOR_DEF"/>
@@ -81,7 +100,7 @@ under the License.
 
     <!-- Block Checks -->
     <module name="EmptyBlock">
-      <property name="severity" value="warning"/>
+      <property name="severity" value="ignore"/>
       <property name="option" value="TEXT"/>
       <property name="tokens" value="LITERAL_TRY, LITERAL_FINALLY, LITERAL_IF, 
LITERAL_ELSE, LITERAL_SWITCH"/>
       <metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" 
value="inherit"/>
@@ -163,6 +182,11 @@ under the License.
       <metadata name="net.sf.eclipsecs.core.lastEnabledSeverity" 
value="inherit"/>
     </module>
     
+    <module name="IllegalTokenText">
+      <property name="tokens" value="STRING_LITERAL"/>
+      <property name="format" value="\\n"/>
+    </module>
+    
     <!-- Class Design -->
     <module name="OneTopLevelClass"/>
     
@@ -396,4 +420,4 @@ under the License.
 
   </module> <!-- End of TreeWalker -->
 
-</module>
\ No newline at end of file
+</module>
diff --git a/tools/suppressions.xml b/tools/suppressions.xml
new file mode 100644
index 0000000..91b8833
--- /dev/null
+++ b/tools/suppressions.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+
+<!DOCTYPE suppressions PUBLIC
+  "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
+  "https://checkstyle.org/dtds/suppressions_1_2.dtd";>
+
+  <!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+  -->
+
+<suppressions>
+  <suppress checks="Javadoc" files=".*[\\/]src[\\/](test|it)[\\/]"/>
+  <suppress checks="MagicNumber" files=".*[\\/]src[\\/](test|it)[\\/]"/>
+</suppressions>
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to