Skip to content

Error prone check added to check unbinded subscriptions#156

Merged
ZacSweers merged 26 commits intouber:masterfrom
bangarharshit:autodispose-error-prone-checker
Jan 21, 2018
Merged

Error prone check added to check unbinded subscriptions#156
ZacSweers merged 26 commits intouber:masterfrom
bangarharshit:autodispose-error-prone-checker

Conversation

@bangarharshit
Copy link
Contributor

This is a copy of the check from Uber/Ribs with 2 major differences:

  1. Support for 3rd party libraries like Ribs and Conductor via error-prone flag -XepOpt:AutoDisposeLeakCheck.
  2. Added support for the new as based API.

Things to do:

  1. It still doesn't include matcher for ParallelFlowable.
  2. Fix build.gradle for removing redundant dependencies and publishing artifact. Can look into this in the weekend.

Fixes - #152

@ZacSweers ZacSweers self-requested a review January 4, 2018 00:34
@ZacSweers
Copy link
Collaborator

Will start review once the to-dos are finished, unless you wanted me to give early feedback now before. Let me know

@bangarharshit
Copy link
Contributor Author

Yeah. It will be great if you can give some early feedback. Most of the remaining changes will only be in build.gradle. The ParallelFlowableMatcher is not yet added because the PR is still open.

Copy link
Collaborator

@ZacSweers ZacSweers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msridhar could I get your review on this as well?

]

