james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r1079912 - in /james/imap/trunk: api/src/main/java/org/apache/james/imap/api/message/request/ api/src/main/java/org/apache/james/imap/api/message/response/ message/src/main/java/org/apache/james/imap/decode/ message/src/main/java/org/apache...
Date Wed, 09 Mar 2011 18:02:14 GMT
Author: felixk
Date: Wed Mar  9 18:02:13 2011
New Revision: 1079912

URL: http://svn.apache.org/viewvc?rev=1079912&view=rev
Log:
Fix various PMD report findings, mainly
- Methods in final classes are automatically final
- Avoid empty if statements (many of them were false positives)
- Avoid empty while statements (many of them were false positives)
- Avoid empty catch blocks (many of them were false positives)

Modified:
    james/imap/trunk/api/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
    james/imap/trunk/api/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/DecoderUtils.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/CreateCommandParser.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/main/ChannelImapResponseWriter.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ExistsResponse.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ExpungeResponse.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/FetchResponse.java
    james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/RecentResponse.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java
    james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java

Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
(original)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/message/request/SearchKey.java
Wed Mar  9 18:02:13 2011
@@ -357,7 +357,7 @@ public final class SearchKey {
      *         {@link #TYPE_SENTBEFORE}, {@link #TYPE_SENTON},
      *         {@link #TYPE_SENTSINCE}, {@link #TYPE_SINCE}; otherwise null
      */
-    public final DayMonthYear getDate() {
+    public DayMonthYear getDate() {
         return date;
     }
 
@@ -367,7 +367,7 @@ public final class SearchKey {
      * @return msn when {@link #TYPE_SEQUENCE_SET}, uids when {@link #TYPE_UID},
      *         null otherwise
      */
-    public final IdRange[] getSequenceNumbers() {
+    public IdRange[] getSequenceNumbers() {
         return sequence;
     }
 
@@ -376,7 +376,7 @@ public final class SearchKey {
      * 
      * @return the field name when {@link #TYPE_HEADER}, null otherwise
      */
-    public final String getName() {
+    public String getName() {
         return name;
     }
 
@@ -386,7 +386,7 @@ public final class SearchKey {
      * @return the size when {@link #TYPE_LARGER} or {@link #TYPE_SMALLER},
      *         otherwise 0
      */
-    public final long getSize() {
+    public long getSize() {
         return size;
     }
 
@@ -397,7 +397,7 @@ public final class SearchKey {
      *         {@link #TYPE_OR}, {@link #TYPE_AND} or {@link #TYPE_NOT}
      *         otherwise null
      */
-    public final List<SearchKey> getKeys() {
+    public List<SearchKey> getKeys() {
         return keys;
     }
 
@@ -406,7 +406,7 @@ public final class SearchKey {
      * 
      * @return the type
      */
-    public final int getType() {
+    public int getType() {
         return type;
     }
 
@@ -415,7 +415,7 @@ public final class SearchKey {
      * 
      * @return the value, or null when this type is not associated with a value.
      */
-    public final String getValue() {
+    public String getValue() {
         return value;
     }
 

Modified: james/imap/trunk/api/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/api/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/api/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java
(original)
+++ james/imap/trunk/api/src/main/java/org/apache/james/imap/api/message/response/StatusResponse.java
Wed Mar  9 18:02:13 2011
@@ -130,13 +130,13 @@ public interface StatusResponse extends 
                 "TRYCREATE");
 
         /** RFC4315 <code>APPENDUID</code> response code */
-        public static final ResponseCode appendUid(long uidValidity, IdRange[] uids) {
+        public static ResponseCode appendUid(long uidValidity, IdRange[] uids) {
             String uidParam = formatRanges(uids);
             return new ResponseCode("APPENDUID", Arrays.asList(uidParam), uidValidity, false);
         }
 
         /** RFC4315 <code>COPYUID</code> response code */
-        public static final ResponseCode copyUid(long uidValidity, IdRange[] sourceRanges,
IdRange[] targetRanges) {
+        public static ResponseCode copyUid(long uidValidity, IdRange[] sourceRanges, IdRange[]
targetRanges) {
             String source = formatRanges(sourceRanges);
             String target = formatRanges(targetRanges);
 
@@ -161,7 +161,7 @@ public interface StatusResponse extends 
          * 
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode alert() {
+        public static 	ResponseCode alert() {
             return ALERT;
         }
 
@@ -173,7 +173,7 @@ public interface StatusResponse extends 
          *            names
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode badCharset(Collection<String> charsetNames)
{
+        public static ResponseCode badCharset(Collection<String> charsetNames) {
             return new ResponseCode("BADCHARSET", charsetNames);
         }
 
@@ -182,7 +182,7 @@ public interface StatusResponse extends 
          * 
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode parse() {
+        public static ResponseCode parse() {
             return PARSE;
         }
 
@@ -193,7 +193,7 @@ public interface StatusResponse extends 
          *            <code>Collection<String></code> containing flag names
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode permanentFlags(Flags flags) {
+        public static ResponseCode permanentFlags(Flags flags) {
             return new ResponseCode("PERMANENTFLAGS", MessageFlags.names(flags));
         }
 
@@ -202,7 +202,7 @@ public interface StatusResponse extends 
          * 
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode readOnly() {
+        public static ResponseCode readOnly() {
             return READ_ONLY;
         }
 
@@ -211,7 +211,7 @@ public interface StatusResponse extends 
          * 
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode readWrite() {
+        public static ResponseCode readWrite() {
             return READ_WRITE;
         }
 
@@ -220,7 +220,7 @@ public interface StatusResponse extends 
          * 
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode tryCreate() {
+        public static ResponseCode tryCreate() {
             return TRYCREATE;
         }
 
@@ -231,7 +231,7 @@ public interface StatusResponse extends 
          *            positive non-zero integer
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode uidValidity(long uid) {
+        public static ResponseCode uidValidity(long uid) {
             return new ResponseCode("UIDVALIDITY", uid);
         }
 
@@ -242,7 +242,7 @@ public interface StatusResponse extends 
          *            positive non-zero integer
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode unseen(int numberUnseen) {
+        public static ResponseCode unseen(int numberUnseen) {
             return new ResponseCode("UNSEEN", numberUnseen);
         }
 
@@ -253,7 +253,7 @@ public interface StatusResponse extends 
          *            positive non-zero integer
          * @return <code>ResponseCode</code>, not null
          */
-        public static final ResponseCode uidNext(long uid) {
+        public static ResponseCode uidNext(long uid) {
             return new ResponseCode("UIDNEXT", uid);
         }
 
@@ -306,7 +306,7 @@ public interface StatusResponse extends 
             this.number = number;
         }
 
-        public final String getCode() {
+        public String getCode() {
             return code;
         }
 
@@ -315,11 +315,11 @@ public interface StatusResponse extends 
          * 
          * @return the number, or zero if no number has been set
          */
-        public final long getNumber() {
+        public long getNumber() {
             return number;
         }
 
-        public final boolean useParens() {
+        public boolean useParens() {
             return useParens;
         }
         
@@ -329,7 +329,7 @@ public interface StatusResponse extends 
          * @return the parameters <code>Collection</code> of
          *         <code>String</code> parameters, not null
          */
-        public final Collection<String> getParameters() {
+        public Collection<String> getParameters() {
             return parameters;
         }
 

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/DecoderUtils.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/DecoderUtils.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/DecoderUtils.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/DecoderUtils.java
Wed Mar  9 18:02:13 2011
@@ -77,7 +77,7 @@ public final class DecoderUtils {
         } else if (flagString.equalsIgnoreCase(MessageFlags.SEEN_ALL_CAPS)) {
             flags.add(Flags.Flag.SEEN);
         } else {
-            if (flagString.equalsIgnoreCase(MessageFlags.RECENT_ALL_CAPS)) {
+            if (flagString.equalsIgnoreCase(MessageFlags.RECENT_ALL_CAPS)) { // NOPMD keep
comment
                 // RFC3501 specifically excludes /Recent
                 // The /Recent flag should be set automatically by the server
             } else {
@@ -96,7 +96,7 @@ public final class DecoderUtils {
      * @throws DecodingException
      *             when this conversion fails
      */
-    public static final Date decodeDateTime(CharSequence chars)
+    public static Date decodeDateTime(CharSequence chars)
             throws DecodingException {
         if (isDateTime(chars)) {
             final char dayHigh = chars.charAt(0);
@@ -469,7 +469,7 @@ public final class DecoderUtils {
      * @throws DecodingException
      *             if the char is not a digit
      */
-    public static final int decodeDigit(char character)
+    public static int decodeDigit(char character)
             throws DecodingException {
         final int result = character - ASCII_ZERO;
         if (result < 0 || result > 9) {

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/CreateCommandParser.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/CreateCommandParser.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/CreateCommandParser.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/decode/parser/CreateCommandParser.java
Wed Mar  9 18:02:13 2011
@@ -57,7 +57,7 @@ public class CreateCommandParser extends
             // RFC3501@6.3.3p2
             // When mailbox name is suffixed with hierarchy separator
             // name created must remove tailing delimiter
-            if (mailboxName.endsWith(Character.toString(mailboxSession.getPathDelimiter())))
{
+            if (mailboxName.endsWith(Character.toString(mailboxSession.getPathDelimiter())))
{ // NOPMD keep comment
                 mailboxName = mailboxName.substring(0, mailboxName.length() -1);
             }
         }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/main/ChannelImapResponseWriter.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/main/ChannelImapResponseWriter.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/main/ChannelImapResponseWriter.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/main/ChannelImapResponseWriter.java
Wed Mar  9 18:02:13 2011
@@ -53,7 +53,7 @@ public class ChannelImapResponseWriter e
      * @see org.apache.james.imap.main.AbstractImapResponseWriter#write(java.nio.ByteBuffer)
      */
     protected void write(final ByteBuffer buffer) throws IOException {
-        while (out.write(buffer) > 0) {
+        while (out.write(buffer) > 0) { // NOPMD false positive
             // Write all
         }
     }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ExistsResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ExistsResponse.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ExistsResponse.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ExistsResponse.java
Wed Mar  9 18:02:13 2011
@@ -29,7 +29,7 @@ public final class ExistsResponse implem
         this.numberOfMessages = numberOfMessages;
     }
 
-    public final long getNumberOfMessages() {
+    public long getNumberOfMessages() {
         return numberOfMessages;
     }
 }

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ExpungeResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ExpungeResponse.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ExpungeResponse.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/ExpungeResponse.java
Wed Mar  9 18:02:13 2011
@@ -30,7 +30,7 @@ public final class ExpungeResponse imple
         this.messageSequenceNumber = messageSequenceNumber;
     }
 
-    public final int getMessageSequenceNumber() {
+    public int getMessageSequenceNumber() {
         return messageSequenceNumber;
     }
 

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/FetchResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/FetchResponse.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/FetchResponse.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/FetchResponse.java
Wed Mar  9 18:02:13 2011
@@ -90,7 +90,7 @@ public final class FetchResponse impleme
      * 
      * @return message number
      */
-    public final int getMessageNumber() {
+    public int getMessageNumber() {
         return messageNumber;
     }
 
@@ -120,7 +120,7 @@ public final class FetchResponse impleme
      * @return the internalDate, or null if the <code>FETCH</code> did not
      *         include <code>INTERNALDATE</code>
      */
-    public final Date getInternalDate() {
+    public Date getInternalDate() {
         return internalDate;
     }
 
@@ -130,7 +130,7 @@ public final class FetchResponse impleme
      * @return the size, or null if the <code>FETCH</code> did not include
      *         <code>SIZE</code>
      */
-    public final Long getSize() {
+    public Long getSize() {
         return size;
     }
 
@@ -140,7 +140,7 @@ public final class FetchResponse impleme
      * @return the envelope, or null if the <code>FETCH</code> did not include
      *         <code>ENVELOPE</code>
      */
-    public final Envelope getEnvelope() {
+    public Envelope getEnvelope() {
         return envelope;
     }
 
@@ -150,7 +150,7 @@ public final class FetchResponse impleme
      * @return <code>List</code> of <code>BodyElement</code>'s, or
null if
      *         the <code>FETCH</code> did not include body elements
      */
-    public final List<BodyElement> getElements() {
+    public List<BodyElement> getElements() {
         return elements;
     }
 

Modified: james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/RecentResponse.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/RecentResponse.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/RecentResponse.java
(original)
+++ james/imap/trunk/message/src/main/java/org/apache/james/imap/message/response/RecentResponse.java
Wed Mar  9 18:02:13 2011
@@ -30,7 +30,7 @@ public final class RecentResponse implem
         this.numberFlaggedRecent = numberFlaggedRecent;
     }
 
-    public final int getNumberFlaggedRecent() {
+    public int getNumberFlaggedRecent() {
         return numberFlaggedRecent;
     }
 }

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AbstractMailboxProcessor.java
Wed Mar  9 18:02:13 2011
@@ -232,7 +232,7 @@ abstract public class AbstractMailboxPro
         session.getLog().info(message.toString());
         session.getLog().debug(message.toString(), e);
         // TODO: consider whether error message should be passed to the user
-        final StatusResponse response = factory.untaggedNo(message);;
+        final StatusResponse response = factory.untaggedNo(message);
         responder.respond(response);
     }
 

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/AppendProcessor.java
Wed Mar  9 18:02:13 2011
@@ -90,8 +90,8 @@ public class AppendProcessor extends Abs
     
     private void consume(InputStream in) {
         try {
-            while(in.read() != -1);
-        } catch (IOException e1) {
+            while(in.read() != -1); // NOPMD false positive
+        } catch (IOException e1) { // NOPMD false positive
             // just consume
         } 
     }

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/RenameProcessor.java
Wed Mar  9 18:02:13 2011
@@ -55,12 +55,12 @@ public class RenameProcessor extends Abs
             MailboxSession mailboxsession = ImapSessionUtils.getMailboxSession(session);
             mailboxManager.renameMailbox(existingPath, newPath, mailboxsession);
 
-            if (existingPath.getName().equalsIgnoreCase(ImapConstants.INBOX_NAME)) {
-                if (mailboxManager.mailboxExists(existingPath, mailboxsession) == false)
{
-                    mailboxManager.createMailbox(existingPath, mailboxsession);
-                }
-              
-            }
+	    if (existingPath.getName().equalsIgnoreCase(
+		    ImapConstants.INBOX_NAME)
+		    && mailboxManager.mailboxExists(existingPath,
+			    mailboxsession) == false) {
+		mailboxManager.createMailbox(existingPath, mailboxsession);
+	    }
             okComplete(command, tag, responder);
             unsolicitedResponses(session, responder, false);
         } catch (MailboxExistsException e) {

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/HeaderBodyElement.java
Wed Mar  9 18:02:13 2011
@@ -88,11 +88,11 @@ final class HeaderBodyElement implements
         for (final Iterator<MessageResult.Header> it = headers.iterator(); it.hasNext();)
{
             MessageResult.Header header = it.next();
             header.writeTo(channel);
-            while (channel.write(endLine) > 0) {
+            while (channel.write(endLine) > 0) { // NOPMD false positive
             }
             endLine.rewind();
         }
-        while (channel.write(endLine) > 0) {
+        while (channel.write(endLine) > 0) { // NOPMD false positive
         }
     }
 

Modified: james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java
URL: http://svn.apache.org/viewvc/james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java?rev=1079912&r1=1079911&r2=1079912&view=diff
==============================================================================
--- james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java
(original)
+++ james/imap/trunk/processor/src/main/java/org/apache/james/imap/processor/fetch/MessageResultUtils.java
Wed Mar  9 18:02:13 2011
@@ -24,8 +24,6 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 
-import javax.mail.MessagingException;
-
 import org.apache.james.mailbox.MailboxException;
 import org.apache.james.mailbox.MessageResult;
 



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message