You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/12/22 15:40:56 UTC

(commons-email) branch master updated: Fix Checkstyle copfig and issues

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-email.git


The following commit(s) were added to refs/heads/master by this push:
     new b252a1c  Fix Checkstyle copfig and issues
b252a1c is described below

commit b252a1cd9153f46e87e1b4f4ae576f3c26142965
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Dec 22 10:40:44 2023 -0500

    Fix Checkstyle copfig and issues
    
    - Let Apache RAT deal with headers
    - Use a for each loop
---
 pom.xml                                            | 21 +++++++-----
 src/changes/changes.xml                            |  4 +++
 src/conf/HEADER.txt                                | 16 ---------
 src/conf/checkstyle.xml                            | 38 ++++++++++------------
 .../apache/commons/mail/ByteArrayDataSource.java   |  1 +
 .../apache/commons/mail/DataSourceResolver.java    |  4 +--
 src/main/java/org/apache/commons/mail/Email.java   |  3 ++
 .../org/apache/commons/mail/MultiPartEmail.java    |  3 +-
 .../mail/activation/InputStreamDataSource.java     | 14 +++++++-
 .../commons/mail/activation/PathDataSource.java    | 11 +++++++
 .../mail/resolver/DataSourceCompositeResolver.java |  3 +-
 .../mail/resolver/DataSourcePathResolver.java      |  8 ++++-
 12 files changed, 74 insertions(+), 52 deletions(-)

diff --git a/pom.xml b/pom.xml
index 0c50f69..1d8ed22 100644
--- a/pom.xml
+++ b/pom.xml
@@ -309,6 +309,19 @@
 
     <build>
         <defaultGoal>clean verify apache-rat:check checkstyle:check japicmp:cmp pmd:check pmd:cpd-check spotbugs:check javadoc:javadoc</defaultGoal>
+        <pluginManagement>
+			<plugins>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-checkstyle-plugin</artifactId>
+                    <configuration>
+                        <configLocation>${basedir}/src/conf/checkstyle.xml</configLocation>
+                        <enableRulesSummary>false</enableRulesSummary>
+                        <violationSeverity>warning</violationSeverity>
+                    </configuration>
+                </plugin>
+			</plugins>
+		</pluginManagement>
         <plugins>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
@@ -414,10 +427,6 @@
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-checkstyle-plugin</artifactId>
-            <configuration>
-              <configLocation>${basedir}/src/conf/checkstyle.xml</configLocation>
-              <enableRulesSummary>false</enableRulesSummary>
-            </configuration>
           </plugin>
       </plugins>
     </build>
@@ -450,10 +459,6 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-checkstyle-plugin</artifactId>
-                <configuration>
-                    <configLocation>${basedir}/src/conf/checkstyle.xml</configLocation>
-                    <enableRulesSummary>false</enableRulesSummary>
-                </configuration>
             </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index e258bc0..d250acf 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -24,6 +24,10 @@
   </properties>
 
   <body>
+    <release version="1.6.1" date="202Y-MM-DD" description="Feature release (Java 8 or above).">
+      <!-- FIX -->
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Checkstyle configuration.</action>
+    </release>
     <release version="1.6.0" date="2023-12-17" description="Feature release (Java 8 or above).">
       <!-- FIX -->
       <action issue="EMAIL-190" type="fix" due-to="sgoeschl">Fix broken JDK 9 build by updating "easymock" and other dependencies.</action>
diff --git a/src/conf/HEADER.txt b/src/conf/HEADER.txt
deleted file mode 100644
index 2944f98..0000000
--- a/src/conf/HEADER.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-/*
- * 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.
- */
diff --git a/src/conf/checkstyle.xml b/src/conf/checkstyle.xml
index 5a2a5ee..2cac44c 100644
--- a/src/conf/checkstyle.xml
+++ b/src/conf/checkstyle.xml
@@ -1,15 +1,24 @@
 <?xml version="1.0"?>
-<!-- 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. -->
+<!--
+   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.
+-->
 <!DOCTYPE module PUBLIC
     "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
     "https://checkstyle.org/dtds/configuration_1_3.dtd">
 
