add checkstyle, add to travis.

fixup any issues found with checkstyle.
feature/updater-pie
Floens 6 years ago
parent 2d462a5c31
commit 5795417ef6
  1. 2
      .travis.yml
  2. 16
      Clover/app/build.gradle
  3. 3
      Clover/app/src/main/java/org/floens/chan/core/database/DatabaseHelper.java
  4. 7
      Clover/app/src/main/java/org/floens/chan/core/presenter/ThreadPresenter.java
  5. 4
      Clover/app/src/main/java/org/floens/chan/core/site/ImageSearch.java
  6. 8
      Clover/app/src/main/java/org/floens/chan/core/site/common/CommonSite.java
  7. 3
      Clover/app/src/main/java/org/floens/chan/ui/controller/ImageViewerNavigationController.java
  8. 1
      Clover/app/src/main/java/org/floens/chan/ui/controller/StyledToolbarNavigationController.java
  9. 12
      Clover/app/src/main/java/org/floens/chan/ui/layout/ReplyLayout.java
  10. 6
      Clover/app/src/main/java/org/floens/chan/ui/layout/ThreadListLayout.java
  11. 1
      Clover/app/src/main/java/org/floens/chan/ui/notification/ThreadWatchNotifications.java
  12. 3
      Clover/app/src/main/java/org/floens/chan/ui/text/FastTextView.java
  13. 141
      Clover/checkstyle.xml

@ -10,7 +10,7 @@ android:
- build-tools-28.0.3 - build-tools-28.0.3
- android-28 - android-28
script: cd Clover && ./gradlew build --console plain -x lint script: cd Clover && ./gradlew clean check --console plain
notifications: notifications:
email: false email: false

@ -10,6 +10,22 @@ if (project.sentryMappingUploadingEnabled) {
} }
} }
// Code style
apply plugin: 'checkstyle'
task('checkstyle', type: Checkstyle) {
configFile rootProject.file('checkstyle.xml')
source 'src/main/java'
ignoreFailures false
showViolations true
include '**/*.java'
classpath = files()
}
afterEvaluate {
tasks.findByName('check').dependsOn('checkstyle')
}
/** /**
* Gets the version name from the latest Git tag * Gets the version name from the latest Git tag
*/ */

