You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2022/02/13 13:31:59 UTC

[myfaces-tobago] 28/32: cherrypick from 2.x: build: checkstyle enhancements

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

weber pushed a commit to branch TOBAGO-1999_Select2
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git

commit 2d511160e63af3219902803189802d3122ca00aa
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Thu Feb 10 16:39:30 2022 +0100

    cherrypick from 2.x: build: checkstyle enhancements
---
 pom.xml                                            | 22 ++++++++--------------
 .../apache/myfaces/tobago/config/TobagoConfig.java |  2 +-
 .../myfaces/tobago/event/TabChangeEvent.java       |  2 +-
 .../component/SelectItemsTagDeclaration.java       |  2 +-
 .../taglib/component/SuggestTagDeclaration.java    |  4 ++--
 .../myfaces/tobago/internal/util/PartUtils.java    |  2 +-
 .../tobago/internal/webapp/JsonResponseWriter.java |  2 +-
 .../tobago/renderkit/LabelWithAccessKey.java       |  2 +-
 .../apache/myfaces/tobago/util/BeanComparator.java |  9 ---------
 .../tobago/util/ValueExpressionComparator.java     |  5 -----
 .../tobago/webapp/TobagoResponseWriter.java        |  2 +-
 .../internal/taglib/component/GenericTestBase.java |  6 +++---
 .../addressbook/web/StartupPhaseListener.java      |  4 ++--
 .../addressbook/web/StartupPhaseListener.java      |  4 ++--
 tobago-example/tobago-example-demo/pom.xml         |  4 ++--
 .../demo/clientConfig/ClientConfigController.java  |  2 +-
 .../myfaces/tobago/event/PageActionUtil.java       |  2 +-
 .../myfaces/tobago/renderkit/html/JsonUtils.java   |  2 +-
 18 files changed, 29 insertions(+), 49 deletions(-)

diff --git a/pom.xml b/pom.xml
index 410ea1f..6aecc03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,7 +55,8 @@
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
     <jsf.target>2.0</jsf.target>
     <required.maven.version>2.2.1</required.maven.version>
-    <maven-checkstyle-plugin.version>3.0.0</maven-checkstyle-plugin.version>
+    <maven-checkstyle-plugin.version>3.1.2</maven-checkstyle-plugin.version>
+    <maven-checkstyle.version>8.45.1</maven-checkstyle.version>
     <checkstyle-rules.version>16-SNAPSHOT</checkstyle-rules.version>
     <tobago.basedir>${project.basedir}</tobago.basedir>
   </properties>
@@ -385,6 +386,7 @@
           <xrefLocation>xref</xrefLocation>
           <excludes>**/package-info.java</excludes>
           <indentSize>2</indentSize>
+          <sourceDirectories>${project.build.sourceDirectory}</sourceDirectories>
           <includeTestSourceDirectory>true</includeTestSourceDirectory>
         </configuration>
         <dependencies>
@@ -393,6 +395,11 @@
             <artifactId>checkstyle-rules</artifactId>
             <version>${checkstyle-rules.version}</version>
           </dependency>
+          <dependency>
+            <groupId>com.puppycrawl.tools</groupId>
+            <artifactId>checkstyle</artifactId>
+            <version>${maven-checkstyle.version}</version>
+          </dependency>
         </dependencies>
       </plugin>
 
@@ -542,19 +549,6 @@
           <version>1.7</version>
         </plugin>
         <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-checkstyle-plugin</artifactId>
-          <version>${maven-checkstyle-plugin.version}</version>
-          <configuration>
-            <configLocation>tobago/checkstyle.xml</configLocation>
-            <headerLocation>default/myfaces-header.txt</headerLocation>
-            <xrefLocation>xref</xrefLocation>
-            <excludes>**/package-info.java</excludes>
-            <indentSize>2</indentSize>
-            <includeTestSourceDirectory>true</includeTestSourceDirectory>
-          </configuration>
-        </plugin>
-        <plugin>
           <artifactId>maven-remote-resources-plugin</artifactId>
           <version>1.2.1</version>
           <executions>
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
index d4178d8..5d97deb 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/config/TobagoConfig.java
@@ -41,7 +41,7 @@ public abstract class TobagoConfig {
     return (TobagoConfig) servletContext.getAttribute(TOBAGO_CONFIG);
   }
 