-<!-- Checkstyle configuration that checks the commons-configuration coding conventions -->
-
 <module name="Checker">
   <property name="localeLanguage" value="en" />
   <property name="severity" value="warning" />
@@ -28,12 +37,6 @@
   <!-- See http://checkstyle.sf.net/config_misc.html#Translation -->
   <module name="Translation" />
 
-  <!-- Checks for Headers -->
-  <!-- See http://checkstyle.sf.net/config_header.html -->
-  <module name="Header">
-    <property name="headerFile" value="${checkstyle.header.file}" />
-    <property name="fileExtensions" value="java" />
-  </module>
   <module name="FileLength" />
   <module name="FileTabCharacter" />
 
@@ -101,13 +104,9 @@
       <property name="option" value="text" />
       <property name="tokens" value="LITERAL_CATCH" />
     </module>
-    <module name="LeftCurly">
-      <property name="option" value="nl" />
-    </module>
+    <module name="LeftCurly" />
     <module name="NeedBraces" />
-    <module name="RightCurly">
-      <property name="option" value="alone" />
-    </module>
+    <module name="RightCurly" />
 
     <!-- Checks for common coding problems -->
     <!-- See http://checkstyle.sf.net/config_coding.html -->
@@ -124,7 +123,6 @@
     <module name="SuperClone" />
     <module name="SuperFinalize" />
     <module name="IllegalType" />
-    <module name="DeclarationOrder" />
     <module name="ExplicitInitialization" />
     <module name="DefaultComesLast" />
     <module name="FallThrough" />
diff --git a/src/main/java/org/apache/commons/mail/ByteArrayDataSource.java b/src/main/java/org/apache/commons/mail/ByteArrayDataSource.java
index 72b05c2..9aee2ed 100644
--- a/src/main/java/org/apache/commons/mail/ByteArrayDataSource.java
+++ b/src/main/java/org/apache/commons/mail/ByteArrayDataSource.java
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.commons.mail;
 
 import java.io.BufferedInputStream;
diff --git a/src/main/java/org/apache/commons/mail/DataSourceResolver.java b/src/main/java/org/apache/commons/mail/DataSourceResolver.java
index 7158f4d..c76f136 100644
--- a/src/main/java/org/apache/commons/mail/DataSourceResolver.java
+++ b/src/main/java/org/apache/commons/mail/DataSourceResolver.java
@@ -34,7 +34,7 @@ public interface DataSourceResolver {
      * @return the {@code DataSource}
      * @throws IOException the resource was not found
      */
-    DataSource resolve(final String resourceLocation) throws IOException;
+    DataSource resolve(String resourceLocation) throws IOException;
 
     /**
      * Resolves the given resource location to a {@code DataSource}.
@@ -44,5 +44,5 @@ public interface DataSourceResolver {
      * @return the data source containing the resource or null if the resource was not found in lenient mode
      * @throws IOException resolving the resource failed
      */
-    DataSource resolve(final String resourceLocation, final boolean isLenient) throws IOException;
+    DataSource resolve(String resourceLocation, boolean isLenient) throws IOException;
 }
