Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed MR comments
Browse files Browse the repository at this point in the history
Piotr Adamczyk committed Jan 20, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 2e5f40b commit c91227f
Showing 2 changed files with 15 additions and 13 deletions.
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -21,7 +21,9 @@ plugins {
tasks {
"lintKotlinMain"(LintTask::class) {
exclude(
"**/*Generated.kt" // we can expand this list
"**/*Generated.kt",
"**/*Test.kt",
"**/Test*.kt" // we can expand this list
)
}
}
24 changes: 12 additions & 12 deletions test_runner/src/main/kotlin/ftl/analytics/StatisticDataFilters.kt
Original file line number Diff line number Diff line change
@@ -9,25 +9,23 @@ annotation class IgnoreInStatistics
annotation class AnonymizeInStatistics

internal val keysToRemove by lazy {
classesForStatistics.map { it.ignoredMembersForStatistics() }.flatten()
classesForStatistics.map(findMembersWithAnnotation(IgnoreInStatistics::class)).flatten()
}

private fun KClass<*>.ignoredMembersForStatistics() = findMembersWithAnnotation(IgnoreInStatistics::class)

internal val keysToAnonymize by lazy {
classesForStatistics.map { it.anonymousMembersForStatistics() }.flatten()
classesForStatistics.map(findMembersWithAnnotation(AnonymizeInStatistics::class)).flatten()
}

private fun KClass<*>.anonymousMembersForStatistics() = findMembersWithAnnotation(AnonymizeInStatistics::class)

private val classesForStatistics = listOf(IArgs::class, AndroidArgs::class, IosArgs::class)

private const val ANONYMIZE_VALUE = "..."

private fun KClass<*>.findMembersWithAnnotation(annotationType: KClass<*>) = members.filter { member ->
member.annotations.any { annotation -> annotation.annotationClass == annotationType }
}.map {
it.name
private fun findMembersWithAnnotation(
annotationType: KClass<*>
): KClass<*>.() -> List<String> = {
members.filter { member ->
member.annotations.any { annotation -> annotation.annotationClass == annotationType }
}.map {
it.name
}
}

internal fun Map<String, Any>.removeNotNeededKeys(defaultArgs: Map<String, Any>) =
@@ -46,3 +44,5 @@ private fun Any.toAnonymous(): Any = when (this) {
is List<*> -> "Count: $size"
else -> ANONYMIZE_VALUE
}

private const val ANONYMIZE_VALUE = "..."

0 comments on commit c91227f

Please sign in to comment.