Skip to content

Commit

Permalink
address compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Jan 31, 2024
1 parent 9cc3fe9 commit 39d7aa4
Show file tree
Hide file tree
Showing 16 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.plugins.quality.Checkstyle
import org.gradle.api.plugins.quality.CheckstyleExtension
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
Expand All @@ -27,6 +28,7 @@ class InternalEmbracePlugin : Plugin<Project> {
project.pluginManager.withPlugin("com.android.library") {
val android = project.extensions.getByType(LibraryExtension::class.java)
configureAndroidExtension(project, android)
configureJavaOptions(project)
configureKotlinOptions(project)
}

Expand Down Expand Up @@ -173,6 +175,13 @@ class InternalEmbracePlugin : Plugin<Project> {
}
}

private fun configureJavaOptions(project: Project) {
project.tasks.withType(JavaCompile::class.java).all {
val args = listOf("-Xlint:unchecked", "-Xlint:deprecation")
options.compilerArgs.addAll(args)
}
}

/**
* Adds common plugins to the project.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ internal class TracingApiTest {
harness.fakeClock.tick(100L)
embrace.start(harness.fakeCoreModule.context)
harness.recordSession {
assertTrue(
returnIfConditionMet(desiredValueSupplier = { true }, waitTimeMs = 1000) { embrace.isTracingAvailable() }
)
val parentSpan = checkNotNull(embrace.createSpan(name = "test-trace-root"))
assertTrue(parentSpan.start())
assertTrue(parentSpan.addAttribute("oMg", "OmG"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ public boolean endView(@NonNull String name) {
return false;
}

@SuppressWarnings("deprecation")
@Override
public boolean isTracingAvailable() {
return impl.tracer.isTracingAvailable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ internal class EmbraceInternalInterfaceImpl(
)
}

@Suppress("DEPRECATION")
override fun logHandledException(
throwable: Throwable,
type: LogType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ internal class UninitializedSdkInternalInterfaceImpl(

override fun logError(message: String, properties: Map<String, Any>?, stacktrace: String?, isException: Boolean) {}

@Suppress("DEPRECATION")
override fun logHandledException(
throwable: Throwable,
type: LogType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ static void logOnClickEvent(android.view.View view, TapBreadcrumbType breadcrumb
} catch (Exception e) {
viewName = UNKNOWN_ELEMENT_NAME;
}
Pair point = null;
Pair<Float, Float> point = null;

Check warning on line 28 in embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/ViewSwazzledHooks.java

View check run for this annotation

Codecov / codecov/patch

embrace-android-sdk/src/main/java/io/embrace/android/embracesdk/ViewSwazzledHooks.java#L28

Added line #L28 was not covered by tests
try {
point = new Pair<>(view.getX(), view.getY());
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ static int getOperatingSystemVersionCode() {
* @return the device's screen resolution
*/
@Nullable
@SuppressWarnings("deprecation")
static String getScreenResolution(WindowManager windowManager) {
try {
InternalStaticEmbraceLogger.logDeveloper("MetadataUtils", "Computing screen resolution");
Expand Down Expand Up @@ -164,6 +165,7 @@ static long getInternalStorageFreeCapacity(StatFs statFs) {
*/
@TargetApi(Build.VERSION_CODES.O)
@Nullable
@SuppressWarnings("deprecation")
static Long getDeviceDiskAppUsage(
StorageStatsManager storageStatsManager,
PackageManager packageManager,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("DEPRECATION")

package io.embrace.android.embracesdk.injection

import android.preference.PreferenceManager
Expand All @@ -15,6 +17,7 @@ internal class AndroidServicesModuleImpl(
coreModule: CoreModule,
workerThreadModule: WorkerThreadModule,
) : AndroidServicesModule {

override val preferencesService: PreferencesService by singleton {
val lazyPrefs = lazy {
PreferenceManager.getDefaultSharedPreferences(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ internal class EssentialServiceModuleImpl(
coreModule.jsonSerializer
)

@Suppress("DEPRECATION")
private val lazyPackageInfo = lazy {
coreModule.context.packageManager.getPackageInfo(coreModule.context.packageName, 0)
}
Expand All @@ -106,6 +107,7 @@ internal class EssentialServiceModuleImpl(
}
}

@Suppress("DEPRECATION")
private val lazyAppVersionCode: Lazy<String> = lazy {
try {
lazyPackageInfo.value.versionCode.toString()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("DEPRECATION")

package io.embrace.android.embracesdk.internal

import android.util.Pair
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ internal class EmbracePreferencesService(
editor.apply()
}

@Suppress("UNCHECKED_CAST")
private fun SharedPreferences.getMapPreference(
key: String
): Map<String, String>? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
* @see <a href="https://cwiki.apache.org/confluence/display/MAVENOLD/Versioning">"Versioning" on Maven Wiki</a>
*/

@SuppressWarnings("unchecked")
class ComparableVersion implements Comparable<ComparableVersion> {
private String value;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("DEPRECATION")

package io.embrace.android.embracesdk.session.lifecycle

import androidx.lifecycle.Lifecycle
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import org.junit.BeforeClass
import org.junit.Test
import java.io.ByteArrayOutputStream
import java.io.OutputStream
import java.nio.charset.Charset

internal class EmbraceDeliveryCacheManagerTest {

Expand Down Expand Up @@ -150,11 +149,9 @@ internal class EmbraceDeliveryCacheManagerTest {
every { cacheService.cacheBytes(any(), any()) } throws Exception()

val sessionMessage = createSessionMessage("test_cache_fails")
val expectedBytes = serializer.toJson(sessionMessage).toByteArray()

deliveryCacheManager.saveSession(sessionMessage, NORMAL_END)

val charset = Charset.defaultCharset()
assertNull(deliveryCacheManager.loadSessionAsAction("test_cache_fails"))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal class UninitializedSdkInternalInterfaceImplTest {
impl = UninitializedSdkInternalInterfaceImpl(InternalTracer(initModule.tracer, initModule.clock))
}

@Suppress("DEPRECATION")
@Test
fun `check no errors thrown when invoked`() {
impl.logInfo("", emptyMap())
Expand Down

0 comments on commit 39d7aa4

Please sign in to comment.