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

Add android nullness annotations #182

Merged
merged 3 commits into from
Jun 7, 2017

Conversation

kzaikin
Copy link
Contributor

@kzaikin kzaikin commented May 27, 2017

The pull request is built from presumably small commits

Commit 1 adds tests on existing NullnessAnnotations inside spotbugs gradle project
Commit 2 adds android annotations to NullnessAnnotations along with a small refactoring (we already have tests so it's safe)
Commit 3 adds android annotations to TypeQualifierResolver and a few integration tests using SpotBugsRule approach

Fix #96

@kzaikin kzaikin force-pushed the android-nullness branch 2 times, most recently from 1835823 to d26e1e1 Compare May 27, 2017 15:22

compileOnly 'com.apple:AppleJavaExtensions:1.4'
compile 'junit:junit:4.12'
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 dependency will come from test-harness

// This seem to work with most tests except the new one based on AnalysisRunner
// TODO fix AnalysisRunner or the test classpath
classpath = project.sourceSets.main.runtimeClasspath \
+ project(':spotbugs').sourceSets.main.runtimeClasspath \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the true way of referencing classes is adding dependency on a project

@@ -214,7 +214,6 @@ private void setUpEngine(String... analyzeMe) throws IOException {
}
}

project.addAuxClasspathEntry("lib/junit.jar");
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 not necessary as soon as junit is in classpath via project dependencies

@@ -236,7 +235,9 @@ private void setUpEngine(String... analyzeMe) throws IOException {
String[] cpParts = classpath.split(File.pathSeparator);
for (String cpStr : cpParts) {
File file = new File(cpStr);
project.addAuxClasspathEntry(file.getCanonicalPath());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

classpath might contain empty directories witch make project unhappy

@kzaikin kzaikin changed the title Add android nullness annotations #96 WIP: Add android nullness annotations May 29, 2017
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 8fda833 on kzaikin:android-nullness into ** on spotbugs:master**.

Copy link
Member

@KengoTODA KengoTODA left a comment

Choose a reason for hiding this comment

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

  • update CHANGELOG.md
  • merge latest master branch and resolve conflict

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 57.547% when pulling f70243c on kzaikin:android-nullness into 70abe04 on spotbugs:master.

@@ -4,6 +4,10 @@ This is the changelog for SpotBugs. This follows [Keep a Changelog v0.3](http://

## Unreleased (2017/??/??)

### Added

* Make TypeQualifierResolver recognize android.support.annotation.NonNull and Nullable ([#182](https://github.com/spotbugs/spotbugs/pull/182))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added it

@kzaikin kzaikin changed the title WIP: Add android nullness annotations Add android nullness annotations Jun 4, 2017
@kzaikin
Copy link
Contributor Author

kzaikin commented Jun 6, 2017

Should anything else be done to have this merged?

@Retention(CLASS)
@Target({METHOD, PARAMETER, FIELD, ANNOTATION_TYPE, PACKAGE})
public @interface NonNull {
}
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@KengoTODA KengoTODA left a comment

Choose a reason for hiding this comment

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

LGTM

@KengoTODA KengoTODA merged commit 20bd223 into spotbugs:master Jun 7, 2017
@kzaikin kzaikin deleted the android-nullness branch June 8, 2017 07:46
@scheffield
Copy link

scheffield commented Jul 1, 2017

This change is really great. Unfortunately the existing gradle plugin in version 1.1 still points to RC2 which makes this change unavailable to Android builds, right?

@KengoTODA
Copy link
Member

@scheffield You can use spotbugs.toolVersion to specify the version of SpotBugs, please have a try:

http://spotbugs.readthedocs.io/en/latest/migration.html#findbugs-gradle-plugin

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.

None yet

4 participants