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

abhi pushed a commit to branch ranger-5060
in repository https://gitbox.apache.org/repos/asf/ranger.git

commit d96f9c97f6b6e45d05f69d41e7d0fb242188c465
Author: Abhishek Kumar <[email protected]>
AuthorDate: Wed Dec 18 00:11:41 2024 -0800

    RANGER-5060: checkstyle compliance updates - ranger-util module
---
 ranger-util/pom.xml                                |   4 +
 .../ranger/common/RangerVersionAnnotation.java     |  90 ++++-----
 .../apache/ranger/common/RangerVersionInfo.java    | 210 ++++++++++-----------
 ranger-util/src/scripts/saveVersion.py             |  44 ++---
 4 files changed, 178 insertions(+), 170 deletions(-)

diff --git a/ranger-util/pom.xml b/ranger-util/pom.xml
index c9fa985f0..32dbbe68f 100644
--- a/ranger-util/pom.xml
+++ b/ranger-util/pom.xml
@@ -25,6 +25,10 @@
     <artifactId>ranger-util</artifactId>
     <name>Ranger Util</name>
     <description>Common Utilities of Ranger</description>
+    <properties>
+        <checkstyle.failOnViolation>true</checkstyle.failOnViolation>
+        <checkstyle.skip>false</checkstyle.skip>
+    </properties>
     <dependencies>
         <dependency>
             <groupId>org.apache.hadoop</groupId>
diff --git 
a/ranger-util/src/main/java/org/apache/ranger/common/RangerVersionAnnotation.java
 
b/ranger-util/src/main/java/org/apache/ranger/common/RangerVersionAnnotation.java
index e1346a13c..ef81398e2 100644
--- 
a/ranger-util/src/main/java/org/apache/ranger/common/RangerVersionAnnotation.java
+++ 
b/ranger-util/src/main/java/org/apache/ranger/common/RangerVersionAnnotation.java
@@ -18,66 +18,70 @@
 
 package org.apache.ranger.common;
 
+import org.apache.hadoop.classification.InterfaceStability;
+
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 
-import org.apache.hadoop.classification.InterfaceStability;
 /**
  * RangerVersionAnnotation.
- *
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.PACKAGE)
 @InterfaceStability.Unstable
 public @interface RangerVersionAnnotation {
+    /**
+     * Get the Ranger version
+     *
+     * @return the version string "0.6.3-dev"
+     */
+    String version();
 
-  /**
-   * Get the Ranger version
-   * @return the version string "0.6.3-dev"
-   */
-  String version();
-
-  /**
-   * Get the Ranger short version containing major/minor/change version numbers
-   * @return the short version string "0.6.3"
-   */
-  String shortVersion();
-
-  /**
-   * Get the username that compiled Ranger.
-   */
-  String user();
+    /**
+     * Get the Ranger short version containing major/minor/change version 
numbers
+     *
+     * @return the short version string "0.6.3"
+     */
+    String shortVersion();
 
-  /**
-   * Get the date when Ranger was compiled.
-   * @return the date in unix 'date' format
-   */
-  String date();
+    /**
+     * Get the username that compiled Ranger.
+     */
+    String user();
 
-  /**
-   * Get the url for the subversion repository.
-   */
-  String url();
+    /**
+     * Get the date when Ranger was compiled.
+     *
+     * @return the date in unix 'date' format
+     */
+    String date();
 
-  /**
-   * Get the subversion revision.
-   * @return the revision number as a string (eg. "451451")
-   */
-  String revision();
+    /**
+     * Get the url for the subversion repository.
+     */
+    String url();
 
-  /**
-   * Get the branch from which this was compiled.
-   * @return The branch name, e.g. "trunk" or "branches/branch-0.20"
-   */
-  String branch();
+    /**
+     * Get the subversion revision.
+     *
+     * @return the revision number as a string (eg. "451451")
+     */
+    String revision();
 
-  /**
-   * Get a checksum of the source files from which
-   * Ranger was compiled.
-   * @return a string that uniquely identifies the source
-   **/
-  String srcChecksum();
+    /**
+     * Get the branch from which this was compiled.
+     *
+     * @return The branch name, e.g. "trunk" or "branches/branch-0.20"
+     */
+    String branch();
 
