Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion LICENSE-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ import(test),com.jakewharton.android.repackaged,Apache-2.0,"Copyright (C) 2007 T
import(test),com.parse.bolts,"BSD License","Copyright (c) Facebook, Inc. and its affiliates."
import(test),com.squareup,Apache-2.0,"Copyright 2015 Square, Inc."
import(test),dev.drewhamilton.poko,Apache-2.0,Copyright 2020-Present Drew Hamilton
import(test),dev.zacsweers.kctfork,MPL-2.0,"Copyright (C) 2023 Thilo Schuchort"
import(test),greatest,ICT,"Copyright (c) 2011-2018 Scott Vokes <vokes.s@gmail.com>"
import(test),io.github.davidburstrom.contester,Apache-2.0,"Copyright 2022-2024 David Burström"
import(test),io.github.detekt.sarif4k,Apache-2.0,"Copyright 2021 Artur Bosch & Contributors"
Expand Down Expand Up @@ -185,7 +186,6 @@ build,com.fasterxml.jackson.dataformat,Apache-2.,"Copyright (c) 2007- Tatu Salor
build,com.fasterxml.jackson.module,Apache-2.0,"Copyright (c) 2007- Tatu Saloranta"
build,com.fasterxml.woodstox,Apache-2.0,"Copyright (c) 2007- Tatu Saloranta"
build,com.github.ajalt.clikt,Apache-2.0,"Copyright clikt authors"
build,com.github.tschuchortdev,MPL-2.0,"Copyright (C) 2023 Thilo Schuchort"
build,com.google.android,Apache-2.0,Copyright (C) 2013 The Android Open Source Project
build,com.google.api.grpc,Apache-2.0,Copyright 2020 Google LLC
build,com.google.auto,Apache-2.0,"Copyright 2014 Google LLC"
Expand All @@ -209,6 +209,7 @@ build,commons-cli,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
build,commons-codec,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
build,commons-io,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
build,commons-logging,Apache-2.0,Copyright 2002-2024 The Apache Software Foundation
build,dev.detekt,Apache-2.0,Copyright 2016-2017 Artur Bosch & Contributors
build,io.github.aakira,Apache-2.0,"Copyright (C) 2019 A.Akira"
build,io.gitlab.arturbosch.detekt,Apache-2.0,Copyright 2016-2019 the original author or authors
build,io.github.classgraph,MIT,"Copyright (c) 2019 Luke Hutchison"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile

