Merge branch 'findbugs_fixes'

This commit is contained in:
cketti 2015-01-03 06:33:43 +01:00
commit ddd78bd3e3
18 changed files with 42 additions and 34 deletions

View file

@ -2,5 +2,8 @@
<FindBugsFilter>
<Match>
<Package name="~com\.fsck\.k9.*" />
<Not>
<Bug pattern="VA_FORMAT_STRING_USES_NEWLINE" />
</Not>
</Match>
</FindBugsFilter>

View file

@ -15,8 +15,6 @@ public abstract class Multipart implements CompositeBody {
private final List<BodyPart> mParts = new ArrayList<BodyPart>();
private String mContentType;
public void addBodyPart(BodyPart part) {
mParts.add(part);
part.setParent(this);
@ -30,9 +28,7 @@ public abstract class Multipart implements CompositeBody {
return Collections.unmodifiableList(mParts);
}
public String getContentType() {
return mContentType;
}
public abstract String getContentType();
public int getCount() {
return mParts.size();

View file

@ -1906,7 +1906,10 @@ public class WebDavStore extends RemoteStore {
@Override
public boolean equals(Object o) {
return false;
if (o instanceof WebDavFolder) {
return ((WebDavFolder) o).mName.equals(mName);
}
return super.equals(o);
}
@Override

View file

@ -149,7 +149,7 @@ public class K9 extends Application {
*
* Feature is enabled when DEBUG == true
*/
public static String ERROR_FOLDER_NAME = "K9mail-errors";
public static final String ERROR_FOLDER_NAME = "K9mail-errors";
/**
* A reference to the {@link SharedPreferences} used for caching the last known database
@ -280,7 +280,7 @@ public class K9 extends Application {
* on each new folder and can be incremented with "Load more messages..." by the
* VISIBLE_LIMIT_INCREMENT
*/
public static int DEFAULT_VISIBLE_LIMIT = 25;
public static final int DEFAULT_VISIBLE_LIMIT = 25;
/**
* The maximum size of an attachment we're willing to download (either View or Save)
@ -295,7 +295,7 @@ public class K9 extends Application {
* until the app is killed and restarted
*/
public static int MAX_SEND_ATTEMPTS = 5;
public static final int MAX_SEND_ATTEMPTS = 5;
/**
* Max time (in millis) the wake lock will be held for when background sync is happening

View file

@ -9,7 +9,6 @@ import java.util.List;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
@ -29,7 +28,7 @@ import com.fsck.k9.R;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.controller.MessagingListener;
import com.fsck.k9.mail.Folder;
import com.fsck.k9.mail.MessagingException;
public class ChooseFolder extends K9ListActivity {
public static final String EXTRA_ACCOUNT = "com.fsck.k9.ChooseFolder_account";
@ -266,7 +265,6 @@ public class ChooseFolder extends K9ListActivity {
return;
}
Account.FolderMode aMode = mMode;
Preferences prefs = Preferences.getPreferences(getApplication().getApplicationContext());
List<String> newFolders = new ArrayList<String>();
List<String> topFolders = new ArrayList<String>();

View file

@ -20,7 +20,7 @@ public class FolderInfoHolder implements Comparable<FolderInfoHolder> {
@Override
public boolean equals(Object o) {
return this.name.equals(((FolderInfoHolder)o).name);
return o instanceof FolderInfoHolder && name.equals(((FolderInfoHolder) o).name);
}
@Override

View file

@ -746,7 +746,6 @@ public class FolderList extends K9ListActivity {
List<FolderInfoHolder> topFolders = new LinkedList<FolderInfoHolder>();
Account.FolderMode aMode = account.getFolderDisplayMode();
Preferences prefs = Preferences.getPreferences(getApplication().getApplicationContext());
for (Folder folder : folders) {
Folder.FolderClass fMode = folder.getDisplayClass();

View file

@ -2888,7 +2888,7 @@ public class MessageCompose extends K9Activity implements OnClickListener,
int cursorPosition = 0;
if (k9identity.containsKey(IdentityField.CURSOR_POSITION)) {
try {
cursorPosition = Integer.valueOf(k9identity.get(IdentityField.CURSOR_POSITION)).intValue();
cursorPosition = Integer.parseInt(k9identity.get(IdentityField.CURSOR_POSITION));
} catch (Exception e) {
Log.e(K9.LOG_TAG, "Could not parse cursor position for MessageCompose; continuing.", e);
}

View file

@ -156,8 +156,8 @@ public class ContactPictureLoader {
}
int val = address.hashCode();
int rgb = CONTACT_DUMMY_COLORS_ARGB[Math.abs(val) % CONTACT_DUMMY_COLORS_ARGB.length];
return rgb;
int colorIndex = (val & Integer.MAX_VALUE) % CONTACT_DUMMY_COLORS_ARGB.length;
return CONTACT_DUMMY_COLORS_ARGB[colorIndex];
}
private String calcUnknownContactLetter(Address address) {

View file

@ -65,12 +65,12 @@ public class EmailProviderCacheCursor extends CursorWrapper {
String value = mCache.getValueForMessage(messageId, columnName);
if (value != null) {
return Integer.valueOf(value);
return Integer.parseInt(value);
}
value = mCache.getValueForThread(threadRootId, columnName);
if (value != null) {
return Integer.valueOf(value);
return Integer.parseInt(value);
}
return super.getInt(columnIndex);

View file

@ -5267,7 +5267,6 @@ public class MessagingController implements Runnable {
if (previousPusher != null) {
previousPusher.stop();
}
Preferences prefs = Preferences.getPreferences(context);
Account.FolderMode aDisplayMode = account.getFolderDisplayMode();
Account.FolderMode aPushMode = account.getFolderPushMode();

View file

@ -13,11 +13,11 @@ import com.fsck.k9.mail.internet.MimeUtility;
public class CryptoHelper {
public static Pattern PGP_MESSAGE =
public static final Pattern PGP_MESSAGE =
Pattern.compile(".*?(-----BEGIN PGP MESSAGE-----.*?-----END PGP MESSAGE-----).*",
Pattern.DOTALL);
public static Pattern PGP_SIGNED_MESSAGE =
public static final Pattern PGP_SIGNED_MESSAGE =
Pattern.compile(
".*?(-----BEGIN PGP SIGNED MESSAGE-----.*?-----BEGIN PGP SIGNATURE-----.*?-----END PGP SIGNATURE-----).*",
Pattern.DOTALL);

View file

@ -145,7 +145,7 @@ public class TimePickerPreference extends DialogPreference implements
return -1;
}
return Integer.valueOf(time.split(":")[0]);
return Integer.parseInt(time.split(":")[0]);
}
/**
@ -159,7 +159,7 @@ public class TimePickerPreference extends DialogPreference implements
return -1;
}
return Integer.valueOf(time.split(":")[1]);
return Integer.parseInt(time.split(":")[1]);
}
/**

View file

@ -115,7 +115,7 @@ public class K9RemoteControl {
public final static String K9_THEME_LIGHT = "LIGHT";
public final static String K9_THEME_DARK = "DARK";
protected static String LOG_TAG = "K9RemoteControl";
protected static final String LOG_TAG = "K9RemoteControl";
public static void set(Context context, Intent broadcastIntent) {
broadcastIntent.setAction(K9RemoteControl.K9_SET);

View file

@ -138,6 +138,16 @@ public interface SearchSpecification extends Parcelable {
return false;
}
@Override
public int hashCode() {
int result = 1;
result = 31 * result + attribute.hashCode();
result = 31 * result + field.hashCode();
result = 31 * result + value.hashCode();
return result;
}
@Override
public int describeContents() {
return 0;
@ -164,4 +174,4 @@ public interface SearchSpecification extends Parcelable {
}
};
}
}
}

View file

@ -15,12 +15,12 @@ import com.fsck.k9.K9;
public class BootReceiver extends CoreReceiver {
public static String FIRE_INTENT = "com.fsck.k9.service.BroadcastReceiver.fireIntent";
public static String SCHEDULE_INTENT = "com.fsck.k9.service.BroadcastReceiver.scheduleIntent";
public static String CANCEL_INTENT = "com.fsck.k9.service.BroadcastReceiver.cancelIntent";
public static final String FIRE_INTENT = "com.fsck.k9.service.BroadcastReceiver.fireIntent";
public static final String SCHEDULE_INTENT = "com.fsck.k9.service.BroadcastReceiver.scheduleIntent";
public static final String CANCEL_INTENT = "com.fsck.k9.service.BroadcastReceiver.cancelIntent";
public static String ALARMED_INTENT = "com.fsck.k9.service.BroadcastReceiver.pendingIntent";
public static String AT_TIME = "com.fsck.k9.service.BroadcastReceiver.atTime";
public static final String ALARMED_INTENT = "com.fsck.k9.service.BroadcastReceiver.pendingIntent";
public static final String AT_TIME = "com.fsck.k9.service.BroadcastReceiver.atTime";
@Override
public Integer receive(Context context, Intent intent, Integer tmpWakeLockId) {

View file

@ -16,9 +16,9 @@ import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
public class CoreReceiver extends BroadcastReceiver {
public static String WAKE_LOCK_RELEASE = "com.fsck.k9.service.CoreReceiver.wakeLockRelease";
public static final String WAKE_LOCK_RELEASE = "com.fsck.k9.service.CoreReceiver.wakeLockRelease";
public static String WAKE_LOCK_ID = "com.fsck.k9.service.CoreReceiver.wakeLockId";
public static final String WAKE_LOCK_ID = "com.fsck.k9.service.CoreReceiver.wakeLockId";
private static ConcurrentHashMap<Integer, TracingWakeLock> wakeLocks = new ConcurrentHashMap<Integer, TracingWakeLock>();
private static AtomicInteger wakeLockSeq = new AtomicInteger(0);

View file

@ -57,7 +57,7 @@ import com.fsck.k9.mail.power.TracingPowerManager.TracingWakeLock;
*/
public abstract class CoreService extends Service {
public static String WAKE_LOCK_ID = "com.fsck.k9.service.CoreService.wakeLockId";
public static final String WAKE_LOCK_ID = "com.fsck.k9.service.CoreService.wakeLockId";
private static ConcurrentHashMap<Integer, TracingWakeLock> sWakeLocks =
new ConcurrentHashMap<Integer, TracingWakeLock>();