diff --git a/src/main/java/org/apache/commons/mail/Email.java b/src/main/java/org/apache/commons/mail/Email.java
index a6bd957..3bd3395 100644
--- a/src/main/java/org/apache/commons/mail/Email.java
+++ b/src/main/java/org/apache/commons/mail/Email.java
@@ -55,6 +55,9 @@ import org.apache.commons.mail.util.IDNEmailAddressConverter;
  */
 public abstract class Email {
 
+    /**
+     * Empty array.
+     */
     private static final InternetAddress[] EMPTY_INTERNET_ADDRESS_ARRAY = {};
 
     /** @deprecated since 1.3, use {@link EmailConstants#SENDER_EMAIL} instead */
diff --git a/src/main/java/org/apache/commons/mail/MultiPartEmail.java b/src/main/java/org/apache/commons/mail/MultiPartEmail.java
index aca2988..482ad4e 100644
--- a/src/main/java/org/apache/commons/mail/MultiPartEmail.java
+++ b/src/main/java/org/apache/commons/mail/MultiPartEmail.java
@@ -309,8 +309,7 @@ public class MultiPartEmail extends Email {
                 final BodyPart body = getPrimaryBodyPart();
                 try {
                     body.getContent();
-                } catch (final IOException e) // NOPMD
-                {
+                } catch (final IOException e) { // NOPMD
                     // do nothing here.
                     // content will be set to an empty string as a result.
                     // (Should this really be rethrown as an email exception?)
diff --git a/src/main/java/org/apache/commons/mail/activation/InputStreamDataSource.java b/src/main/java/org/apache/commons/mail/activation/InputStreamDataSource.java
index 07e96f7..f8f2b78 100644
--- a/src/main/java/org/apache/commons/mail/activation/InputStreamDataSource.java
+++ b/src/main/java/org/apache/commons/mail/activation/InputStreamDataSource.java
@@ -37,8 +37,20 @@ public final class InputStreamDataSource implements DataSource {
      * Default content type documented in {@link DataSource#getContentType()}.
      */
     private static final String DEFAULT_CONTENT_TYPE = "application/octet-stream";
+
+    /**
+     * The MIME content type.
+     */
     private final String contentType;
+
+    /**
+     * The source.
+     */
     private final InputStream inputStream;
+
+    /**
+     * The optional name.
+     */
     private final String name;
 
     /**
@@ -90,4 +102,4 @@ public final class InputStreamDataSource implements DataSource {
         throw new UnsupportedOperationException();
     }
 
-}
\ No newline at end of file
+}
diff --git a/src/main/java/org/apache/commons/mail/activation/PathDataSource.java b/src/main/java/org/apache/commons/mail/activation/PathDataSource.java
index c0d11c1..bb425b1 100644
--- a/src/main/java/org/apache/commons/mail/activation/PathDataSource.java
+++ b/src/main/java/org/apache/commons/mail/activation/PathDataSource.java
@@ -40,8 +40,19 @@ import javax.activation.MimetypesFileTypeMap;
  */
 public final class PathDataSource implements DataSource {
 
+    /**
+     * The source.
+     */
     private final Path path;
+
+    /**
+     * Defaults to {@link FileTypeMap#getDefaultFileTypeMap()}.
+     */
     private final FileTypeMap typeMap;
+
+    /**
+     * NIO options to open the source Path.
+     */
     private final OpenOption[] options;
 
     /**
diff --git a/src/main/java/org/apache/commons/mail/resolver/DataSourceCompositeResolver.java b/src/main/java/org/apache/commons/mail/resolver/DataSourceCompositeResolver.java
index 99a1ed5..6574d81 100644
--- a/src/main/java/org/apache/commons/mail/resolver/DataSourceCompositeResolver.java
+++ b/src/main/java/org/apache/commons/mail/resolver/DataSourceCompositeResolver.java
@@ -76,8 +76,7 @@ public class DataSourceCompositeResolver extends DataSourceBaseResolver {
     /** {@inheritDoc} */
     @Override
     public DataSource resolve(final String resourceLocation, final boolean isLenient) throws IOException {
-        for (int i = 0; i < dataSourceResolvers.length; i++) {
-            final DataSourceResolver dataSourceResolver = dataSourceResolvers[i];
+        for (final DataSourceResolver dataSourceResolver : dataSourceResolvers) {
             final DataSource dataSource = dataSourceResolver.resolve(resourceLocation, isLenient);
             if (dataSource != null) {
                 return dataSource;
diff --git a/src/main/java/org/apache/commons/mail/resolver/DataSourcePathResolver.java b/src/main/java/org/apache/commons/mail/resolver/DataSourcePathResolver.java
index 909fb82..c179df9 100644
--- a/src/main/java/org/apache/commons/mail/resolver/DataSourcePathResolver.java
+++ b/src/main/java/org/apache/commons/mail/resolver/DataSourcePathResolver.java
@@ -34,8 +34,14 @@ import org.apache.commons.mail.activation.PathDataSource;
  */
 public final class DataSourcePathResolver extends DataSourceBaseResolver {
 
-    /** The base directory of the resource when resolving relative paths */
+    /**
+     * The base directory of the resource when resolving relative paths.
+     */
     private final Path baseDir;
+
+    /**
+     * NIO options to open the data source.
+     */
     private final OpenOption[] options;
 
     /**