Fixed SpotBugs violations, so that at least the most severe checks pass
This commit is contained in:
parent
3946f986d7
commit
71184ee5d4
|
@ -94,8 +94,5 @@ workflows:
|
|||
name: SpotBugs
|
||||
build-steps:
|
||||
- run:
|
||||
name: SpotBugs (Modules with Play flavour)
|
||||
command: ./gradlew spotbugsPlayDebug | grep "\[SpotBugs\]"
|
||||
- run:
|
||||
name: SpotBugs (Modules without Play flavour)
|
||||
command: ./gradlew spotbugsDebug | grep "\[SpotBugs\]"
|
||||
name: SpotBugs
|
||||
command: ./gradlew spotbugsPlayDebug spotbugsDebug 2>&1 | grep -i "spotbugs"
|
||||
|
|
|
@ -188,7 +188,9 @@ public class MainActivity extends CastEnabledActivity {
|
|||
|
||||
public void setupToolbarToggle(@NonNull Toolbar toolbar, boolean displayUpArrow) {
|
||||
if (drawerLayout != null) { // Tablet layout does not have a drawer
|
||||
drawerLayout.removeDrawerListener(drawerToggle);
|
||||
if (drawerToggle != null) {
|
||||
drawerLayout.removeDrawerListener(drawerToggle);
|
||||
}
|
||||
drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, toolbar,
|
||||
R.string.drawer_open, R.string.drawer_close);
|
||||
drawerLayout.addDrawerListener(drawerToggle);
|
||||
|
|
|
@ -58,9 +58,8 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder>
|
|||
*/
|
||||
public static final String SUBSCRIPTION_LIST_TAG = "SubscriptionList";
|
||||
|
||||
private static List<String> fragmentTags;
|
||||
private static String[] titles;
|
||||
|
||||
private final List<String> fragmentTags = new ArrayList<>();
|
||||
private final String[] titles;
|
||||
private final ItemAccess itemAccess;
|
||||
private final WeakReference<Activity> activity;
|
||||
public boolean showSubscriptionList = true;
|
||||
|
@ -98,7 +97,8 @@ public class NavListAdapter extends RecyclerView.Adapter<NavListAdapter.Holder>
|
|||
showSubscriptionList = false;
|
||||
}
|
||||
|
||||
fragmentTags = newTags;
|
||||
fragmentTags.clear();
|
||||
fragmentTags.addAll(newTags);
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ public class ProxyDialog {
|
|||
|
||||
private boolean checkPort() {
|
||||
int port = getPort();
|
||||
if(port < 0 && port > 65535) {
|
||||
if (port < 0 || port > 65535) {
|
||||
etPort.setError(context.getString(R.string.proxy_port_invalid_error));
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ public class PodcastSearcherRegistry {
|
|||
private PodcastSearcherRegistry() {
|
||||
}
|
||||
|
||||
public static List<SearcherInfo> getSearchProviders() {
|
||||
public static synchronized List<SearcherInfo> getSearchProviders() {
|
||||
if (searchProviders == null) {
|
||||
searchProviders = new ArrayList<>();
|
||||
searchProviders.add(new SearcherInfo(new CombinedSearcher(), 1.0f));
|
||||
|
|
|
@ -7,7 +7,6 @@ import de.danoeh.antennapod.BuildConfig;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
|
@ -40,7 +39,7 @@ public class CrashReportWriter implements Thread.UncaughtExceptionHandler {
|
|||
File path = getFile();
|
||||
PrintWriter out = null;
|
||||
try {
|
||||
out = new PrintWriter(new FileWriter(path));
|
||||
out = new PrintWriter(path, "UTF-8");
|
||||
out.println("## Crash info");
|
||||
out.println("Time: " + new SimpleDateFormat("dd-MM-yyyy HH:mm:ss", Locale.getDefault()).format(new Date()));
|
||||
out.println("AntennaPod version: " + BuildConfig.VERSION_NAME);
|
||||
|
|
|
@ -27,7 +27,7 @@ public class AllEpisodesFragment extends EpisodesListFragment {
|
|||
private static final String PREF_NAME = "PrefAllEpisodesFragment";
|
||||
private static final String PREF_FILTER = "filter";
|
||||
|
||||
private static FeedItemFilter feedItemFilter = new FeedItemFilter("");
|
||||
private FeedItemFilter feedItemFilter = new FeedItemFilter("");
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package de.danoeh.antennapod.fragment.gpodnet;
|
||||
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import de.danoeh.antennapod.core.sync.gpoddernet.GpodnetService;
|
||||
import de.danoeh.antennapod.core.sync.gpoddernet.GpodnetServiceException;
|
||||
import de.danoeh.antennapod.core.sync.gpoddernet.model.GpodnetPodcast;
|
||||
import de.danoeh.antennapod.core.sync.gpoddernet.model.GpodnetTag;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import de.danoeh.antennapod.activity.MainActivity;
|
||||
|
||||
|
@ -24,8 +24,7 @@ public class TagFragment extends PodcastListFragment {
|
|||
|
||||
private GpodnetTag tag;
|
||||
|
||||
public static TagFragment newInstance(GpodnetTag tag) {
|
||||
Validate.notNull(tag);
|
||||
public static TagFragment newInstance(@NonNull GpodnetTag tag) {
|
||||
TagFragment fragment = new TagFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putParcelable("tag", tag);
|
||||
|
@ -38,7 +37,9 @@ public class TagFragment extends PodcastListFragment {
|
|||
super.onCreate(savedInstanceState);
|
||||
|
||||
Bundle args = getArguments();
|
||||
Validate.isTrue(args != null && args.getParcelable("tag") != null, "args invalid");
|
||||
if (args == null || args.getParcelable("tag") == null) {
|
||||
throw new IllegalArgumentException("Arguments not given");
|
||||
}
|
||||
tag = args.getParcelable("tag");
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public class DevelopersFragment extends ListFragment {
|
|||
developersLoader = Single.create((SingleOnSubscribe<ArrayList<SimpleIconListAdapter.ListItem>>) emitter -> {
|
||||
ArrayList<SimpleIconListAdapter.ListItem> developers = new ArrayList<>();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
getContext().getAssets().open("developers.csv")));
|
||||
getContext().getAssets().open("developers.csv"), "UTF-8"));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String[] info = line.split(";");
|
||||
|
|
|
@ -95,7 +95,7 @@ public class LicensesFragment extends ListFragment {
|
|||
private void showLicenseText(String licenseTextFile) {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
getContext().getAssets().open(licenseTextFile)));
|
||||
getContext().getAssets().open(licenseTextFile), "UTF-8"));
|
||||
StringBuilder licenseText = new StringBuilder();
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
|
|
|
@ -29,7 +29,7 @@ public class SpecialThanksFragment extends ListFragment {
|
|||
translatorsLoader = Single.create((SingleOnSubscribe<ArrayList<SimpleIconListAdapter.ListItem>>) emitter -> {
|
||||
ArrayList<SimpleIconListAdapter.ListItem> translators = new ArrayList<>();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
getContext().getAssets().open("special_thanks.csv")));
|
||||
getContext().getAssets().open("special_thanks.csv"), "UTF-8"));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String[] info = line.split(";");
|
||||
|
|
|
@ -29,7 +29,7 @@ public class TranslatorsFragment extends ListFragment {
|
|||
translatorsLoader = Single.create((SingleOnSubscribe<ArrayList<SimpleIconListAdapter.ListItem>>) emitter -> {
|
||||
ArrayList<SimpleIconListAdapter.ListItem> translators = new ArrayList<>();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(
|
||||
getContext().getAssets().open("translators.csv")));
|
||||
getContext().getAssets().open("translators.csv"), "UTF-8"));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
String[] info = line.split(";");
|
||||
|
|
|
@ -1,13 +1,39 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<FindBugsFilter>
|
||||
<Match>
|
||||
<Bug pattern="v WEAK_MESSAGE_DIGEST_MD5"/>
|
||||
<Bug pattern="DM_DEFAULT_ENCODING"/>
|
||||
<Class name="de.danoeh.antennapod.core.util.vorbiscommentreader.VorbisCommentReader"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="v LI_LAZY_INIT_UPDATE_STATIC"/>
|
||||
<Bug pattern="MS_MUTABLE_ARRAY"/>
|
||||
<Class name="de.danoeh.antennapod.fragment.NavDrawerFragment"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="MS_SHOULD_BE_FINAL"/>
|
||||
<Class name="de.danoeh.antennapod.core.ClientConfig"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NM_SAME_SIMPLE_NAME_AS_SUPERCLASS"/>
|
||||
<Class name="de.danoeh.antennapod.menuhandler.MenuItemUtils"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NP_NONNULL_PARAM_VIOLATION"/>
|
||||
<Class name="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
|
||||
<Class name="de.danoeh.antennapod.activity.MainActivity"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NP_NULL_ON_SOME_PATH"/>
|
||||
<Class name="de.danoeh.antennapod.core.feed.FeedMedia"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE"/>
|
||||
<Class name="de.danoeh.antennapod.dialog.PlaybackControlsDialog"/>
|
||||
</Match>
|
||||
<Match>
|
||||
<Bug pattern="NP_NULL_PARAM_DEREF"/>
|
||||
<Class name="de.danoeh.antennapod.core.feed.FeedMedia"/>
|
||||
</Match>
|
||||
</FindBugsFilter>
|
||||
|
|
|
@ -43,7 +43,7 @@ public class FeedItem extends FeedComponent implements Serializable {
|
|||
private Date pubDate;
|
||||
private FeedMedia media;
|
||||
|
||||
private Feed feed;
|
||||
private transient Feed feed;
|
||||
private long feedId;
|
||||
|
||||
private int state;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package de.danoeh.antennapod.core.glide;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.bumptech.glide.Priority;
|
||||
import com.bumptech.glide.load.DataSource;
|
||||
import com.bumptech.glide.load.Options;
|
||||
|
@ -36,7 +35,6 @@ public final class ChapterImageModelLoader implements ModelLoader<EmbeddedChapte
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public LoadData<ByteBuffer> buildLoadData(@NonNull EmbeddedChapterImage model,
|
||||
int width,
|
||||
|
@ -65,9 +63,9 @@ public final class ChapterImageModelLoader implements ModelLoader<EmbeddedChapte
|
|||
if (image.getMedia().localFileAvailable()) {
|
||||
File localFile = new File(image.getMedia().getLocalMediaUrl());
|
||||
stream = new BufferedInputStream(new FileInputStream(localFile));
|
||||
stream.skip(image.getPosition());
|
||||
IOUtils.skip(stream, image.getPosition());
|
||||
byte[] imageContent = new byte[image.getLength()];
|
||||
stream.read(imageContent, 0, image.getLength());
|
||||
IOUtils.read(stream, imageContent, 0, image.getLength());
|
||||
callback.onDataReady(ByteBuffer.wrap(imageContent));
|
||||
} else {
|
||||
Request.Builder httpReq = new Request.Builder();
|
||||
|
@ -88,10 +86,13 @@ public final class ChapterImageModelLoader implements ModelLoader<EmbeddedChapte
|
|||
}
|
||||
}
|
||||
|
||||
@Override public void cleanup() {
|
||||
@Override
|
||||
public void cleanup() {
|
||||
// nothing to clean up
|
||||
}
|
||||
@Override public void cancel() {
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
// cannot cancel
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.util.Log;
|
|||
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool;
|
||||
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class FastBlurTransformation extends BitmapTransformation {
|
||||
|
@ -43,7 +44,7 @@ public class FastBlurTransformation extends BitmapTransformation {
|
|||
|
||||
@Override
|
||||
public void updateDiskCacheKey(@NonNull MessageDigest messageDigest) {
|
||||
messageDigest.update(TAG.getBytes());
|
||||
messageDigest.update(TAG.getBytes(Charset.defaultCharset()));
|
||||
}
|
||||
|
||||
private static Bitmap fastBlur(Bitmap bitmap, int radius) {
|
||||
|
|
|
@ -120,7 +120,7 @@ public class AntennapodHttpClient {
|
|||
SocketAddress address = InetSocketAddress.createUnresolved(config.host, port);
|
||||
Proxy proxy = new Proxy(config.type, address);
|
||||
builder.proxy(proxy);
|
||||
if (!TextUtils.isEmpty(config.username)) {
|
||||
if (!TextUtils.isEmpty(config.username) && config.password != null) {
|
||||
String credentials = Credentials.basic(config.username, config.password);
|
||||
builder.interceptors().add(chain -> {
|
||||
Request request = chain.request().newBuilder()
|
||||
|
|
|
@ -667,11 +667,11 @@ public class GpodnetService implements ISyncService {
|
|||
while ((count = in.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, count);
|
||||
}
|
||||
return outputStream.toString("UTF-8");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
throw new GpodnetServiceException(e);
|
||||
}
|
||||
return outputStream.toString();
|
||||
}
|
||||
|
||||
private void checkStatusCode(@NonNull Response response) throws GpodnetServiceException {
|
||||
|
|
|
@ -34,8 +34,7 @@ import java.util.regex.Pattern;
|
|||
public class HtmlToPlainText {
|
||||
|
||||
/**
|
||||
* Use this method to strip off HTML encoding from given text
|
||||
* <p>
|
||||
* Use this method to strip off HTML encoding from given text.
|
||||
* Replaces bullet points with *, ignores colors/bold/...
|
||||
*
|
||||
* @param str String with any encoding
|
||||
|
@ -60,10 +59,8 @@ public class HtmlToPlainText {
|
|||
* @return <b>True</b> if text contains any HTML tags<br /><b>False</b> is no HTML tag is found
|
||||
*/
|
||||
private static boolean isHtml(String str) {
|
||||
final String HTML_TAG_PATTERN = "<(\"[^\"]*\"|'[^']*'|[^'\">])*>";
|
||||
Pattern htmlValidator = TextUtils.isEmpty(HTML_TAG_PATTERN) ? null : Pattern.compile(HTML_TAG_PATTERN);
|
||||
|
||||
return htmlValidator.matcher(str).find();
|
||||
final String htmlTagPattern = "<(\"[^\"]*\"|'[^']*'|[^'\">])*>";
|
||||
return Pattern.compile(htmlTagPattern).matcher(str).find();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue