Skip to content

Commit

Permalink
Merge pull request JakeWharton#294 from JakeWharton/jw/2017-07-19/err…
Browse files Browse the repository at this point in the history
…or-prone

Add error-prone to CI builds.
  • Loading branch information
JakeWharton authored Jul 20, 2017
2 parents 990ea00 + 65dd5c7 commit 038d789
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ final class SharedPreferencesMockResponseSupplier implements MockResponseSupplie

@SuppressLint("ApplySharedPref") // Persist to disk because we might kill the process next.
@Override public void set(Enum<?> value) {
preferences.edit().putString(value.getClass().getCanonicalName(), value.name()).commit();
preferences.edit()
.putString(value.getDeclaringClass().getCanonicalName(), value.name())
.commit();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

/** This is a fork of DrawerLayout which propagates insets without applying them. */
@SuppressLint("all")
@SuppressWarnings({"ClassCanBeStatic", "OperatorPrecedence", "ShortCircuitBoolean", "MissingOverride"})
public class DebugDrawerLayout extends ViewGroup implements DrawerLayoutImpl {
private static final String TAG = "DrawerLayout";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ private void setupUserInterfaceSection() {

RxAdapterView.itemSelections(uiAnimationSpeedView)
.map(speedAdapter::getItem)
.filter(item -> item != animationSpeed.get())
.filter(item -> !item.equals(animationSpeed.get()))
.subscribe(selected -> {
Timber.d("Setting animation speed to %sx", selected);
animationSpeed.set(selected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
* <p>To use this view server, your application must require the INTERNET
* permission.</p>
*/
@SuppressWarnings({"MissingOverride", "FutureReturnValueIgnored"})
public class SocketActivityHierarchyServer implements Runnable, ActivityHierarchyServer {
/**
* The default port used to start view servers.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,19 @@ public TrendingAdapter(Picasso picasso, RepositoryClickListener repositoryClickL
}

public final class ViewHolder extends RecyclerView.ViewHolder {
public final TrendingItemView itemView;
public final TrendingItemView view;

public ViewHolder(TrendingItemView itemView) {
super(itemView);
this.itemView = itemView;
this.itemView.setOnClickListener(v -> {
public ViewHolder(TrendingItemView view) {
super(view);
this.view = view;
this.view.setOnClickListener(v -> {
Repository repository = repositories.get(getAdapterPosition());
repositoryClickListener.onRepositoryClick(repository);
});
}

public void bindTo(Repository repository) {
itemView.bindTo(repository, picasso);
view.bindTo(repository, picasso);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ enum TrendingTimespan {

private final String name;
private final long duration;
@SuppressWarnings("ImmutableEnumChecker") // TODO https://github.com/google/error-prone/pull/686
private final TemporalUnit durationUnit;

TrendingTimespan(String name, int duration, TemporalUnit durationUnit) {
Expand Down
25 changes: 0 additions & 25 deletions app/src/main/java/com/jakewharton/u2020/util/EnumPreferences.java

This file was deleted.

30 changes: 30 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
buildscript {
ext.isCi = Boolean.parseBoolean(System.getProperty('CI', 'false'))

ext.versions = [
'compileSdk': 26,
'buildTools': '26.0.0',
Expand All @@ -13,6 +15,7 @@ buildscript {
'leakCanary': '1.5.1',
'espresso': '2.2.2',
'astl': '0.5',
'errorProne': '2.0.21',
]

ext.deps = [
Expand Down Expand Up @@ -73,17 +76,22 @@ buildscript {
],
'spoon': 'com.squareup.spoon:spoon-client:1.7.1',
'truth': 'com.google.truth:truth:0.34',
'errorProneAnnotations': "com.google.errorprone:error_prone_annotations:${versions.errorProne}",
]

repositories {
google()
mavenCentral()
jcenter()
maven {
url 'https://plugins.gradle.org/m2'
}
}

dependencies {
classpath 'com.android.tools.build:gradle:3.0.0-alpha7'
classpath 'com.stanfy.spoon:spoon-gradle-plugin:1.2.2'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.10'
}
}

Expand All @@ -101,7 +109,29 @@ subprojects {
if (details.requested.group == 'com.android.support') {
details.useVersion versions.supportLibrary
}
// Force all the error-prone dependencies to use the same version.
if (details.requested.group == 'com.google.errorprone'
&& details.requested.name.startsWith('error_prone_')) {
details.useVersion versions.errorProne
}
}
}
}

if (isCi) {
project.apply(plugin: 'net.ltgt.errorprone')

project.tasks.withType(JavaCompile) {
options.compilerArgs += [
'-Xep:UnnecessaryDefaultInEnumSwitch:ERROR',
'-Xep:TypeParameterUnusedInFormals:ERROR',
'-Xep:MissingOverride:ERROR',
'-Xep:ClassCanBeStatic:ERROR',
'-Xep:OperatorPrecedence:ERROR',
'-Xep:ReferenceEquality:ERROR',
'-Xep:FloatingPointLiteralPrecision:ERROR',
'-Xep:SimpleDateFormatConstant:ERROR',
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public enum MockRepositoriesResponse {
EMPTY("Empty", new RepositoriesResponse(null));

public final String name;
@SuppressWarnings("ImmutableEnumChecker") // TODO make this @Immutable.
public final RepositoriesResponse response;

MockRepositoriesResponse(String name, RepositoriesResponse response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ static void sort(List<Repository> repositories, Sort sort, Order order) {
case UPDATED:
Collections.sort(repositories, order == ASC ? UPDATED_ASC : UPDATED_DESC);
break;
default:
throw new IllegalArgumentException("Unknown sort: " + sort);
}
}

Expand Down

0 comments on commit 038d789

Please sign in to comment.