@ -188,7 +188,8 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
if (oldVersion < 19) { if (oldVersion < 19) {
try { try {
filterDao.executeRawNoArgs("CREATE TABLE `filter` (`action` INTEGER NOT NULL , `allBoards` SMALLINT NOT NULL , `boards` VARCHAR NOT NULL , `color` INTEGER NOT NULL , `enabled` SMALLINT NOT NULL , `id` INTEGER PRIMARY KEY AUTOINCREMENT , `pattern` VARCHAR NOT NULL , `type` INTEGER NOT NULL );"); filterDao.executeRawNoArgs("CREATE TABLE `filter` (`action` INTEGER NOT NULL , `allBoards` SMALLINT NOT NULL , `boards` VARCHAR NOT NULL , `color` INTEGER NOT NULL , " +
"`enabled` SMALLINT NOT NULL , `id` INTEGER PRIMARY KEY AUTOINCREMENT , `pattern` VARCHAR NOT NULL , `type` INTEGER NOT NULL );");
} catch (SQLException e) { } catch (SQLException e) {
Logger.e(TAG, "Error upgrading to version 19", e); Logger.e(TAG, "Error upgrading to version 19", e);
} }

@ -59,7 +59,12 @@ import javax.inject.Inject;
import static org.floens.chan.utils.AndroidUtils.getString; import static org.floens.chan.utils.AndroidUtils.getString;
public class ThreadPresenter implements ChanThreadLoader.ChanLoaderCallback, PostAdapter.PostAdapterCallback, PostCellInterface.PostCellCallback, ThreadStatusCell.Callback, ThreadListLayout.ThreadListLayoutPresenterCallback { public class ThreadPresenter implements
ChanThreadLoader.ChanLoaderCallback,
PostAdapter.PostAdapterCallback,
PostCellInterface.PostCellCallback,
ThreadStatusCell.Callback,
ThreadListLayout.ThreadListLayoutPresenterCallback {
private static final int POST_OPTION_QUOTE = 0; private static final int POST_OPTION_QUOTE = 0;
private static final int POST_OPTION_QUOTE_TEXT = 1; private static final int POST_OPTION_QUOTE_TEXT = 1;
private static final int POST_OPTION_INFO = 2; private static final int POST_OPTION_INFO = 2;

@ -85,7 +85,7 @@ public abstract class ImageSearch {
return "http://tineye.com/search/?url=" + imageUrl; return "http://tineye.com/search/?url=" + imageUrl;
} }
}); });
engines.add(new ImageSearch() { engines.add(new ImageSearch() {
public int getId() { public int getId() {
return 4; return 4;
@ -99,7 +99,7 @@ public abstract class ImageSearch {
return "https://trace.moe/?url=" + imageUrl; return "https://trace.moe/?url=" + imageUrl;
} }
}); });
engines.add(new ImageSearch() { engines.add(new ImageSearch() {
public int getId() { public int getId() {
return 5; return 5;

@ -239,7 +239,7 @@ public abstract class CommonSite extends SiteBase {
} }
} }
public static abstract class CommonSiteUrlHandler implements SiteUrlHandler { public abstract static class CommonSiteUrlHandler implements SiteUrlHandler {
public abstract HttpUrl getUrl(); public abstract HttpUrl getUrl();
public abstract String[] getNames(); public abstract String[] getNames();
@ -315,7 +315,7 @@ public abstract class CommonSite extends SiteBase {
} }
} }
public static abstract class CommonEndpoints implements SiteEndpoints { public abstract static class CommonEndpoints implements SiteEndpoints {
protected CommonSite site; protected CommonSite site;
public CommonEndpoints(CommonSite site) { public CommonEndpoints(CommonSite site) {
@ -413,7 +413,7 @@ public abstract class CommonSite extends SiteBase {
} }
} }
public static abstract class CommonActions implements SiteActions { public abstract static class CommonActions implements SiteActions {
protected CommonSite site; protected CommonSite site;
public CommonActions(CommonSite site) { public CommonActions(CommonSite site) {
@ -550,7 +550,7 @@ public abstract class CommonSite extends SiteBase {
} }
} }
public static abstract class CommonApi implements ChanReader { public abstract static class CommonApi implements ChanReader {
protected CommonSite site; protected CommonSite site;
public CommonApi(CommonSite site) { public CommonApi(CommonSite site) {

@ -21,9 +21,8 @@ import android.content.Context;
import org.floens.chan.R; import org.floens.chan.R;
import org.floens.chan.controller.ui.NavigationControllerContainerLayout; import org.floens.chan.controller.ui.NavigationControllerContainerLayout;
import org.floens.chan.core.model.orm.Loadable;
import org.floens.chan.core.model.PostImage; import org.floens.chan.core.model.PostImage;
import org.floens.chan.ui.toolbar.Toolbar; import org.floens.chan.core.model.orm.Loadable;
import java.util.List; import java.util.List;

@ -25,7 +25,6 @@ import org.floens.chan.controller.ControllerTransition;
import org.floens.chan.controller.ui.NavigationControllerContainerLayout; import org.floens.chan.controller.ui.NavigationControllerContainerLayout;
import org.floens.chan.core.settings.ChanSettings; import org.floens.chan.core.settings.ChanSettings;
import org.floens.chan.ui.theme.ThemeHelper; import org.floens.chan.ui.theme.ThemeHelper;
import org.floens.chan.ui.toolbar.Toolbar;
public class StyledToolbarNavigationController extends ToolbarNavigationController { public class StyledToolbarNavigationController extends ToolbarNavigationController {
public StyledToolbarNavigationController(Context context) { public StyledToolbarNavigationController(Context context) {

@ -70,7 +70,12 @@ import static org.floens.chan.utils.AndroidUtils.getAttrColor;
import static org.floens.chan.utils.AndroidUtils.getString; import static org.floens.chan.utils.AndroidUtils.getString;
import static org.floens.chan.utils.AndroidUtils.setRoundItemBackground; import static org.floens.chan.utils.AndroidUtils.setRoundItemBackground;
public class ReplyLayout extends LoadView implements View.OnClickListener, ReplyPresenter.ReplyPresenterCallback, TextWatcher, ImageDecoder.ImageDecoderCallback, SelectionListeningEditText.SelectionChangedListener { public class ReplyLayout extends LoadView implements
View.OnClickListener,
ReplyPresenter.ReplyPresenterCallback,
TextWatcher,
ImageDecoder.ImageDecoderCallback,
SelectionListeningEditText.SelectionChangedListener {
@Inject @Inject
ReplyPresenter presenter; ReplyPresenter presenter;
@ -228,15 +233,14 @@ public class ReplyLayout extends LoadView implements View.OnClickListener, Reply
@Override @Override
public void onClick(View v) { public void onClick(View v) {
// TODO handle preview
if (v == more) { if (v == more) {
presenter.onMoreClicked(); presenter.onMoreClicked();
} else if (v == attach) { } else if (v == attach) {
presenter.onAttachClicked(); presenter.onAttachClicked();
} else if (v == submit) { } else if (v == submit) {
presenter.onSubmitClicked(); presenter.onSubmitClicked();
}/* else if (v == preview) { } else if (v == captchaHardReset) {
// TODO
}*/ else if (v == captchaHardReset) {
if (authenticationLayout != null) { if (authenticationLayout != null) {
authenticationLayout.hardReset(); authenticationLayout.hardReset();
} }

@ -678,7 +678,7 @@ public class ThreadListLayout extends FrameLayout implements ReplyLayout.ReplyLa
private Bitmap hat; private Bitmap hat;
private final RecyclerView.ItemDecoration PARTY = new RecyclerView.ItemDecoration() { private final RecyclerView.ItemDecoration party = new RecyclerView.ItemDecoration() {
@Override @Override
public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) { public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {
if (hat == null) { if (hat == null) {
@ -705,13 +705,13 @@ public class ThreadListLayout extends FrameLayout implements ReplyLayout.ReplyLa
if (showingThread.loadable.site instanceof Chan4) { if (showingThread.loadable.site instanceof Chan4) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
if (calendar.get(Calendar.MONTH) == Calendar.OCTOBER && calendar.get(Calendar.DAY_OF_MONTH) == 1) { if (calendar.get(Calendar.MONTH) == Calendar.OCTOBER && calendar.get(Calendar.DAY_OF_MONTH) == 1) {
recyclerView.addItemDecoration(PARTY); recyclerView.addItemDecoration(party);
} }
} }
} }
private void noParty() { private void noParty() {
recyclerView.removeItemDecoration(PARTY); recyclerView.removeItemDecoration(party);
} }
public interface ThreadListLayoutPresenterCallback { public interface ThreadListLayoutPresenterCallback {

@ -12,7 +12,6 @@ import android.support.v4.app.NotificationCompat;
import org.floens.chan.R; import org.floens.chan.R;
import org.floens.chan.core.manager.WatchManager; import org.floens.chan.core.manager.WatchManager;
import org.floens.chan.core.model.Post; import org.floens.chan.core.model.Post;
import org.floens.chan.core.model.orm.Pin;
import org.floens.chan.ui.activity.BoardActivity; import org.floens.chan.ui.activity.BoardActivity;
import java.util.List; import java.util.List;

@ -222,7 +222,8 @@ public class FastTextView extends View {
// Logger.test("staticlayout cache miss: text = %s", text); // Logger.test("staticlayout cache miss: text = %s", text);
cached = getStaticLayout(layoutWidth); cached = getStaticLayout(layoutWidth);
textCache.put(item, cached); textCache.put(item, cached);
}/* else { }
/* else {
Logger.test("staticlayout cache hit"); Logger.test("staticlayout cache hit");
}*/ }*/

@ -0,0 +1,141 @@
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
"http://checkstyle.sourceforge.net/dtds/configuration_1_3.dtd">
<module name="Checker">
<!--module name="NewlineAtEndOfFile"/-->
<module name="FileLength"/>
<module name="FileTabCharacter"/>
<!-- Trailing spaces -->
<module name="RegexpSingleline">
<property name="format" value="\s+$"/>
<property name="message" value="Line has trailing spaces."/>
</module>
<!-- Space after 'for' and 'if' -->
<module name="RegexpSingleline">
<property name="format" value="^\s*(for|if)[^ ]\("/>
<property name="message" value="Space needed before opening parenthesis."/>
</module>
<!-- For each spacing -->
<module name="RegexpSingleline">
<property name="format" value="^\s*for \(.*?([^ ]:|:[^ ])"/>
<property name="message" value="Space needed around ':' character."/>
</module>
<module name="TreeWalker">
<!--<property name="cacheFile" value="${checkstyle.cache.file}"/>-->
<!-- Checks for Javadoc comments. -->
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
<!--module name="JavadocMethod"/-->
<!--module name="JavadocType"/-->
<!--module name="JavadocVariable"/-->
<!--module name="JavadocStyle"/-->
<!-- Checks for Naming Conventions. -->
<!-- See http://checkstyle.sf.net/config_naming.html -->
<!--<module name="ConstantName"/>-->
<module name="LocalFinalVariableName"/>
<module name="LocalVariableName"/>
<module name="MemberName"/>
<module name="MethodName">
<property name="format" value="^[a-z][a-zA-Z0-9_]*$"/>
</module>
<module name="PackageName"/>
<module name="ParameterName"/>
<module name="StaticVariableName">
<property name="format" value="^[a-zA-Z0-9_]*$"/>
</module>
<module name="TypeName"/>
<!-- Checks for imports -->
<!-- See http://checkstyle.sf.net/config_import.html -->
<module name="AvoidStarImport"/>
<module name="IllegalImport"/>
<module name="RedundantImport"/>
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>
</module>
<!-- Checks for Size Violations. -->
<!-- See http://checkstyle.sf.net/config_sizes.html -->
<module name="LineLength">
<property name="max" value="200"/>
</module>
<module name="MethodLength">
<property name="max" value="250"/>
</module>
<!--module name="ParameterNumber"/-->
<!-- Checks for whitespace -->
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
<module name="GenericWhitespace"/>
<module name="EmptyForIteratorPad">
<property name="option" value="space"/>
</module>
<module name="MethodParamPad"/>
<!--<module name="NoWhitespaceAfter"/>-->
<module name="NoWhitespaceBefore"/>
<!-- <module name="OperatorWrap"/> -->
<module name="ParenPad"/>
<module name="TypecastParenPad"/>
<module name="WhitespaceAfter"/>
<module name="WhitespaceAround"/>
<!-- Modifier Checks -->
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
<module name="ModifierOrder"/>
<!-- <module name="RedundantModifier"/> -->
<!-- Checks for blocks. You know, those {}'s -->
<!-- See http://checkstyle.sf.net/config_blocks.html -->
<!--module name="AvoidNestedBlocks"/-->
<!--module name="EmptyBlock"/-->
<module name="LeftCurly"/>
<!--module name="NeedBraces"/-->
<module name="RightCurly"/>
<!-- Checks for common coding problems -->
<!-- See http://checkstyle.sf.net/config_coding.html -->
<!--module name="AvoidInlineConditionals"/-->
<module name="CovariantEquals"/>
<module name="EmptyStatement"/>
<!--<module name="EqualsAvoidNull"/>-->
<module name="EqualsHashCode"/>
<!--module name="HiddenField"/-->
<module name="IllegalInstantiation"/>
<!--<module name="InnerAssignment"/>-->
<!--module name="MagicNumber"/-->
<!-- <module name="MissingSwitchDefault"/> -->
<!--<module name="RedundantThrows"/>-->
<module name="SimplifyBooleanExpression"/>
<module name="SimplifyBooleanReturn"/>
<!-- Checks for class design -->
<!-- See http://checkstyle.sf.net/config_design.html -->
<!--module name="DesignForExtension"/-->
<!--module name="FinalClass"/-->
<!--module name="HideUtilityClassConstructor"/-->
<!--module name="InterfaceIsType"/-->
<!--module name="VisibilityModifier"/-->
<!-- Miscellaneous other checks. -->
<!-- See http://checkstyle.sf.net/config_misc.html -->
<!--module name="ArrayTypeStyle"/-->
<!--module name="FinalParameters"/-->
<!--module name="TodoComment"/-->
<module name="UpperEll"/>
</module>
</module>
Loading…
Cancel
Save