Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate lint check to new PSI API #130

Merged
merged 3 commits into from
Nov 23, 2016
Merged

Conversation

felipecsl
Copy link
Contributor

Custom lint checks using the old and deprecated Lombok AST API cause an incompatibility between the Android lint and Retrolambda as described here evant/gradle-retrolambda#96

Migrating to the new API fixes the issue.

Copy link
Member

@lkorth lkorth left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @felipecsl!

I made a few comments on code style and the fact that we can't upgrade the gradle build plugin to 2.2.2 yet.

@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.3'
classpath 'com.android.tools.build:gradle:2.2.2'
Copy link
Member

Choose a reason for hiding this comment

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

This upgrade is not possible at the moment, Robolectric 3.0 does not work with gradle build plugin 2.2.2 and upgrading Robolectric to 3.1.4 causes a conflict with PowerMock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmmm weird, we have Robolectric 3.0 working fine with the plugin v2.2.2, anyways this is unrelated so I'll just revert it

Copy link
Member

Choose a reason for hiding this comment

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

The difference is probably an Android application vs library. The location of the merged manifest changed in 2.2.2 and Robolectric has the path hard coded to the old path in 3.0 for libraries.


private static final List<String> METHODS = Collections.emptyList();

public class BetaDetector extends Detector implements Detector.JavaPsiScanner {
Copy link
Member

Choose a reason for hiding this comment

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

Newline after this.


public class BetaDetector extends Detector implements Detector.JavaPsiScanner {
// This would normally be private final, but has exposed here for testing purposes, since there
// seems to be no way to inject it via the Detector constructor using LintDetectorTest
Copy link
Member

Choose a reason for hiding this comment

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

This seems fine, I don't think it really needs a comment.


import static org.assertj.core.api.Assertions.assertThat;

public class BetaDetectorTest extends LintDetectorTest {
Copy link
Member

Choose a reason for hiding this comment

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

Newline here.

@felipecsl
Copy link
Contributor Author

PR updated

@felipecsl
Copy link
Contributor Author

would it be possible to get this out in a SNAPSHOT release of the library?

@lkorth lkorth merged commit 20c3f6d into braintree:master Nov 23, 2016
@lkorth
Copy link
Member

lkorth commented Nov 23, 2016

I've released this in 2.3.12-SNAPSHOT. We have had issues with SNAPSHOTs being cleaned up after a short period of time, so I can't say how long it will stick around, but it should be available for a few days.

@felipecsl felipecsl deleted the lint-psi-api branch November 23, 2016 20:51
@felipecsl
Copy link
Contributor Author

Since the latest release is 2.3.12, i'd expect the current snapshot to be 2.3.13-SNAPSHOT, no?

@felipecsl
Copy link
Contributor Author

Also I can't find 2.3.12-SNAPSHOT anywhere

@lkorth
Copy link
Member

lkorth commented Jan 10, 2017

Sorry about the wait @felipecsl, I've just returned after some leave.

No, we don't currently version snapshots like that since we don't know the next version number at the time, but it is a bit backwards compared to most libraries' snapshot versioning.

I've released 2.3.12-SNAPSHOT again and you can find it https://oss.sonatype.org/content/repositories/snapshots/com/braintreepayments/api/braintree/2.3.12-SNAPSHOT/

I'll make a full release soon.

@lkorth
Copy link
Member

lkorth commented Jan 14, 2017

Running lint with this change spits out quite a bit of noise because of missing classes and results in the custom rules not being loaded.

Could not load custom rule jar file /braintree-android/Demo/build/intermediates/exploded-aar/com.braintreepayments.api/Braintree/2.3.12-SNAPSHOT/jars/lint.jar
java.lang.NoClassDefFoundError: com/android/tools/lint/detector/api/Detector$JavaPsiScanner

Since the custom rules aren't currently being used for anything and I haven't seen any workable fix for this, I've just removed them for now.

The 2.4.0 release is going out right now with these changes.

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.

2 participants