internal fun Project.kotlinConfig(
evaluateWarningsAsErrors: Boolean = true,
jvmBytecodeTarget: JvmTarget = JvmTarget.JVM_17
jvmBytecodeTarget: JvmTarget = JvmTarget.JVM_17,
kotlinApiVersion: KotlinVersion = KotlinVersion.KOTLIN_2_0,
kotlinLanguageVersion: KotlinVersion = KotlinVersion.KOTLIN_2_0
Comment thread
0xnm marked this conversation as resolved.
) {
taskConfig<KotlinJvmCompile> {
compilerOptions {
jvmTarget.set(jvmBytecodeTarget)
val isCI = System.getenv("CI").toBoolean()
allWarningsAsErrors.set(evaluateWarningsAsErrors && isCI)
apiVersion.set(KotlinVersion.KOTLIN_2_0)
languageVersion.set(KotlinVersion.KOTLIN_2_0)
apiVersion.set(kotlinApiVersion)
languageVersion.set(kotlinLanguageVersion)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class ApiSurfacePlugin : Plugin<Project> {
private fun Project.createParserConfiguration(): Configuration {
val kotlinVersion = extensions.getByType<VersionCatalogsExtension>()
.named("libs")
.findVersion("kotlin")
.findVersion("kotlinBuildscript")
.orElseThrow { IllegalStateException("No `kotlin` version found in the version catalog") }
return configurations.create(CONFIGURATION_PARSER) {
isCanBeConsumed = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.datadog.gradle.config.kotlinConfig
import com.datadog.gradle.config.publishingConfig
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import javax.inject.Inject

/**
Expand All @@ -29,9 +30,11 @@ abstract class DatadogBuildExtension @Inject constructor(
/** Aligns Kotlin compilation: bytecode target, API/language version and warning strictness. */
fun applyKotlinConfig(
evaluateWarningsAsErrors: Boolean = true,
jvmBytecodeTarget: JvmTarget = JvmTarget.JVM_17
jvmBytecodeTarget: JvmTarget = JvmTarget.JVM_17,
kotlinApiVersion: KotlinVersion = KotlinVersion.KOTLIN_2_0,
kotlinLanguageVersion: KotlinVersion = KotlinVersion.KOTLIN_2_0
) {
project.kotlinConfig(evaluateWarningsAsErrors, jvmBytecodeTarget)
project.kotlinConfig(evaluateWarningsAsErrors, jvmBytecodeTarget, kotlinApiVersion, kotlinLanguageVersion)
}

/** Applies the shared `com.android.library` setup: SDK levels, source sets, lint and packaging. */
Expand Down
27 changes: 4 additions & 23 deletions build-logic/src/main/kotlin/detekt-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import com.android.build.api.variant.LibraryAndroidComponentsExtension
import io.gitlab.arturbosch.detekt.Detekt
import dev.detekt.gradle.Detekt

/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
Expand All @@ -8,7 +7,7 @@ import io.gitlab.arturbosch.detekt.Detekt
*/

plugins {
id("io.gitlab.arturbosch.detekt")
id("dev.detekt")
}

dependencies {
Expand All @@ -32,9 +31,8 @@ tasks.withType<Detekt>().configureEach {
reports {
sarif.required = false
html.required = false
xml.required = false
txt.required = false
md.required = false
markdown.required = false
checkstyle.required = false
}
}

Expand All @@ -48,20 +46,3 @@ tasks.detekt {
tasks.named("detektTest")
)
}

// testFixtures is an Android source set and isn't picked up by the detekt/AGP on AGP 8, this should
// be able to be deleted in AGP 9 and covered by `detektTest`
extensions.getByType<LibraryAndroidComponentsExtension>().onVariants { variant ->
if (variant.name == "debug") {
variant.testFixtures?.let { testFixtures ->
val detektTestFixtures = tasks.register<Detekt>("detektTestFixtures") {
source(layout.projectDirectory.dir("src/testFixtures/kotlin"))
config.setFrom(detektConfigFiles)
classpath.setFrom(testFixtures.compileClasspath)
}
tasks.detekt {
dependsOn(detektTestFixtures)
}
}
}
}
29 changes: 11 additions & 18 deletions build-logic/src/main/kotlin/test-pyramid-api-surface.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,19 @@
*/

import com.android.build.api.variant.LibraryAndroidComponentsExtension
import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.api.artifacts.VersionCatalogsExtension
import dev.detekt.gradle.Detekt
import org.gradle.api.attributes.Usage
import org.gradle.kotlin.dsl.getByType
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.the

// Applying `io.gitlab.arturbosch.detekt` would also register its own detekt tasks and apply detekt.yml
// - unwanted, since this plugin isn't linting, only using Detekt as an engine. All our own task actually needs
// from the plugin is the engine classpath, so provide that directly via detached configurations instead of applying it.
val detektVersion = the<VersionCatalogsExtension>().named("libs").findVersion("detekt").get().requiredVersion
val detektEngineClasspath = configurations.detachedConfiguration(
dependencies.create("io.gitlab.arturbosch.detekt:detekt-cli:$detektVersion")
)
val detektPluginClasspath = configurations.detachedConfiguration(
dependencies.create(project(":tools:detekt"))
)
plugins {
// Provides the Detekt engine classpath and the defaults of the `Detekt` tasks
id("dev.detekt")
}

dependencies {
detektPlugins(project(":tools:detekt"))
}

val apiSurfaceLogFile = layout.buildDirectory.file("reports/detekt-test-pyramid/apiSurface.log")
val generatedConfigFile = layout.buildDirectory.file("tmp/detekt-test-pyramid/apiSurfaceTestPyramidConfig.yml")
Expand All @@ -47,8 +43,6 @@ androidComponents.onVariants(androidComponents.selector().withBuildType("debug")
)
}

detektClasspath.setFrom(detektEngineClasspath)
pluginClasspath.setFrom(detektPluginClasspath)
classpath.setFrom(variant.compileClasspath, androidComponents.sdkComponents.bootClasspath)
jvmTarget = "17"
buildUponDefaultConfig = false
Expand All @@ -58,9 +52,8 @@ androidComponents.onVariants(androidComponents.selector().withBuildType("debug")
reports {
sarif.required = false
html.required = false
xml.required = false
txt.required = false
md.required = false
markdown.required = false
checkstyle.required = false
}

// Internal working state regenerated every run, not a published output - LocalState, not @OutputFile.
Expand Down
34 changes: 16 additions & 18 deletions build-logic/src/main/kotlin/test-pyramid-api-usage.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,26 @@ import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import com.android.build.api.variant.HasUnitTest
import com.android.build.api.variant.LibraryAndroidComponentsExtension
import com.android.build.api.variant.Variant
import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.api.artifacts.VersionCatalogsExtension
import dev.detekt.gradle.Detekt
import org.gradle.api.attributes.Usage
import org.gradle.api.file.RegularFile
import org.gradle.api.provider.Provider
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.the

// Applying `io.gitlab.arturbosch.detekt` would also register its own detekt tasks and apply detekt.yml
// - unwanted, since this plugin isn't linting, only using Detekt as an engine. All our own task actually needs
// from the plugin is the engine classpath, so provide that directly via detached configurations instead of applying it.
val detektVersion = the<VersionCatalogsExtension>().named("libs").findVersion("detekt").get().requiredVersion
val detektEngineClasspath = configurations.detachedConfiguration(
dependencies.create("io.gitlab.arturbosch.detekt:detekt-cli:$detektVersion")
)
val detektPluginClasspath = configurations.detachedConfiguration(
dependencies.create(project(":tools:detekt"))
)
plugins {
// Provides the Detekt engine classpath and the defaults of the `Detekt` tasks
id("dev.detekt")
}

dependencies {
detektPlugins(project(":tools:detekt"))
}

// This plugin only uses Detekt as an engine: these modules aren't linted, so keep the root `detekt` task away from them
tasks.detekt {
isEnabled = false
}

val apiUsageLogFile = layout.buildDirectory.file("reports/detekt-test-pyramid/apiUsage.log")
val generatedConfigFile = layout.buildDirectory.file("tmp/detekt-test-pyramid/apiUsageTestPyramidConfig.yml")
Expand All @@ -41,8 +42,6 @@ fun configureApiUsageVariant(variant: Variant, bootClasspath: Provider<List<Regu

unitTest.sources.java?.let { source(it.all) }
unitTest.sources.kotlin?.let { source(it.all) }
detektClasspath.setFrom(detektEngineClasspath)
pluginClasspath.setFrom(detektPluginClasspath)
classpath.setFrom(unitTest.compileClasspath, bootClasspath)
jvmTarget = "17"
buildUponDefaultConfig = false
Expand All @@ -52,9 +51,8 @@ fun configureApiUsageVariant(variant: Variant, bootClasspath: Provider<List<Regu
reports {
sarif.required = false
html.required = false
xml.required = false
txt.required = false
md.required = false
markdown.required = false
checkstyle.required = false
}

localState.register(generatedConfigFile)
Expand Down
4 changes: 2 additions & 2 deletions dd-sdk-android-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ android {
}

dependencies {
implementation(libs.kotlin)
implementation(libs.kotlinRuntime)

// Network
implementation(libs.okHttp)
Expand Down Expand Up @@ -144,7 +144,7 @@ dependencies {
unmock(libs.robolectric)

// Test Fixtures
testFixturesImplementation(libs.kotlin)
testFixturesImplementation(libs.kotlinRuntime)
testFixturesImplementation(libs.bundles.jUnit5)
testFixturesImplementation(libs.okHttp)
testFixturesImplementation(libs.bundles.testTools)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ internal class DatadogCore(
)
}

@Suppress("ComplexMethod")
@Suppress("CyclomaticComplexMethod")
private fun applyAdditionalConfiguration(
additionalConfiguration: Map<String, Any>
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ internal class PlainBatchFileReaderWriter(
}

@Throws(IOException::class)
@Suppress("UnsafeThirdPartyFunctionCall", "ComplexMethod", "LoopWithTooManyJumpStatements")
@Suppress("UnsafeThirdPartyFunctionCall", "CyclomaticComplexMethod", "LoopWithTooManyJumpStatements")
// Called within a try/catch block
private fun readFileData(
file: File,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import org.mockito.junit.jupiter.MockitoSettings
import org.mockito.kotlin.doReturn
import org.mockito.kotlin.whenever
import org.mockito.quality.Strictness
import java.util.Locale

@Extensions(
ExtendWith(MockitoExtension::class),
Expand Down Expand Up @@ -92,7 +93,7 @@ internal class NoOpInternalSdkCoreTest {
// Given
whenever(mockFeature.name) doReturn fakeFeatureName
val expectedMessage = "[${NoOpInternalSdkCore.name}]: " +
REGISTER_FEATURE_INVOKED_ON_NO_OP_CORE_ERROR.format(fakeFeatureName)
REGISTER_FEATURE_INVOKED_ON_NO_OP_CORE_ERROR.format(Locale.US, fakeFeatureName)

// When + Then
Mockito.mockStatic(Log::class.java).use { mockedLog ->
Expand All @@ -111,7 +112,7 @@ internal class NoOpInternalSdkCoreTest {
// Given
whenever(mockFeature.name) doReturn fakeFeatureName
val expectedMessage = "[${NoOpInternalSdkCore.name}]: " +
REGISTER_FEATURE_INVOKED_ON_NO_OP_CORE_ERROR.format(fakeFeatureName)
REGISTER_FEATURE_INVOKED_ON_NO_OP_CORE_ERROR.format(Locale.US, fakeFeatureName)

// When + Then
Mockito.mockStatic(Log::class.java).use { mockedLog ->
Expand All @@ -128,7 +129,7 @@ internal class NoOpInternalSdkCoreTest {
fun `M log error W getFeature()`(@StringForgery fakeFeatureName: String) {
// Given
val expectedMessage = "[${NoOpInternalSdkCore.name}]: " +
GET_FEATURE_INVOKED_ON_NO_OP_CORE_ERROR.format(fakeFeatureName)
GET_FEATURE_INVOKED_ON_NO_OP_CORE_ERROR.format(Locale.US, fakeFeatureName)

// When + Then
Mockito.mockStatic(Log::class.java).use { mockedLog ->
Expand All @@ -144,7 +145,7 @@ internal class NoOpInternalSdkCoreTest {
fun `M log error only once W getFeature() {called multiple times}`(@StringForgery fakeFeatureName: String) {
// Given
val expectedMessage = "[${NoOpInternalSdkCore.name}]: " +
GET_FEATURE_INVOKED_ON_NO_OP_CORE_ERROR.format(fakeFeatureName)
GET_FEATURE_INVOKED_ON_NO_OP_CORE_ERROR.format(Locale.US, fakeFeatureName)

// When + Then
Mockito.mockStatic(Log::class.java).use { mockedLog ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ internal class SdkFeatureTest {
assertThrows<ClassCastException> {
// strange enough nothing is thrown if we don't save the result.
// Kotlin compiler removing/optimizing code unused?
@Suppress("UNUSED_VARIABLE")
@Suppress("UnusedVariable", "unused")
val result = testedFeature.unwrap<AnotherFakeFeature>()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ internal class BatchFileOrchestratorTest {
forge.anAlphabeticalString()
}

previousFile?.writeText(previousData[0])
previousFile.writeText(previousData[0])

for (i in 1 until MAX_ITEM_PER_BATCH) {
val file = testedOrchestrator.getWritableFile(1L)
Expand All @@ -623,7 +623,7 @@ internal class BatchFileOrchestratorTest {
.doesNotExist()
.hasParent(fakeRootDir)
assertThat(nextFile.name.toLong()).isEqualTo(newFileTimestamp)
assertThat(previousFile?.readText())
assertThat(previousFile.readText())
.isEqualTo(previousData.joinToString(separator = ""))

argumentCaptor<BatchClosedMetadata> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ internal class DefaultAndroidInfoProviderTest {
val fakeLocales = mutableListOf<Locale>()
val mockLocaleList: LocaleList = mock()

for (i in 0 until collectionSize) {
repeat(collectionSize) {
val fakeLanguage = forge.aStringMatching("[a-z][a-z]{1}")
val fakeRegion = forge.aStringMatching("[a-z][a-z]{1}")
fakeLocales.add(
Expand Down
4 changes: 2 additions & 2 deletions dd-sdk-android-internal/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ android {
}

dependencies {
implementation(libs.kotlin)
implementation(libs.kotlinRuntime)
implementation(libs.androidXAnnotation)

// Generate NoOp implementations
Expand All @@ -65,7 +65,7 @@ dependencies {
)
}
}
testFixturesImplementation(libs.kotlin)
testFixturesImplementation(libs.kotlinRuntime)
testFixturesImplementation(libs.bundles.jUnit5)
testFixturesImplementation(libs.bundles.testTools)
testFixturesImplementation(project(":tools:unit")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class EvictingQueue<T> constructor(

else -> {
val spaceLeft = maxSize - size
for (index in 0 until elements.size - spaceLeft) {
repeat(elements.size - spaceLeft) {
delegate.poll()
}

Expand Down
Loading
Loading