-
Notifications
You must be signed in to change notification settings - Fork 118
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
#823 Added obfuscate option to dump shards #837
#823 Added obfuscate option to dump shards #837
Conversation
Codecov Report
@@ Coverage Diff @@
## master #837 +/- ##
============================================
+ Coverage 81.23% 81.56% +0.32%
Complexity 637 637
============================================
Files 167 169 +2
Lines 3240 3292 +52
Branches 463 467 +4
============================================
+ Hits 2632 2685 +53
+ Misses 343 341 -2
- Partials 265 266 +1 |
I pushed all documentation changes which were generated |
class ObfuscationGsonTest { | ||
|
||
@Test | ||
fun `Should return gson with correct type adapters registered`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everywhere we starting test name from lower letter. Maybe we should keep always same naming convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
If you add new command you should update
|
this is CLI option not flank settings. |
Right, sorry! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -47,7 +47,7 @@ class AndroidRunCommand : CommonRunCommand(), Runnable { | |||
|
|||
runBlocking { | |||
if (dumpShards) | |||
dumpShards(config) else | |||
dumpShards(args = config, obfuscatedOutput = obfuscate) else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why obfuscate
is passed via function argument? It shouldn't be in CommonArgs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is CLI option which are not in Common args, so I would like to make them same as others
} | ||
} | ||
|
||
private object ObfusctedIosJsonSerializer : JsonSerializer<List<List<String>>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, should be ObfuscatedIosJsonSerializer
@VisibleForTesting | ||
internal object ListOfStringListTypeToken : TypeToken<ShardChunks>() | ||
|
||
private object ObfusctedAndroidJsonSerializer : JsonSerializer<List<String>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo, should be ObfuscatedAndroidJsonSerializer
private const val UPPER_CASE_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | ||
private const val START_CONTEXT_KEY = "" | ||
|
||
interface Obfuscation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant abstraction if you remove this interface everything will work as well, so that means it is not needed. Keep it simple
|
||
class AndroidObfuscation : Obfuscation { | ||
private val contextMapAndroid = mutableMapOf<String, MutableMap<String, String>>() | ||
private val androidTestMethodSeparator = '#' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's not configurable so it could be const
private object ObfusctedAndroidJsonSerializer : JsonSerializer<List<String>> { | ||
private val obfuscation by lazy { AndroidObfuscation() } | ||
|
||
override fun serialize(src: List<String>?, typeOfSrc: Type?, context: JsonSerializationContext?): JsonElement { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure that any any of this args could be null? IMO not.
} | ||
|
||
private fun obfuscateAndroidPackageAndClass(packageNameWithClass: String): String { | ||
return packageNameWithClass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be expression
} | ||
|
||
private fun obfuscateMethodName(methodName: String, context: MutableMap<String, String>): String { | ||
return context.getOrPut(methodName) { nextSymbol(methodName, context) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could be expression
fun obfuscate(input: String): String | ||
} | ||
|
||
class AndroidObfuscation : Obfuscation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You already know my opinion about object oriented programming. Do we really need class for that I guess it's unnecessary complication to bound functions with state. I could be simple function like that:
typealias ObfuscationContext = Map<String, MutableMap<String, String>>
fun ObfuscationContext.obfuscateAndroidTestMethod(input: String): String {
...
}
The same about ios.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea was to keep it state, however it could be done much better by keeping context and make extension function. Thank you, for this idea
private fun obfuscateAndroidPackageAndClass(packageNameWithClass: String): String { | ||
return packageNameWithClass | ||
.split(androidPackageSeparator) | ||
.fold(START_CONTEXT_KEY) { previous, next -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, START_CONTEXT_KEY
is redundant. fold("")
is better than fold(START_CONTEXT_KEY)
because START_CONTEXT_KEY
forces to remember next name, and scroll to check what value it holds.
…-obfuscation-option # Conflicts: # release_notes.md
…option' into #823-add-dump-shard-obfuscation-option
this task must be updated after merging #853 |
# Conflicts: # release_notes.md # test_runner/docs/ascii/flank.jar_-android-run.adoc # test_runner/docs/ascii/flank.jar_-firebase-test-android-run.adoc # test_runner/docs/ascii/flank.jar_-firebase-test-ios-run.adoc # test_runner/docs/ascii/flank.jar_-ios-run.adoc
…-obfuscation-option # Conflicts: # release_notes.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Fixes #823
Test Plan
run
flank [android|ios] run --dump-shards --obfuscate
and compare output file with running
flank [android|ios] run --dump-shards
Check
ObfuscationTest
for checking obfuscation resultsChecklist