-  public abstract Theme getTheme(final String name);
+  public abstract Theme getTheme(String name);
 
   public abstract List<Theme> getSupportedThemes();
 
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/event/TabChangeEvent.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/event/TabChangeEvent.java
index 2875237..4ad7539 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/event/TabChangeEvent.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/event/TabChangeEvent.java
@@ -37,7 +37,7 @@ public class TabChangeEvent extends ActionEvent {
   }
 
   /**
-   * @deprecated Please use {@link TabChangeEvent(UIComponent, Integer, Integer)}
+   * @deprecated Please use {@link #TabChangeEvent(UIComponent, Integer, Integer)}
    */
   @Deprecated
   public TabChangeEvent(final UIComponent uiComponent, final Object oldState, final Object newState) {
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectItemsTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectItemsTagDeclaration.java
index 15891a1..199e391 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectItemsTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SelectItemsTagDeclaration.java
@@ -55,7 +55,7 @@ public interface SelectItemsTagDeclaration extends HasId, HasBinding, HasItemLab
    */
   @TagAttribute
   @UIComponentTagAttribute(expression = DynamicExpression.PROHIBITED)
-  void setVar(final String var);
+  void setVar(String var);
 
   /**
    * Flag indicating whether the option created by this component is disabled.
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java
index 6ee02da..1fa615b 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/taglib/component/SuggestTagDeclaration.java
@@ -138,9 +138,9 @@ public interface SuggestTagDeclaration extends HasIdBindingAndRendered, HasMarku
 
   /**
    * TODO: not implemented yet
-   * <p/>
+   * <p>
    * Should the list be updated while typing (via AJAX). This is the default behaviour.
-   * If you set this value to <code>false</code>, please set the <code>minimumCharacters="0"</pre>.
+   * If you set this value to <code>false</code>, please set the <code>minimumCharacters="0"</code>.
    */
   @TagAttribute
   @UIComponentTagAttribute(type = "boolean", defaultValue = "true")
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/PartUtils.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/PartUtils.java
index 49c3860..9076ea2 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/PartUtils.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/util/PartUtils.java
@@ -152,7 +152,7 @@ public final class PartUtils {
       }
       String result = null;
       if (i2 > i1) {
-        result = new String(chars, i1, i2 - i1);
+        result = String.copyValueOf(chars, i1, i2 - i1);
       }
       return result;
     }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/JsonResponseWriter.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/JsonResponseWriter.java
index 26a8fcc..f2b7cea 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/JsonResponseWriter.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/webapp/JsonResponseWriter.java
@@ -80,7 +80,7 @@ public class JsonResponseWriter extends HtmlResponseWriter {
     if (FacesVersion.isMojarra() && FacesVersion.supports20()) {
       final StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
       if (stackTraceElements[2].getClassName().equals("com.sun.faces.renderkit.ServerSideStateHelper")) {
-        super.write(StringUtils.replace(new String(chars), "\"", "\\\""));
+        super.write(StringUtils.replace(String.copyValueOf(chars), "\"", "\\\""));
         return;
       }
     }
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKey.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKey.java
index 2b10148..69c4d2b 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKey.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/renderkit/LabelWithAccessKey.java
@@ -117,7 +117,7 @@ public final class LabelWithAccessKey {
             j++;
           }
         }