+    /**
+     * Get a checksum of the source files from which
+     * Ranger was compiled.
+     *
+     * @return a string that uniquely identifies the source
+     **/
+    String srcChecksum();
 }
diff --git 
a/ranger-util/src/main/java/org/apache/ranger/common/RangerVersionInfo.java 
b/ranger-util/src/main/java/org/apache/ranger/common/RangerVersionInfo.java
index e4f9c0f4e..e64824085 100644
--- a/ranger-util/src/main/java/org/apache/ranger/common/RangerVersionInfo.java
+++ b/ranger-util/src/main/java/org/apache/ranger/common/RangerVersionInfo.java
@@ -23,113 +23,113 @@ import 
org.apache.hadoop.classification.InterfaceStability;
 
 /**
  * RangerVersionInfo.
- *
  */
 @InterfaceAudience.Private
 @InterfaceStability.Unstable
 public class RangerVersionInfo {
-
-       private static Package myPackage;
-       private static RangerVersionAnnotation version;
-
-       static {
-               myPackage = RangerVersionAnnotation.class.getPackage();
-               version = 
myPackage.getAnnotation(RangerVersionAnnotation.class);
-       }
-
-       /**
-        * Get the meta-data for the Ranger package.
-        *
-        * @return
-        */
-       static Package getPackage() {
-               return myPackage;
-       }
-
-       /**
-        * Get the Ranger version.
-        *
-        * @return the Ranger version string, eg. "0.6.3-dev"
-        */
-       public static String getVersion() {
-               return version != null ? version.version() : "Unknown";
-       }
-
-       /**
-        * Get the Ranger short version, with major/minor/change version 
numbers.
-        *
-        * @return short version string, eg. "0.6.3"
-        */
-       public static String getShortVersion() {
-               return version != null ? version.shortVersion() : "Unknown";
-       }
-
-       /**
-        * Get the subversion revision number for the root directory
-        *
-        * @return the revision number, eg. "451451"
-        */
-       public static String getRevision() {
-               return version != null ? version.revision() : "Unknown";
-       }
-
-       /**
-        * Get the branch on which this originated.
-        *
-        * @return The branch name, e.g. "trunk" or "branches/branch-0.20"
-        */
-       public static String getBranch() {
-               return version != null ? version.branch() : "Unknown";
-       }
-
-       /**
-        * The date that Ranger was compiled.
-        *
-        * @return the compilation date in unix date format
-        */
-       public static String getDate() {
-               return version != null ? version.date() : "Unknown";
-       }
-
-       /**
-        * The user that compiled Ranger.
-        *
-        * @return the username of the user
-        */
-       public static String getUser() {
-               return version != null ? version.user() : "Unknown";
-       }
-
-       /**
-        * Get the subversion URL for the root Ranger directory.
-        */
-       public static String getUrl() {
-               return version != null ? version.url() : "Unknown";
-       }
-
-       /**
-        * Get the checksum of the source files from which Ranger was built.
-        **/
-       public static String getSrcChecksum() {
-               return version != null ? version.srcChecksum() : "Unknown";
-       }
-
-       /**
-        * Returns the buildVersion which includes version, revision, user and 
date.
-        */
-       public static String getBuildVersion() {
-               return RangerVersionInfo.getVersion() + " from "
-                               + RangerVersionInfo.getRevision() + " by "
-                               + RangerVersionInfo.getUser() + " source 
checksum "
-                               + RangerVersionInfo.getSrcChecksum();
-       }
-
-       public static void main(String[] args) {
-               System.out.println("");
-               System.out.println("Ranger " + getVersion());
-               System.out.println("Subversion " + getUrl() + " -r " + 
getRevision());
-               System.out.println("Compiled by " + getUser() + " on " + 
getDate());
-               System.out.println("From source with checksum " + 
getSrcChecksum());
-       }
-
+    private static Package                 myPackage;
+    private static RangerVersionAnnotation version;
+
+    private RangerVersionInfo(){
+        // to block instantiation
+    }
+
+    /**
+     * Get the Ranger version.
+     *
+     * @return the Ranger version string, eg. "0.6.3-dev"
+     */
+    public static String getVersion() {
+        return version != null ? version.version() : "Unknown";
+    }
+
+    /**
+     * Get the Ranger short version, with major/minor/change version numbers.
+     *
+     * @return short version string, eg. "0.6.3"
+     */
+    public static String getShortVersion() {
+        return version != null ? version.shortVersion() : "Unknown";
+    }
+
+    /**
+     * Get the subversion revision number for the root directory
+     *
+     * @return the revision number, eg. "451451"
+     */
+    public static String getRevision() {
+        return version != null ? version.revision() : "Unknown";
+    }
+
+    /**
+     * Get the branch on which this originated.
+     *
+     * @return The branch name, e.g. "trunk" or "branches/branch-0.20"
+     */
+    public static String getBranch() {
+        return version != null ? version.branch() : "Unknown";
+    }
+
+    /**
+     * The date that Ranger was compiled.
+     *
+     * @return the compilation date in unix date format
+     */
+    public static String getDate() {
+        return version != null ? version.date() : "Unknown";
+    }
+
+    /**
+     * The user that compiled Ranger.
+     *
+     * @return the username of the user
+     */
+    public static String getUser() {
+        return version != null ? version.user() : "Unknown";
+    }
+
+    /**
+     * Get the subversion URL for the root Ranger directory.
+     */
+    public static String getUrl() {
+        return version != null ? version.url() : "Unknown";
+    }
+
+    /**
+     * Get the checksum of the source files from which Ranger was built.
+     **/
+    public static String getSrcChecksum() {
+        return version != null ? version.srcChecksum() : "Unknown";
+    }
+
+    /**
+     * Returns the buildVersion which includes version, revision, user and 
date.
+     */
+    public static String getBuildVersion() {
+        return RangerVersionInfo.getVersion() + " from "
+                + RangerVersionInfo.getRevision() + " by "
+                + RangerVersionInfo.getUser() + " source checksum "
+                + RangerVersionInfo.getSrcChecksum();
+    }
+
+    public static void main(String[] args) {
+        System.out.println();
+        System.out.println("Ranger " + getVersion());
+        System.out.println("Subversion " + getUrl() + " -r " + getRevision());
+        System.out.println("Compiled by " + getUser() + " on " + getDate());
+        System.out.println("From source with checksum " + getSrcChecksum());
+    }
+
+    /**
+     * Get the meta-data for the Ranger package.
+     *
+     */
+    static Package getPackage() {
+        return myPackage;
+    }
+
+    static {
+        myPackage = RangerVersionAnnotation.class.getPackage();
+        version   = myPackage.getAnnotation(RangerVersionAnnotation.class);
+    }
 }
