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

Address existing UnknownNullness lint violations #395

Merged
merged 17 commits into from
Dec 17, 2018
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
053ca17
build: regenerate lint baseline file to account for changed lines + b…
fractalwrench Dec 11, 2018
2ff6ca5
feat: add nullability annotations to public Client methods
fractalwrench Dec 11, 2018
8f22662
feat: add nullability annotations to public Bugsnag.java methods
fractalwrench Dec 11, 2018
8472047
feat: add nullability annotations for Client
fractalwrench Dec 11, 2018
d1fefcd
feat: add nullability annotations to NativeInterface class
fractalwrench Dec 12, 2018
181e809
feat: add nullability annotations to remaining public sites
fractalwrench Dec 12, 2018
ebab41a
feat: update mazerunner delivery signatures to use non-null parameters
fractalwrench Dec 13, 2018
a633394
Merge pull request #396 from bugsnag/null-annotations-client
fractalwrench Dec 13, 2018
cfa6c7a
Merge pull request #397 from bugsnag/null-annotations-bugsnag
fractalwrench Dec 13, 2018
221b04e
Merge pull request #399 from bugsnag/null-annotations-native-interface
fractalwrench Dec 13, 2018
78e3df2
Merge pull request #398 from bugsnag/null-annotations-config
fractalwrench Dec 13, 2018
24e414e
Merge branch 'resolve-unknown-nullness-issues' into null-annotations-…
fractalwrench Dec 13, 2018
4e272eb
Merge pull request #400 from bugsnag/null-annotations-remaining
fractalwrench Dec 13, 2018
99fd5ca
Merge branch 'next' into resolve-unknown-nullness-issues
fractalwrench Dec 13, 2018
18c5b5a
feat: add nullability annotations to missed getters
fractalwrench Dec 13, 2018
55f1577
feat: final adjustments of nullability annotations on second sweep
fractalwrench Dec 14, 2018
194f576
docs: add changelog entry
fractalwrench Dec 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ internal fun createSlowDelivery(context: Context): Delivery {
val delivery = DefaultDelivery(cm)

return object : Delivery {
override fun deliver(payload: SessionTrackingPayload?, config: Configuration?) {
override fun deliver(payload: SessionTrackingPayload, config: Configuration) {
Thread.sleep(500)
delivery.deliver(payload, config)
}

override fun deliver(report: Report?, config: Configuration?) {
override fun deliver(report: Report, config: Configuration) {
Thread.sleep(500)
delivery.deliver(report, config)
}
Expand All @@ -47,18 +47,18 @@ internal fun createCustomHeaderDelivery(context: Context): Delivery {
return object : Delivery {
val delivery: DefaultDelivery = createDefaultDelivery(context)

override fun deliver(payload: SessionTrackingPayload?, config: Configuration?) {
deliver(config?.sessionEndpoint, payload, config?.sessionApiHeaders)
override fun deliver(payload: SessionTrackingPayload, config: Configuration) {
deliver(config.sessionEndpoint, payload, config.sessionApiHeaders)
}

override fun deliver(report: Report?, config: Configuration?) {
deliver(config?.endpoint, report, config?.errorApiHeaders)
override fun deliver(report: Report, config: Configuration) {
deliver(config.endpoint, report, config.errorApiHeaders)
}

fun deliver(endpoint: String?,
streamable: JsonStream.Streamable?,
headers: MutableMap<String, String>?) {
headers!!["Custom-Client"] = "Hello World"
fun deliver(endpoint: String,
streamable: JsonStream.Streamable,
headers: MutableMap<String, String>) {
headers["Custom-Client"] = "Hello World"
delivery.deliver(endpoint, streamable, headers)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ abstract internal class Scenario(protected val config: Configuration,
protected fun disableSessionDelivery() {
val baseDelivery = Bugsnag.getClient().config.delivery
Bugsnag.getClient().config.delivery = object: Delivery {
override fun deliver(payload: SessionTrackingPayload?, config: Configuration?) {
override fun deliver(payload: SessionTrackingPayload, config: Configuration) {
throw DeliveryFailureException("Session Delivery NOP", RuntimeException("NOP"))
}

override fun deliver(report: Report?, config: Configuration?) {
override fun deliver(report: Report, config: Configuration) {
baseDelivery.deliver(report, config)
}
}
Expand All @@ -34,11 +34,11 @@ abstract internal class Scenario(protected val config: Configuration,
protected fun disableReportDelivery() {
val baseDelivery = Bugsnag.getClient().config.delivery
Bugsnag.getClient().config.delivery = object: Delivery {
override fun deliver(payload: SessionTrackingPayload?, config: Configuration?) {
override fun deliver(payload: SessionTrackingPayload, config: Configuration) {
baseDelivery.deliver(payload, config)
}

override fun deliver(report: Report?, config: Configuration?) {
override fun deliver(report: Report, config: Configuration) {
throw DeliveryFailureException("Session Delivery NOP", RuntimeException("NOP"))
}
}
Expand All @@ -57,11 +57,11 @@ abstract internal class Scenario(protected val config: Configuration,

protected fun disableAllDelivery(config: Configuration) {
config.delivery = object: Delivery {
override fun deliver(payload: SessionTrackingPayload?, config: Configuration?) {
override fun deliver(payload: SessionTrackingPayload, config: Configuration) {
throw DeliveryFailureException("Error Delivery NOP", RuntimeException("NOP"))
}

override fun deliver(report: Report?, config: Configuration?) {
override fun deliver(report: Report, config: Configuration) {
throw DeliveryFailureException("Session Delivery NOP", RuntimeException("NOP"))
}
}
Expand Down
1,969 changes: 0 additions & 1,969 deletions sdk/lint-baseline.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bugsnag.android;

import android.support.annotation.NonNull;

import java.util.Locale;

/**
Expand All @@ -10,7 +12,7 @@
public class BadResponseException extends Exception {
private static final long serialVersionUID = -870190454845379171L;

public BadResponseException(String msg, int responseCode) {
public BadResponseException(@NonNull String msg, int responseCode) {
super(String.format(Locale.US, "%s (%d)", msg, responseCode));
}
}
4 changes: 3 additions & 1 deletion sdk/src/main/java/com/bugsnag/android/BeforeNotify.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bugsnag.android;

import android.support.annotation.NonNull;

/**
* A callback to be run before reports are sent to Bugsnag.
* <p>
Expand All @@ -18,5 +20,5 @@ public interface BeforeNotify {
* @param error the error to be sent to Bugsnag
* @see Error
*/
boolean run(Error error);
boolean run(@NonNull Error error);
}
4 changes: 3 additions & 1 deletion sdk/src/main/java/com/bugsnag/android/BeforeSend.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bugsnag.android;

import android.support.annotation.NonNull;

/**
* A callback to be run before every report sent to Bugsnag.
* <p>
Expand All @@ -16,5 +18,5 @@ public interface BeforeSend {
*
* @param report the {@link Report} to be sent to Bugsnag
*/
boolean run(Report report);
boolean run(@NonNull Report report);
}
5 changes: 4 additions & 1 deletion sdk/src/main/java/com/bugsnag/android/BreadcrumbType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.bugsnag.android;

import android.support.annotation.NonNull;

/**
* Recognized types of breadcrumbs
*/
Expand Down Expand Up @@ -40,11 +42,12 @@ public enum BreadcrumbType {

private final String type;

BreadcrumbType(String type) {
BreadcrumbType(@NonNull String type) {
this.type = type;
}

@Override
@NonNull
public String toString() {
return type;
}
Expand Down
69 changes: 41 additions & 28 deletions sdk/src/main/java/com/bugsnag/android/Bugsnag.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static Client init(@NonNull Context androidContext, @NonNull Configuratio
*
* @param appVersion the app version to send
*/
public static void setAppVersion(final String appVersion) {
public static void setAppVersion(@NonNull final String appVersion) {
getClient().setAppVersion(appVersion);
}

Expand All @@ -95,7 +95,7 @@ public static void setAppVersion(final String appVersion) {
*
* @return Context
*/
public static String getContext() {
@Nullable public static String getContext() {
return getClient().getContext();
}

Expand All @@ -106,7 +106,7 @@ public static String getContext() {
*
* @param context set what was happening at the time of a crash
*/
public static void setContext(final String context) {
public static void setContext(@Nullable final String context) {
getClient().setContext(context);
}

Expand All @@ -121,7 +121,7 @@ public static void setContext(final String context) {
* instead.
*/
@Deprecated
public static void setEndpoint(final String endpoint) {
public static void setEndpoint(@NonNull final String endpoint) {
getClient().setEndpoint(endpoint);
}

Expand All @@ -134,7 +134,7 @@ public static void setEndpoint(final String endpoint) {
* @param buildUuid the buildUuid.
*/
@SuppressWarnings("checkstyle:AbbreviationAsWordInName")
public static void setBuildUUID(final String buildUuid) {
public static void setBuildUUID(@Nullable final String buildUuid) {
getClient().setBuildUUID(buildUuid);
}

Expand All @@ -151,7 +151,7 @@ public static void setBuildUUID(final String buildUuid) {
*
* @param filters a list of keys to filter from metaData
*/
public static void setFilters(final String... filters) {
public static void setFilters(@Nullable final String... filters) {
getClient().setFilters(filters);
}

Expand All @@ -164,7 +164,7 @@ public static void setFilters(final String... filters) {
*
* @param ignoreClasses a list of exception classes to ignore
*/
public static void setIgnoreClasses(final String... ignoreClasses) {
public static void setIgnoreClasses(@Nullable final String... ignoreClasses) {
getClient().setIgnoreClasses(ignoreClasses);
}

Expand All @@ -179,7 +179,7 @@ public static void setIgnoreClasses(final String... ignoreClasses) {
* @param notifyReleaseStages a list of releaseStages to notify for
* @see #setReleaseStage
*/
public static void setNotifyReleaseStages(final String... notifyReleaseStages) {
public static void setNotifyReleaseStages(@Nullable final String... notifyReleaseStages) {
getClient().setNotifyReleaseStages(notifyReleaseStages);
}

Expand All @@ -195,7 +195,7 @@ public static void setNotifyReleaseStages(final String... notifyReleaseStages) {
*
* @param projectPackages a list of package names
*/
public static void setProjectPackages(final String... projectPackages) {
public static void setProjectPackages(@Nullable final String... projectPackages) {
getClient().setProjectPackages(projectPackages);
}

Expand All @@ -209,7 +209,7 @@ public static void setProjectPackages(final String... projectPackages) {
* @param releaseStage the release stage of the app
* @see #setNotifyReleaseStages {@link #setLoggingEnabled(boolean)}
*/
public static void setReleaseStage(final String releaseStage) {
public static void setReleaseStage(@Nullable final String releaseStage) {
getClient().setReleaseStage(releaseStage);
}

Expand Down Expand Up @@ -247,7 +247,9 @@ public static void setAutoCaptureSessions(boolean autoCapture) {
* @param email the email address of the current user
* @param name the name of the current user
*/
public static void setUser(final String id, final String email, final String name) {
public static void setUser(@Nullable final String id,
@Nullable final String email,
@Nullable final String name) {
getClient().setUser(id, email, name);
}

Expand All @@ -265,7 +267,7 @@ public static void clearUser() {
*
* @param id a unique identifier of the current user
*/
public static void setUserId(final String id) {
public static void setUserId(@Nullable final String id) {
getClient().setUserId(id);
}

Expand All @@ -275,7 +277,7 @@ public static void setUserId(final String id) {
*
* @param email the email address of the current user
*/
public static void setUserEmail(final String email) {
public static void setUserEmail(@Nullable final String email) {
getClient().setUserEmail(email);
}

Expand All @@ -285,7 +287,7 @@ public static void setUserEmail(final String email) {
*
* @param name the name of the current user
*/
public static void setUserName(final String name) {
public static void setUserName(@Nullable final String name) {
getClient().setUserName(name);
}

Expand Down Expand Up @@ -347,7 +349,7 @@ public static void setSessionTrackingApiClient(@NonNull SessionTrackingApiClient
* @param beforeNotify a callback to run before sending errors to Bugsnag
* @see BeforeNotify
*/
public static void beforeNotify(final BeforeNotify beforeNotify) {
public static void beforeNotify(@NonNull final BeforeNotify beforeNotify) {
getClient().beforeNotify(beforeNotify);
}

Expand All @@ -369,7 +371,8 @@ public static void beforeNotify(final BeforeNotify beforeNotify) {
* @param beforeRecordBreadcrumb a callback to run before a breadcrumb is captured
* @see BeforeRecordBreadcrumb
*/
public static void beforeRecordBreadcrumb(final BeforeRecordBreadcrumb beforeRecordBreadcrumb) {
public static void beforeRecordBreadcrumb(
@NonNull final BeforeRecordBreadcrumb beforeRecordBreadcrumb) {
getClient().beforeRecordBreadcrumb(beforeRecordBreadcrumb);
}

Expand All @@ -389,7 +392,8 @@ public static void notify(@NonNull final Throwable exception) {
* @param callback callback invoked on the generated error report for
* additional modification
*/
public static void notify(@NonNull final Throwable exception, final Callback callback) {
public static void notify(@NonNull final Throwable exception,
@Nullable final Callback callback) {
getClient().notify(exception, callback);
}

Expand All @@ -405,7 +409,7 @@ public static void notify(@NonNull final Throwable exception, final Callback cal
public static void notify(@NonNull String name,
@NonNull String message,
@NonNull StackTraceElement[] stacktrace,
Callback callback) {
@Nullable Callback callback) {
getClient().notify(name, message, stacktrace, callback);
}

Expand All @@ -416,7 +420,8 @@ public static void notify(@NonNull String name,
* @param severity the severity of the error, one of Severity.ERROR,
* Severity.WARNING or Severity.INFO
*/
public static void notify(@NonNull final Throwable exception, final Severity severity) {
public static void notify(@NonNull final Throwable exception,
@NonNull final Severity severity) {
getClient().notify(exception, severity);
}

Expand Down Expand Up @@ -448,7 +453,8 @@ public void beforeNotify(@NonNull Report report) {
* @deprecated Use {@link #notify(Throwable, Callback)} to send and modify error reports
*/
@Deprecated
public static void notify(@NonNull final Throwable exception, final Severity severity,
public static void notify(@NonNull final Throwable exception,
@NonNull final Severity severity,
@NonNull final MetaData metaData) {
getClient().notify(exception, new Callback() {
@Override
Expand All @@ -472,8 +478,10 @@ public void beforeNotify(@NonNull Report report) {
* to send and modify error reports
*/
@Deprecated
public static void notify(@NonNull String name, @NonNull String message,
@NonNull StackTraceElement[] stacktrace, Severity severity,
public static void notify(@NonNull String name,
@NonNull String message,
@NonNull StackTraceElement[] stacktrace,
@NonNull Severity severity,
@NonNull MetaData metaData) {
final Severity finalSeverity = severity;
final MetaData finalMetaData = metaData;
Expand Down Expand Up @@ -502,8 +510,11 @@ public void beforeNotify(@NonNull Report report) {
@Deprecated
@SuppressWarnings("checkstyle:JavadocTagContinuationIndentation")

public static void notify(@NonNull String name, @NonNull String message, String context,
@NonNull StackTraceElement[] stacktrace, Severity severity,
public static void notify(@NonNull String name,
@NonNull String message,
@Nullable String context,
@NonNull StackTraceElement[] stacktrace,
@NonNull Severity severity,
@NonNull MetaData metaData) {
final String finalContext = context;
final Severity finalSeverity = severity;
Expand All @@ -523,9 +534,9 @@ public void beforeNotify(@NonNull Report report) {
* Android is not supported.
*/
public static void internalClientNotify(@NonNull final Throwable exception,
Map<String, Object> clientData,
@NonNull Map<String, Object> clientData,
boolean blocking,
Callback callback) {
@Nullable Callback callback) {
getClient().internalClientNotify(exception, clientData, blocking, callback);
}

Expand All @@ -542,7 +553,9 @@ public static void internalClientNotify(@NonNull final Throwable exception,
* @param key the name of the diagnostic information
* @param value the contents of the diagnostic information
*/
public static void addToTab(final String tab, final String key, final Object value) {
public static void addToTab(@NonNull final String tab,
@NonNull final String key,
@Nullable final Object value) {
getClient().addToTab(tab, key, value);
}

Expand All @@ -551,7 +564,7 @@ public static void addToTab(final String tab, final String key, final Object val
*
* @param tabName the dashboard tab to remove diagnostic data from
*/
public static void clearTab(String tabName) {
public static void clearTab(@NonNull String tabName) {
getClient().clearTab(tabName);
}

Expand Down
Loading