-        label0 = new String(chars, 0, j);
+        label0 = String.copyValueOf(chars, 0, j);
       }
 
     } else {
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java
index b676c46..eca59db 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/BeanComparator.java
@@ -53,10 +53,6 @@ public class BeanComparator extends ComparatorBase implements Serializable {
     this.property = property;
   }
 
-  /**
-   * @param param1 <description>
-   * @return <description>
-   */
   public boolean equals(final Object param1) {
     if (this == param1) {
       return true;
@@ -77,11 +73,6 @@ public class BeanComparator extends ComparatorBase implements Serializable {
 
   // implementation of java.util.Comparator interface
 
-  /**
-   * @param param1 <description>
-   * @param param2 <description>
-   * @return <description>
-   */
   public int compare(final Object param1, final Object param2) {
     final Object obj1;
     final Object obj2;
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java
index 28ae643..d770780 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ValueExpressionComparator.java
@@ -108,11 +108,6 @@ public class ValueExpressionComparator extends ComparatorBase {
 
   // implementation of java.util.Comparator interface
 
-  /**
-   * @param param1 <description>
-   * @param param2 <description>
-   * @return <description>
-   */
   public int compare(final Object param1, final Object param2) {
     final Object obj1;
     final Object obj2;
diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
index 63b703f..ef33662 100644
--- a/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
+++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/webapp/TobagoResponseWriter.java
@@ -67,7 +67,7 @@ public abstract class TobagoResponseWriter extends ResponseWriter {
    * @deprecated Should not directly called via this interface. There is be a special method which might be better.
    */
   @Deprecated
-  public abstract void writeAttribute(String name, Object value, final String property) throws IOException;
+  public abstract void writeAttribute(String name, Object value, String property) throws IOException;
 
   /**
    * @deprecated Should not directly called via this interface. There is be a special method which might be better.
diff --git a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java
index 8002d7f..abd0cd4 100644
--- a/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java
+++ b/tobago-core/src/test/java/org/apache/myfaces/tobago/internal/taglib/component/GenericTestBase.java
@@ -137,12 +137,12 @@ public abstract class GenericTestBase extends AbstractTobagoTestBase {
     for (final PropertyDescriptor descriptor : descriptors) {
       if (isTagProperty(descriptor)) {
         final String name = descriptor.getName();
-        final Class propertyType = descriptor.getPropertyType();
+        final Class<?> propertyType = descriptor.getPropertyType();
         Object value = null;
         if (propertyType == String.class) {
-          value = new String("bla");
+          value = "bla";
         } else if (propertyType == Integer.TYPE) {
-          value = new Integer(42);
+          value = 42;
         } else if (propertyType == Boolean.TYPE) {
           value = Boolean.TRUE;
         } else {
diff --git a/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java b/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java
index 5bddf04..d008438 100644
--- a/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java
+++ b/tobago-example/tobago-example-addressbook-cdi/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java
@@ -50,8 +50,8 @@ public class StartupPhaseListener implements PhaseListener {
       LOG.debug("externalContext.getRequestPathInfo() = '" + pathInfo + "'");
     }
 
-    if (pathInfo.equals("/error.xhtml") || // todo: not nice, find a declarative way.
-        pathInfo.startsWith("/auth/")) {
+    if (pathInfo.equals("/error.xhtml") // todo: not nice, find a declarative way.
+        || pathInfo.startsWith("/auth/")) {
       final Object session = externalContext.getSession(false);
       if (session != null) {
         externalContext.getSessionMap().put(LOGGED_IN, Boolean.FALSE);
diff --git a/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java b/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java
index 5bddf04..d008438 100644
--- a/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java
+++ b/tobago-example/tobago-example-addressbook/src/main/java/org/apache/myfaces/tobago/example/addressbook/web/StartupPhaseListener.java
@@ -50,8 +50,8 @@ public class StartupPhaseListener implements PhaseListener {
       LOG.debug("externalContext.getRequestPathInfo() = '" + pathInfo + "'");
     }
 
-    if (pathInfo.equals("/error.xhtml") || // todo: not nice, find a declarative way.
-        pathInfo.startsWith("/auth/")) {
+    if (pathInfo.equals("/error.xhtml") // todo: not nice, find a declarative way.
+        || pathInfo.startsWith("/auth/")) {
       final Object session = externalContext.getSession(false);
       if (session != null) {
         externalContext.getSessionMap().put(LOGGED_IN, Boolean.FALSE);
diff --git a/tobago-example/tobago-example-demo/pom.xml b/tobago-example/tobago-example-demo/pom.xml
index 8782ffb..4088b56 100644
--- a/tobago-example/tobago-example-demo/pom.xml
+++ b/tobago-example/tobago-example-demo/pom.xml
@@ -643,12 +643,12 @@
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-checkstyle-plugin</artifactId>
-            <version>2.9</version>
+            <version>3.1.2</version>
             <configuration>
               <configLocation>META-INF/checkstyle-tobago.xml</configLocation>
               <includes>**/*.xhtml,**/*.jsp,**/*.tag</includes>
               <excludes>**/*.java</excludes>
-              <sourceDirectory>src/main/webapp</sourceDirectory>
+              <sourceDirectories>src/main/webapp</sourceDirectories>
             </configuration>
             <dependencies>
               <dependency>
diff --git a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/clientConfig/ClientConfigController.java b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/clientConfig/ClientConfigController.java
index 837d10a..66e56f9 100644
--- a/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/clientConfig/ClientConfigController.java
+++ b/tobago-example/tobago-example-demo/src/main/java/org/apache/myfaces/tobago/example/demo/clientConfig/ClientConfigController.java
@@ -170,7 +170,7 @@ public class ClientConfigController {
   public String getLocalizedLocale() {
     if (locale != null) {
       return locale.getDisplayName(locale);
-    } else{
+    } else {
       return null;
     }
   }
diff --git a/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java b/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java
index 098d7f8..b0a6aa6 100644
--- a/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java
+++ b/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/PageActionUtil.java
@@ -23,7 +23,7 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * @deprecated use {@link PageAction.parse()}
+ * @deprecated use {@link PageAction#parse(String)}
  */
 @Deprecated
 public class PageActionUtil {
diff --git a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java
index b857d22..aac1eaf 100644
--- a/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java
+++ b/tobago-theme/tobago-theme-standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/JsonUtils.java
@@ -88,7 +88,7 @@ public class JsonUtils {
 
     final Map<String, Command> other = commandMap.getOther();
     if (other != null) {
-      for(final Map.Entry<String, Command> entry : other.entrySet()) {
+      for (final Map.Entry<String, Command> entry : other.entrySet()) {
         encode(builder, entry.getKey(), entry.getValue());
       }
     }