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

Adjust ktlint formatting rules #1919

Merged
merged 1 commit into from
Mar 19, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
# Copyright 2016-Present Datadog, Inc.

[*.{kt,kts}]
ktlint_code_style = ktlint_official
indent_size = unset
ktlint_code_style = android_studio
ij_kotlin_allow_trailing_comma_on_call_site = false
ij_kotlin_allow_trailing_comma = false
ij_kotlin_imports_layout=*,java.**,javax.**,kotlin.**,^
max_line_length = 120

# Code generated by KotlinPoet
[buildSrc/src/test/kotlin/com/example/model/*.kt]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ internal class DatadogCore(

internal const val NO_NEED_TO_WRITE_LAST_VIEW_EVENT =
"No need to write last RUM view event: NDK" +
" crash reports feature is not enabled and API is below 30."
" crash reports feature is not enabled and API is below 30."

internal val CONFIGURATION_TELEMETRY_DELAY_MS = TimeUnit.SECONDS.toMillis(5)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ fun File.readLinesSafe(
}

internal fun File.writeTextSafe(
text: String, charset: Charset = Charsets.UTF_8,
text: String,
charset: Charset = Charsets.UTF_8,
internalLogger: InternalLogger
) {
if (existsSafe(internalLogger) && canWriteSafe(internalLogger)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ internal class DatadogNdkCrashHandler(
InternalLogger.Level.ERROR,
InternalLogger.Target.TELEMETRY,
{
"Decoded file (${file.name}) content contains NULL character, file content={$it}," +
"Decoded file (${file.name}) content contains NULL character, file content={$it}," +
" raw_bytes=${content.joinToString(",")}"
}
)
Expand Down Expand Up @@ -378,7 +378,7 @@ internal class DatadogNdkCrashHandler(
}

@Deprecated(
"We will still process this path to check file from the old SDK" +
"We will still process this path to check file from the old SDK" +
" versions, but don't use it anymore for writing."
)
internal fun getLastViewEventFile(storageDir: File): File {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ internal class ConfigurationBuilderTest {
fun `𝕄 build config with first party hosts 𝕎 setFirstPartyHosts() { ip addresses }`(
@StringForgery(
regex = "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}" +
"([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"
"([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"
) hosts: List<String>
) {
// When
Expand All @@ -148,7 +148,7 @@ internal class ConfigurationBuilderTest {
fun `𝕄 build config with first party hosts 𝕎 setFirstPartyHosts() { host names }`(
@StringForgery(
regex = "(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)+" +
"([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])"
"([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])"
) hosts: List<String>
) {
// When
Expand Down Expand Up @@ -202,7 +202,7 @@ internal class ConfigurationBuilderTest {
fun `𝕄 sanitize hosts 𝕎 setFirstPartyHosts()`(
@StringForgery(
regex = "(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)+" +
"([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])"
"([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])"
) hosts: List<String>
) {
// When
Expand All @@ -224,7 +224,7 @@ internal class ConfigurationBuilderTest {
fun `𝕄 build config with first party hosts and header types 𝕎 setFirstPartyHostsWithHeaderType() { host names }`(
@StringForgery(
regex = "(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\\.)+" +
"([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])"
"([A-Za-z]|[A-Za-z][A-Za-z0-9-]*[A-Za-z0-9])"
) hosts: List<String>,
forge: Forge
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ internal class BatchMetricsDispatcherTest {
eq(InternalLogger.Target.MAINTAINER),
argThat {
this.invoke() ==
BatchMetricsDispatcher.WRONG_FILE_NAME_MESSAGE_FORMAT
.format(Locale.ENGLISH, fakeFile.name)
BatchMetricsDispatcher.WRONG_FILE_NAME_MESSAGE_FORMAT
.format(Locale.ENGLISH, fakeFile.name)
},
eq(null),
eq(false),
Expand Down Expand Up @@ -510,8 +510,8 @@ internal class BatchMetricsDispatcherTest {
eq(InternalLogger.Target.MAINTAINER),
argThat {
this.invoke() ==
BatchMetricsDispatcher.WRONG_FILE_NAME_MESSAGE_FORMAT
.format(Locale.ENGLISH, fakeFile.name)
BatchMetricsDispatcher.WRONG_FILE_NAME_MESSAGE_FORMAT
.format(Locale.ENGLISH, fakeFile.name)
},
eq(null),
eq(false),
Expand Down Expand Up @@ -584,12 +584,12 @@ internal class BatchMetricsDispatcherTest {
BatchMetricsDispatcher.TRACK_KEY to resolveTrackName(fakeFeatureName),
BatchMetricsDispatcher.BATCH_AGE_KEY to max(0, (currentTimeInMillis - file.name.toLong())),
BatchMetricsDispatcher.UPLOADER_WINDOW_KEY to
fakeFilePersistenceConfig.recentDelayMs,
fakeFilePersistenceConfig.recentDelayMs,
BatchMetricsDispatcher.UPLOADER_DELAY_KEY to mapOf(
BatchMetricsDispatcher.UPLOADER_DELAY_MIN_KEY to
fakeUploadConfiguration.minDelayMs,
fakeUploadConfiguration.minDelayMs,
BatchMetricsDispatcher.UPLOADER_DELAY_MAX_KEY to
fakeUploadConfiguration.maxDelayMs
fakeUploadConfiguration.maxDelayMs
),
BatchMetricsDispatcher.FILE_NAME to file.name,
BatchMetricsDispatcher.THREAD_NAME to Thread.currentThread().name,
Expand All @@ -606,9 +606,9 @@ internal class BatchMetricsDispatcherTest {
BatchMetricsDispatcher.TYPE_KEY to BatchMetricsDispatcher.BATCH_CLOSED_TYPE_VALUE,
BatchMetricsDispatcher.TRACK_KEY to resolveTrackName(fakeFeatureName),
BatchMetricsDispatcher.BATCH_DURATION_KEY to
max(0, (batchClosedMetadata.lastTimeWasUsedInMs - file.name.toLong())),
max(0, (batchClosedMetadata.lastTimeWasUsedInMs - file.name.toLong())),
BatchMetricsDispatcher.UPLOADER_WINDOW_KEY to
fakeFilePersistenceConfig.recentDelayMs,
fakeFilePersistenceConfig.recentDelayMs,
BatchMetricsDispatcher.FORCE_NEW_KEY to batchClosedMetadata.forcedNew,
BatchMetricsDispatcher.BATCH_EVENTS_COUNT_KEY to batchClosedMetadata.eventsCount,
BatchMetricsDispatcher.FILE_NAME to file.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ object Logs {

internal const val LOGS_NOT_ENABLED_MESSAGE =
"You're trying to add attributes to logs, but the feature is not enabled. " +
"Please enable it first."
"Please enable it first."
}
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ internal class DatadogLateCrashReporter(
" where one or more mandatory (timestamp, signalName, stacktrace," +
" message, lastViewEvent) fields are either missing or have wrong type."
internal const val MISSING_ANR_TRACE = "Last known exit reason has no trace information" +
" attached, cannot report fatal ANR."
" attached, cannot report fatal ANR."

internal val VIEW_EVENT_AVAILABILITY_TIME_THRESHOLD = TimeUnit.HOURS.toMillis(4)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,6 @@ internal class RumApplicationScope(

companion object {
internal const val MULTIPLE_ACTIVE_SESSIONS_ERROR = "Application has multiple active " +
"sessions when starting a new session"
"sessions when starting a new session"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ internal class RumSessionScope(
// To do so, we take the offset of those times in the event time, which should be consistent,
// then add that to our processStartTime to get the correct value.
val timestampNs = (
TimeUnit.MILLISECONDS.toNanos(eventTime.timestamp) - eventTime.nanoTime
) + processStartTimeNs
TimeUnit.MILLISECONDS.toNanos(eventTime.timestamp) - eventTime.nanoTime
) + processStartTimeNs
val applicationLaunchViewTime = Time(
timestamp = TimeUnit.NANOSECONDS.toMillis(timestampNs),
nanoTime = processStartTimeNs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,9 @@ internal class RumViewManagerScope(
private const val MESSAGE_GAP_BETWEEN_VIEWS = "Gap between views was %d nanoseconds"
internal const val MESSAGE_MISSING_VIEW =
"A RUM event was detected, but no view is active. " +
"To track views automatically, try calling the " +
"RumConfiguration.Builder.useViewTrackingStrategy() method.\n" +
"You can also track views manually using the RumMonitor.startView() and " +
"RumMonitor.stopView() methods."
"To track views automatically, try calling the " +
"RumConfiguration.Builder.useViewTrackingStrategy() method.\n" +
"You can also track views manually using the RumMonitor.startView() and " +
"RumMonitor.stopView() methods."
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1126,9 +1126,9 @@ internal open class RumViewScope(

private fun isViewComplete(): Boolean {
val pending = pendingActionCount +
pendingResourceCount +
pendingErrorCount +
pendingLongTaskCount
pendingResourceCount +
pendingErrorCount +
pendingLongTaskCount
// we use <= 0 for pending counter as a safety measure to make sure this ViewScope will
// be closed.
return stopped && activeResourceScopes.isEmpty() && (pending <= 0L)
Expand All @@ -1153,19 +1153,19 @@ internal open class RumViewScope(
internal val ONE_SECOND_NS = TimeUnit.SECONDS.toNanos(1)

internal const val ACTION_DROPPED_WARNING = "RUM Action (%s on %s) was dropped, because" +
" another action is still active for the same view"
" another action is still active for the same view"

internal const val RUM_CONTEXT_UPDATE_IGNORED_AT_STOP_VIEW_MESSAGE =
"Trying to update global RUM context when StopView event arrived, but the context" +
" doesn't reference this view."
" doesn't reference this view."
internal const val RUM_CONTEXT_UPDATE_IGNORED_AT_ACTION_UPDATE_MESSAGE =
"Trying to update active action in the global RUM context, but the context" +
" doesn't reference this view."
" doesn't reference this view."

internal val FROZEN_FRAME_THRESHOLD_NS = TimeUnit.MILLISECONDS.toNanos(700)
internal const val SLOW_RENDERED_THRESHOLD_FPS = 55
internal const val NEGATIVE_DURATION_WARNING_MESSAGE = "The computed duration for the " +
"view: %s was 0 or negative. In order to keep the view we forced it to 1ns."
"view: %s was 0 or negative. In order to keep the view we forced it to 1ns."

internal fun fromEvent(
parentScope: RumScope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ internal class DatadogRumMonitor(

@Deprecated(
"This method is deprecated and will be removed in the future versions." +
" Use `startResource` method which takes `RumHttpMethod` as `method` parameter instead."
" Use `startResource` method which takes `RumHttpMethod` as `method` parameter instead."
)
override fun startResource(
key: String,
Expand Down Expand Up @@ -412,7 +412,7 @@ internal class DatadogRumMonitor(
override fun start() {
val processImportance = DdRumContentProvider.processImportance
val isAppInForeground = processImportance ==
ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND
val processStartTimeNs = appStartTimeProvider.appStartTimeNs
handleEvent(
RumRawEvent.SdkInit(isAppInForeground, processStartTimeNs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ internal class JankStatsActivityLifecycleListener(

internal const val JANK_STATS_TRACKING_ALREADY_DISABLED_ERROR =
"Trying to disable JankStats instance which was already disabled before, this" +
" shouldn't happen."
" shouldn't happen."
internal const val JANK_STATS_TRACKING_DISABLE_ERROR =
"Failed to disable JankStats tracking"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ internal class ErrorEventAssert(actual: ErrorEvent) :
assertThat(actual.error.threads)
.overridingErrorMessage(
"Expected RUM event to have error.threads: $expected" +
" but instead was: ${actual.error.threads}"
" but instead was: ${actual.error.threads}"
)
.isEqualTo(expected)
return this
Expand All @@ -575,7 +575,7 @@ internal class ErrorEventAssert(actual: ErrorEvent) :
assertThat(actual.error.threads)
.overridingErrorMessage(
"Expected RUM event to not have error.threads," +
" but instead was: ${actual.error.threads}"
" but instead was: ${actual.error.threads}"
)
.isNull()
return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ internal class RumSessionScopeTest {
val expectedEventTimestamp =
TimeUnit.NANOSECONDS.toMillis(
TimeUnit.MILLISECONDS.toNanos(fakeEvent.eventTime.timestamp) -
fakeEvent.eventTime.nanoTime + fakeEvent.appStartTimeNs
fakeEvent.eventTime.nanoTime + fakeEvent.appStartTimeNs
)

// When
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1535,7 +1535,7 @@ internal class DatadogRumMonitorTest {
val viewScopes = forge.aList {
mock<RumViewScope>().apply {
whenever(getRumContext()) doReturn
RumContext(viewName = forge.aNullable { forge.anAlphaNumericalString() })
RumContext(viewName = forge.aNullable { forge.anAlphaNumericalString() })

whenever(isActive()) doReturn true
}
Expand Down Expand Up @@ -1571,7 +1571,7 @@ internal class DatadogRumMonitorTest {
val viewScopes = forge.aList {
mock<RumViewScope>().apply {
whenever(getRumContext()) doReturn
RumContext(viewName = forge.aNullable { forge.anAlphaNumericalString() })
RumContext(viewName = forge.aNullable { forge.anAlphaNumericalString() })

whenever(isActive()) doReturn false
}
Expand Down Expand Up @@ -1895,7 +1895,7 @@ internal class DatadogRumMonitorTest {
if (isMethodOccupied) {
throw IllegalStateException(
"Only one thread should" +
" be allowed to enter rootScope at the time."
" be allowed to enter rootScope at the time."
)
}
isMethodOccupied = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ internal class MaskInputTabWireframeMapper internal constructor(
viewBoundsResolver: ViewBoundsResolver,
drawableToColorMapper: DrawableToColorMapper
) : this(
viewIdentifierResolver, viewBoundsResolver,
viewIdentifierResolver,
viewBoundsResolver,
MaskInputTextViewMapper(
viewIdentifierResolver, colorStringFormatter, viewBoundsResolver, drawableToColorMapper
viewIdentifierResolver,
colorStringFormatter,
viewBoundsResolver,
drawableToColorMapper
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ internal class MaskTabWireframeMapper internal constructor(
viewBoundsResolver: ViewBoundsResolver,
drawableToColorMapper: DrawableToColorMapper
) : this(
viewIdentifierResolver, viewBoundsResolver,
viewIdentifierResolver,
viewBoundsResolver,
MaskTextViewMapper(
viewIdentifierResolver, colorStringFormatter, viewBoundsResolver, drawableToColorMapper
viewIdentifierResolver,
colorStringFormatter,
viewBoundsResolver,
drawableToColorMapper
)
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ internal abstract class BaseSliderWireframeMapperTest {
.densityNormalized(fakeMappingContext.systemInformation.screenDensity)
val normalizedSliderHeight = fakeSliderHeight
val normalizedSliderValue = (fakeSliderValue - fakeSliderFromValue) /
(fakeSliderToValue - fakeSliderFromValue)
(fakeSliderToValue - fakeSliderFromValue)

fakeExpectedInactiveTrackHeight = fakeTrackHeight.toLong()
.densityNormalized(fakeMappingContext.systemInformation.screenDensity)
Expand All @@ -185,16 +185,16 @@ internal abstract class BaseSliderWireframeMapperTest {
fakeExpectedThumbHeight = fakeThumbRadius.toLong()
.densityNormalized(fakeMappingContext.systemInformation.screenDensity) * 2
fakeExpectedInactiveTrackXPos = normalizedSliderXPos + normalizedSliderStartPadding +
normalizedTrackSidePadding
normalizedTrackSidePadding
fakeExpectedInactiveTrackYPos = normalizedSliderYPos + normalizedSliderTopPadding +
(normalizedSliderHeight - fakeExpectedActiveTrackHeight) / 2
(normalizedSliderHeight - fakeExpectedActiveTrackHeight) / 2
fakeExpectedActiveTrackYPos = fakeExpectedInactiveTrackYPos
fakeExpectedActiveTrackXPos = fakeExpectedInactiveTrackXPos
fakeExpectedActiveTrackXPos = fakeExpectedInactiveTrackXPos
fakeExpectedActiveTrackYPos = fakeExpectedInactiveTrackYPos
fakeExpectedThumbXPos = fakeExpectedActiveTrackXPos + fakeExpectedActiveTrackWidth
fakeExpectedThumbYPos = normalizedSliderYPos + normalizedSliderTopPadding +
(normalizedSliderHeight - fakeExpectedThumbHeight) / 2
(normalizedSliderHeight - fakeExpectedThumbHeight) / 2
whenever(
mockColorStringFormatter.formatColorAndAlphaAsHexString(
fakeThumbColor,
Expand Down