From 9f546d13c23228dbac8e4e3db6ec68e808d198a7 Mon Sep 17 00:00:00 2001 From: Mohamed Ezzat Date: Thu, 28 Apr 2016 18:45:39 +0200 Subject: [PATCH] squid:S1118 - Utility classes should not have public constructors (#281) --- .../kanade/tachiyomi/data/database/tables/ChapterTable.java | 6 +++++- .../tachiyomi/data/database/tables/MangaSyncTable.java | 6 +++++- .../java/eu/kanade/tachiyomi/util/AndroidComponentUtil.java | 6 +++++- .../java/eu/kanade/tachiyomi/util/ChapterRecognition.java | 6 +++++- app/src/main/java/eu/kanade/tachiyomi/util/GLUtil.java | 6 +++++- app/src/main/java/eu/kanade/tachiyomi/util/Parser.java | 6 +++++- app/src/main/java/eu/kanade/tachiyomi/util/UrlUtil.java | 6 +++++- 7 files changed, 35 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/ChapterTable.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/ChapterTable.java index 1aea2574d..f325bd6de 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/ChapterTable.java +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/ChapterTable.java @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.data.database.tables; import android.support.annotation.NonNull; -public class ChapterTable { +public final class ChapterTable { @NonNull public static final String TABLE = "chapters"; @@ -34,6 +34,10 @@ public class ChapterTable { @NonNull public static final String COLUMN_CHAPTER_NUMBER = "chapter_number"; + private ChapterTable() throws InstantiationException { + throw new InstantiationException("This class is not for instantiation"); + } + @NonNull public static String getCreateTableQuery() { return "CREATE TABLE " + TABLE + "(" diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/MangaSyncTable.java b/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/MangaSyncTable.java index c8dadeb60..0c4861fef 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/MangaSyncTable.java +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/tables/MangaSyncTable.java @@ -2,7 +2,7 @@ package eu.kanade.tachiyomi.data.database.tables; import android.support.annotation.NonNull; -public class MangaSyncTable { +public final class MangaSyncTable { public static final String TABLE = "manga_sync"; @@ -24,6 +24,10 @@ public class MangaSyncTable { public static final String COLUMN_TOTAL_CHAPTERS = "total_chapters"; + private MangaSyncTable() throws InstantiationException { + throw new InstantiationException("This class is not for instantiation"); + } + @NonNull public static String getCreateTableQuery() { return "CREATE TABLE " + TABLE + "(" diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/AndroidComponentUtil.java b/app/src/main/java/eu/kanade/tachiyomi/util/AndroidComponentUtil.java index cc261b93a..9b9402519 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/AndroidComponentUtil.java +++ b/app/src/main/java/eu/kanade/tachiyomi/util/AndroidComponentUtil.java @@ -8,7 +8,11 @@ import android.content.pm.PackageManager; import timber.log.Timber; -public class AndroidComponentUtil { +public final class AndroidComponentUtil { + + private AndroidComponentUtil() throws InstantiationException { + throw new InstantiationException("This class is not for instantiation"); + } public static void toggleComponent(Context context, Class componentClass, boolean enable) { Timber.i((enable ? "Enabling " : "Disabling ") + componentClass.getSimpleName()); diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.java b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.java index 08fa0f4b7..bd4f40802 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.java +++ b/app/src/main/java/eu/kanade/tachiyomi/util/ChapterRecognition.java @@ -8,7 +8,7 @@ import java.util.regex.Pattern; import eu.kanade.tachiyomi.data.database.models.Chapter; import eu.kanade.tachiyomi.data.database.models.Manga; -public class ChapterRecognition { +public final class ChapterRecognition { private static final Pattern cleanWithToken = Pattern.compile("ch[^0-9]?\\s*(\\d+[\\.,]?\\d+)($|\\b)"); private static final Pattern uncleanWithToken = Pattern.compile("ch[^0-9]?\\s*(\\d+[\\.,]?\\d*)"); @@ -23,6 +23,10 @@ public class ChapterRecognition { private static final Pattern pPart = Pattern.compile("(\\b|\\d)part\\s*\\d+.+"); + private ChapterRecognition() throws InstantiationException { + throw new InstantiationException("This class is not for instantiation"); + } + public static void parseChapterNumber(Chapter chapter, Manga manga) { if (chapter.chapter_number != -1) return; diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/GLUtil.java b/app/src/main/java/eu/kanade/tachiyomi/util/GLUtil.java index 53f69b847..f60376524 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/GLUtil.java +++ b/app/src/main/java/eu/kanade/tachiyomi/util/GLUtil.java @@ -5,7 +5,11 @@ import javax.microedition.khronos.egl.EGLConfig; import javax.microedition.khronos.egl.EGLContext; import javax.microedition.khronos.egl.EGLDisplay; -public class GLUtil { +public final class GLUtil { + + private GLUtil() throws InstantiationException { + throw new InstantiationException("This class is not for instantiation"); + } public static int getMaxTextureSize() { // Safe minimum default size diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/Parser.java b/app/src/main/java/eu/kanade/tachiyomi/util/Parser.java index bad9854a2..282663c57 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/Parser.java +++ b/app/src/main/java/eu/kanade/tachiyomi/util/Parser.java @@ -5,7 +5,11 @@ import android.support.annotation.Nullable; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; -public class Parser { +public final class Parser { + + private Parser() throws InstantiationException { + throw new InstantiationException("This class is not for instantiation"); + } @Nullable public static Element element(Element container, String pattern) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/UrlUtil.java b/app/src/main/java/eu/kanade/tachiyomi/util/UrlUtil.java index baf7ce9dc..b877867bd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/UrlUtil.java +++ b/app/src/main/java/eu/kanade/tachiyomi/util/UrlUtil.java @@ -3,12 +3,16 @@ package eu.kanade.tachiyomi.util; import java.net.URI; import java.net.URISyntaxException; -public class UrlUtil { +public final class UrlUtil { private static final String JPG = ".jpg"; private static final String PNG = ".png"; private static final String GIF = ".gif"; + private UrlUtil() throws InstantiationException { + throw new InstantiationException("This class is not for instantiation"); + } + public static String getPath(String s) { try { URI uri = new URI(s);