def apt = [
autoService : "com.google.auto.service:auto-service:1.0-rc3",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: make this match the rest of this file's style

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also rc4 is out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


checkerFramework: 'org.checkerframework:dataflow:2.3.0',
errorProneCheckApi: "com.google.errorprone:error_prone_check_api:${versions.errorProne}",
errorProne: "com.google.errorprone:error_prone_core:${versions.errorProne}",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this goes above errorProneCheckApi alphabetically

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


// we use this config to get the path of the JDK 9 javac jar, to
// stick it in the bootclasspath when running tests
configurations.maybeCreate("epJavac")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kageiit can you confirm this is correct?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually if you wouldn't mind taking a general review of this config, I'd appreciate the extra set of eyes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,70 @@
plugins {
id "net.ltgt.errorprone" version "0.0.13"
id "com.github.johnrengelman.shadow" version "2.0.1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain the shadow bits here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to create a fat jar here and the steps are taken from - NullAway's build.gradle - dependency part.

It is not working in any case as I am not able to use it in the sample project. Will be fixing it over the weekend. I am not sure what is the best way to publish an error-prone check.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. Maybe @msridhar or @kageiit have advice here

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not need to create a fat jar. the jar with just the classes from this module can be consumed by anyone that uses error prone

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah all the shadow stuff isn't needed here. NullAway needs it due to a forked dependence

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

test {
maxHeapSize = "1024m"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
@AutoService(BugChecker.class)
@BugPattern(
name = "RxJavaMissingAutoDisposeErrorChecker",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant RxJava

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend renaming this to

MissingAutoDisposeErrorChecker

Adding Rxjava at the start seems redundant. Similar to @hzsweers comment earlier about removing rx from the artifact identifier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private static final ImmutableList<MethodMatchers.MethodNameMatcher> TO_CALL_MATCHERS;
private static final ImmutableList<MethodMatchers.MethodNameMatcher> SUBSCRIBE_MATCHERS;
private static final String SUBSCRIBE = "subscribe";
private static final String TO = "to";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to support the to implementation since it's going away

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ImmutableList.Builder<String> builder = new ImmutableList.Builder<>();
classesWithLifecycle = builder
.add("android.app.Activity")
.add("android.app.Fragment")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should support support fragments out of the box. I'm kind of thinking we shouldn't check any by default though, and leave it totally up to the user. Will think on it more

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is s already added.

}

static {
ImmutableList.Builder<MethodMatchers.MethodNameMatcher> builder = new ImmutableList.Builder<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all these

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


ImmutableList.Builder<MethodMatchers.MethodNameMatcher> builder2
= new ImmutableList.Builder<>();
builder2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not continue the fluent API after creating the builder?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
@AutoService(BugChecker.class)
@BugPattern(
name = "RxJavaMissingAutoDisposeErrorChecker",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend renaming this to

MissingAutoDisposeErrorChecker

Adding Rxjava at the start seems redundant. Similar to @hzsweers comment earlier about removing rx from the artifact identifier

@BugPattern(
name = "RxJavaMissingAutoDisposeErrorChecker",
summary = "Always apply an Autodispose scope before subscribing",
category = JDK,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend using the concurrency tag instead of the deprecated categories

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@Override
public String linkUrl() {
return "https://github.com/uber/RIBs"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be updated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to a shortcut - d4883cc @hzsweers can this point to a wiki in autodispose? The readme in ribs is not updated.


// we use this config to get the path of the JDK 9 javac jar, to
// stick it in the bootclasspath when running tests
configurations.maybeCreate("epJavac")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many config options in this file are not required. They are specific to nullaway and do not translate here.

Remove this line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This actually might be needed for unit tests, to get EP java in bootclasspath. Can try without first.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed for unit tests.


compileOnly deps.build.errorProneCheckApi

errorprone deps.build.errorProne
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,70 @@
plugins {
id "net.ltgt.errorprone" version "0.0.13"
id "com.github.johnrengelman.shadow" version "2.0.1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not need to create a fat jar. the jar with just the classes from this module can be consumed by anyone that uses error prone

@@ -0,0 +1,70 @@
plugins {
id "net.ltgt.errorprone" version "0.0.13"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,70 @@
plugins {
id "net.ltgt.errorprone" version "0.0.13"
id "com.github.johnrengelman.shadow" version "2.0.1"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
testCompile project(':autodispose')

epJavac deps.build.errorProneCheckApi
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

epJavac deps.build.errorProneCheckApi
}

shadowJar {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove everything from this line and below (Change the maven bits to just match what other projects do)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
if (matcher(classesWithLifecycle).matches(tree, state)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result of matcher(classesWithLifecycle) should be cached in an instance field

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type.ClassType enclosingClassType = ASTHelpers.getType(enclosingClass);

for (String s : classesWithLifecycle) {
Type lifecycleType = state.getTypeFromString(s);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small optimization: store classesWithLifecycle as a List<Type>. The call getTypeFromString() can be a bit costly (though for this checker it may not get called very often)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed it. Will fix in a separate commit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@msridhar quick question - do you mean to cache it when we will call it the first time? Can we get the type from a string without visitor state? I am not sure how to do it eagerly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah you're right, hard to do eagerly. We can skip this optimization for now I think; this code shouldn't run all that often.

}
return false;
} catch (ClassCastException e) {
return false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why catch a ClassCastException here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed - 96a8baf

SUBSCRIBE_MATCHERS = builder3.build();
}

private static final Matcher<ExpressionTree> METHOD_NAME_MATCHERS =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

javadoc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@bangarharshit bangarharshit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed comments except caching the types in a list. Will push a commit for that.

]

def apt = [
autoService : "com.google.auto.service:auto-service:1.0-rc3",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


checkerFramework: 'org.checkerframework:dataflow:2.3.0',
errorProneCheckApi: "com.google.errorprone:error_prone_check_api:${versions.errorProne}",
errorProne: "com.google.errorprone:error_prone_core:${versions.errorProne}",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,70 @@
plugins {
id "net.ltgt.errorprone" version "0.0.13"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,70 @@
plugins {
id "net.ltgt.errorprone" version "0.0.13"
id "com.github.johnrengelman.shadow" version "2.0.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -0,0 +1,70 @@
plugins {
id "net.ltgt.errorprone" version "0.0.13"
id "com.github.johnrengelman.shadow" version "2.0.1"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type.ClassType enclosingClassType = ASTHelpers.getType(enclosingClass);

for (String s : classesWithLifecycle) {
Type lifecycleType = state.getTypeFromString(s);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed it. Will fix in a separate commit.


@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
if (matcher(classesWithLifecycle).matches(tree, state)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SUBSCRIBE_MATCHERS = builder3.build();
}

private static final Matcher<ExpressionTree> METHOD_NAME_MATCHERS =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BugPattern(
name = "RxJavaMissingAutoDisposeErrorChecker",
summary = "Always apply an Autodispose scope before subscribing",
category = JDK,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@Override
public String linkUrl() {
return "https://github.com/uber/RIBs"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to a shortcut - d4883cc @hzsweers can this point to a wiki in autodispose? The readme in ribs is not updated.

Copy link
Collaborator

@ZacSweers ZacSweers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you edit this page? If so, can you write integration details for consumers?

Let's also add a section to the README linking to this. Something to the effect of:

There is an optional error-prone checker you can use to enforce use of AutoDispose. Integration steps can be found on the wiki

@@ -0,0 +1,32 @@
plugins {
id "net.ltgt.errorprone" version "0.0.13"
id "java"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

java-library, then use api and implementation configurations in dependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


public MissingAutoDisposeErrorChecker(ErrorProneFlags flags) {
Optional<ImmutableList<String>> inputClasses = flags.getList("AutoDisposeLeakCheck");
ImmutableList<String> classesWithLifecycle = new ImmutableList.Builder<String>()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This list seems to still be missing support fragments, LifecycleOwner, and ScopeProvider. Is that intentional? Also, we should have a way to allow the user to disable these built-in classes if they want.

Copy link
Contributor Author

@bangarharshit bangarharshit Jan 6, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add these. Not sure what is the best way to disable it. Another flag? cc: @msridhar if you have any suggestions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to treat flag as an override and not an addition. The developers may have to pass all these base classes themselves. Con - The callers need to be aware of all the base cases. Pros - Simple.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with 2nd as it is much simpler and requirements for different projects can be different. cf07e46


/**
* Checker for subscriptions not binding to lifecycle in components with lifecycle.
* Use -XepOpt:AutoDisposeLeakCheck to add support for custom components with lifecycle.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add a more fleshed out example for things like Conductor in a <code><pre> block

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no code changes. These are just changes for build.gradle. Not sure if this will be the correct place. Maybe we should remove this line also.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even a one liner is useful. This is a correct place for an example. We can also have a more fleshed out one in the wiki page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASTHelpers.findEnclosingNode(state.getPath(), ClassTree.class);
Type.ClassType enclosingClassType = ASTHelpers.getType(enclosingClass);

for (String s : classesWithLifecycle) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use a java 8 stream here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return false;
}

for (MethodMatchers.MethodNameMatcher nameMatcher : AS_CALL_MATCHERS) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stream

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
@SuppressWarnings("CheckTestExtendsBaseClass")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this, copy-pasta from internal

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Please make this a separate commit in the future though, that commit was mostly unrelated changes

tags = {BugPattern.StandardTags.CONCURRENCY},
severity = ERROR
)
public final class MissingAutoDisposeErrorChecker extends BugChecker
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming the AutoDisposeLeakCheck name sticks, we should call this AutoDisposeLeakChecker

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


@RunWith(JUnit4.class)
@SuppressWarnings("CheckTestExtendsBaseClass")
public class MissingAutoDisposeErrorCheckerTest {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call this AutoDisposeLeakCheckerTest

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

@Test
public void test_autodisposePositiveCases2() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we call this something more descriptive? Or at least have comments explaining what these two cases are verifying?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

47c35ce. Calling them default for default lifecycle and custom when input is provided.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, but please make this a separate commit next time. That commit's message/desc mentioned nothing about the descriptive method changes

*/
@AutoService(BugChecker.class)
@BugPattern(
name = "MissingAutoDisposeErrorChecker",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be AutoDisposeLeakCheck right? Not sure if I'm missing how these are conventionally done CC @msridhar

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name usually matches the class

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not AutoDisposeLeakChecker. 47c35ce

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious to know why you picked a 3rd new name. Checker should not be part of the name. Thinking more on this, let's call the bugpattern name MissingAutoDispose, and also call the class that

@ZacSweers
Copy link
Collaborator

The parallelflowable change is merged now if you want to rebase

@ZacSweers
Copy link
Collaborator

@bangarharshit are you planning to finisht this?

@bangarharshit
Copy link
Contributor Author

@hzsweers Sorry was busy with another thing.

I am getting weird issues with the build for android projects (it is working fine for normal java projects as an apt). Strangely, I am getting a similar issue for even normal java project after migrating to java-library. Something similar to - google/error-prone#730. I will try to resolve this issue over the weekend.

I can address the rest of the comments and then solely look on the build related issues.

@ZacSweers
Copy link
Collaborator

Sounds good, I'm likely going to cut a new release without waiting for this one in the meantime

@bangarharshit bangarharshit force-pushed the autodispose-error-prone-checker branch from d4883cc to a9bf402 Compare January 20, 2018 09:33
@bangarharshit
Copy link
Contributor Author

bangarharshit commented Jan 20, 2018

Merge parallel flowable changes and there was a bug when superclass constructor is invoked it is not MemberSelectTree.

Will update the wiki in sometime.

README.md Outdated

Snapshots of the development version are available in [Sonatype's snapshots repository][snapshots].

Static code analysis
Copy link
Collaborator

@ZacSweers ZacSweers Jan 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just call this Static Analysis. Also, please move this to above the Download section

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -49,7 +49,7 @@
@AutoService(BugChecker.class)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, this commit should have been two commits. One for the parallelflowable support, and another for the naming convention cleanups

settings.gradle Outdated
include 'autodispose-rxlifecycle'
include ':sample'
include ':test-utils'
include ':tooling:autodispose-error-prone-checker'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rename tooling to static-analysis. I suspect you borrowed the tooling convention from the internal monorepo, but there's not actually any build tooling here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also changing the name in gradle.properties for the artifact.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No the artifact name is fine. Only the directory needs to change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZacSweers
Copy link
Collaborator

Will update the wiki in sometime.

Do you have a time frame for that? I'd like to have that in place before merging this

@bangarharshit
Copy link
Contributor Author

I don't have the permission to update the wiki. Since Github doesn't support PR for the wiki, can you enable wiki edit for me?

@AutoService(BugChecker.class)
@BugPattern(
name = "AutoDisposeLeakChecker",
summary = "Always apply an AutoDispose scope before subscribing",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's flesh this out to mention that this is only when running in lifecycle scopes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BugPattern(
name = "AutoDisposeLeakChecker",
summary = "Always apply an AutoDispose scope before subscribing",
tags = {BugPattern.StandardTags.CONCURRENCY},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't need braces since it's one element. Also static import CONCURRENCY

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
@AutoService(BugChecker.class)
@BugPattern(
name = "AutoDisposeLeakChecker",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a comment somewhere that I can't find now, but let's call both the bugpattern name and the class UseAutoDispose. Don't have Checker as a suffix anywhere. This matches the error-prone convention

Copy link
Contributor Author

@bangarharshit bangarharshit Jan 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think maybe that comment wasn't published because I never saw that. Error-prone doesn't have a common stand against it - https://github.com/google/error-prone/blob/master/core/src/main/java/com/google/errorprone/bugpatterns/CompileTimeConstantChecker.java. Fixing it for this case. Maybe you meant this comment - #156 (comment).

Renaming this class for the fourth time based on feedback from PR (RxJavAutoMissingDisposeLeakChecker - MissingAutoDisposeLeakChecker -AutoDisposeLeakChecker - UseAutoDispose).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ZacSweers
Copy link
Collaborator

I think this looks good. Do you want to make a separate PR with the wiki contents (won't merge it, but just something we can review here), then I'll paste them into the wiki when that's done?

Also, after this is release, we should remove the one in uber/ribs and make it depend on this

@ZacSweers ZacSweers merged commit 46762c6 into uber:master Jan 21, 2018
@ZacSweers
Copy link
Collaborator

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants