From 710964b47df92cbdb1ab41b562c80dd9d7c28ce8 Mon Sep 17 00:00:00 2001 From: Stypox Date: Fri, 18 Mar 2022 19:58:59 +0100 Subject: [PATCH 1/2] Update checkstyle to 10.0 and fix various related issues - Put checkstyle files into checkstyle/ subfolder so that the gradle task does not implicitly depend on the whole project, fixing many warnings during build and possibly increasing build performance. - Remove unused SuppressionXpathFilter from config file. - Remove outdated suppressions from suppressions file. --- app/build.gradle | 4 ++-- checkstyle.xml => checkstyle/checkstyle.xml | 9 +-------- .../suppressions.xml | 8 -------- 3 files changed, 3 insertions(+), 18 deletions(-) rename checkstyle.xml => checkstyle/checkstyle.xml (94%) rename checkstyle-suppressions.xml => checkstyle/suppressions.xml (74%) diff --git a/app/build.gradle b/app/build.gradle index 51762db7518..0299c0fd598 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -98,7 +98,7 @@ android { } ext { - checkstyleVersion = '9.3' + checkstyleVersion = '10.0' androidxLifecycleVersion = '2.3.1' androidxRoomVersion = '2.4.2' @@ -121,7 +121,7 @@ configurations { } checkstyle { - getConfigDirectory().set(rootProject.file(".")) + getConfigDirectory().set(rootProject.file("checkstyle")) ignoreFailures false showViolations true toolVersion = checkstyleVersion diff --git a/checkstyle.xml b/checkstyle/checkstyle.xml similarity index 94% rename from checkstyle.xml rename to checkstyle/checkstyle.xml index 61145d61f6d..282358f6a6d 100644 --- a/checkstyle.xml +++ b/checkstyle/checkstyle.xml @@ -22,7 +22,7 @@ - + @@ -180,12 +180,5 @@ - - - - - - diff --git a/checkstyle-suppressions.xml b/checkstyle/suppressions.xml similarity index 74% rename from checkstyle-suppressions.xml rename to checkstyle/suppressions.xml index 3c5e4891a0b..8b9e50afacc 100644 --- a/checkstyle-suppressions.xml +++ b/checkstyle/suppressions.xml @@ -7,18 +7,10 @@ files="LocalItemListAdapter.java" lines="232,304"/> - - - - From 53f8415e9b898942b3995532d66f0ccb844f7f24 Mon Sep 17 00:00:00 2001 From: Stypox Date: Fri, 18 Mar 2022 23:57:11 +0100 Subject: [PATCH 2/2] Use @SuppressWarnings for checkstyle suppressions & warnings It's better to use @SuppressWarnings instead of the suppressions file, so that the warning suppression is at the place where it acts. --- .../org/schabi/newpipe/local/LocalItemListAdapter.java | 2 ++ app/src/main/java/org/schabi/newpipe/player/Player.java | 1 + .../schabi/newpipe/player/playqueue/PlayQueueItem.java | 1 + .../org/schabi/newpipe/streams/Mp4FromDashWriter.java | 1 + .../main/java/org/schabi/newpipe/streams/WebMWriter.java | 1 + checkstyle/suppressions.xml | 8 +------- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java b/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java index 5d81c0069c0..05e2fdac083 100644 --- a/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/local/LocalItemListAdapter.java @@ -228,6 +228,7 @@ public int getItemCount() { return count; } + @SuppressWarnings("FinalParameters") @Override public int getItemViewType(int position) { if (DEBUG) { @@ -300,6 +301,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull final ViewGroup paren } } + @SuppressWarnings("FinalParameters") @Override public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int position) { if (DEBUG) { diff --git a/app/src/main/java/org/schabi/newpipe/player/Player.java b/app/src/main/java/org/schabi/newpipe/player/Player.java index 76f7a81019f..1051f678f3f 100644 --- a/app/src/main/java/org/schabi/newpipe/player/Player.java +++ b/app/src/main/java/org/schabi/newpipe/player/Player.java @@ -682,6 +682,7 @@ public void seek(final boolean forward) { //////////////////////////////////////////////////////////////////////////*/ //region Playback initialization via intent + @SuppressWarnings("MethodLength") public void handleIntent(@NonNull final Intent intent) { // fail fast if no play queue was provided final String queueCache = intent.getStringExtra(PLAY_QUEUE_KEY); diff --git a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItem.java b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItem.java index f7dfc562e48..bf31ea9b10d 100644 --- a/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItem.java +++ b/app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueueItem.java @@ -52,6 +52,7 @@ public class PlayQueueItem implements Serializable { item.getUploaderUrl(), item.getStreamType()); } + @SuppressWarnings("ParameterNumber") private PlayQueueItem(@Nullable final String name, @Nullable final String url, final int serviceId, final long duration, @Nullable final String thumbnailUrl, @Nullable final String uploader, diff --git a/app/src/main/java/org/schabi/newpipe/streams/Mp4FromDashWriter.java b/app/src/main/java/org/schabi/newpipe/streams/Mp4FromDashWriter.java index ca3da9d2449..889cc85e629 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/Mp4FromDashWriter.java +++ b/app/src/main/java/org/schabi/newpipe/streams/Mp4FromDashWriter.java @@ -142,6 +142,7 @@ public void close() throws IOException { outStream = null; } + @SuppressWarnings("MethodLength") public void build(final SharpStream output) throws IOException { if (done) { throw new RuntimeException("already done"); diff --git a/app/src/main/java/org/schabi/newpipe/streams/WebMWriter.java b/app/src/main/java/org/schabi/newpipe/streams/WebMWriter.java index ebae3812ca0..2b69f23ac07 100644 --- a/app/src/main/java/org/schabi/newpipe/streams/WebMWriter.java +++ b/app/src/main/java/org/schabi/newpipe/streams/WebMWriter.java @@ -121,6 +121,7 @@ public void close() { clustersOffsetsSizes = null; } + @SuppressWarnings("MethodLength") public void build(final SharpStream out) throws IOException, RuntimeException { if (!out.canRewind()) { throw new IOException("The output stream must be allow seek"); diff --git a/checkstyle/suppressions.xml b/checkstyle/suppressions.xml index 8b9e50afacc..3f31de48a86 100644 --- a/checkstyle/suppressions.xml +++ b/checkstyle/suppressions.xml @@ -3,13 +3,7 @@ "-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN" "https://checkstyle.org/dtds/suppressions_1_2.dtd"> - - - +