diff --git a/ranger-util/src/scripts/saveVersion.py 
b/ranger-util/src/scripts/saveVersion.py
index 51227542d..d33aeb3cf 100644
--- a/ranger-util/src/scripts/saveVersion.py
+++ b/ranger-util/src/scripts/saveVersion.py
@@ -123,28 +123,28 @@ def main():
        srcChecksum = srcChecksum.strip('\n\r')
 
        content = """/*
-        * 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.
-        */
-        /*
-        * Generated by saveVersion.py
-        */
-        @RangerVersionAnnotation(version="{VERSION}", 
shortVersion="{SHORTVERSION}",revision="{REV}",branch="{BRANCH}", 
user="{USER}",date="{DATE}", url="{URL}",srcChecksum="{SRCCHECKSUM}")
-                                                       package 
org.apache.ranger.common;"""
-
+* 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.
+*/
+/*
+* Generated by saveVersion.py
+*/
+@RangerVersionAnnotation(version = "{VERSION}", shortVersion = 
"{SHORTVERSION}", revision = "{REV}", branch = "{BRANCH}", user = "{USER}", 
date = "{DATE}", url = "{URL}", srcChecksum = "{SRCCHECKSUM}")
+package org.apache.ranger.common;
+"""
        content = 
content.format(VERSION=version,SHORTVERSION=shortversion,USER=user,DATE=date,URL=url,REV=revision,BRANCH=branch,SRCCHECKSUM=srcChecksum)
        des = os.path.join(dir, "package-info.java")
        f = open(des , 'w')

Reply via email to