Remove whitespace from all test functions.
This was generated by running this exact query (who knows what tools that line will break): rg "fun \`" -l | xargs -I {} gsed -i -e '/fun `/s/\(\s*\)fun /\1DONOTSUBMIT/' -e '/DONOTSUBMIT/s/ - /_/g' -e '/DONOTSUBMIT/s/--/_/g' -e '/DONOTSUBMIT/s/\([a-z]\) \([a-z]\)/\1 \U\2/g' -e '/DONOTSUBMIT/s/\s//g' -e '/DONOTSUBMIT/s/`//g' -e '/DONOTSUBMIT/s/DONOTSUBMIT/DONOTSUBMIT /g' -e '/DONOTSUBMIT/s/ \([A-Z]\)\([a-z]\)/ \L\1\2/' -e '/DONOTSUBMIT/s/-\(\S\)/\U\1/g' -e '/DONOTSUBMIT/s/=/ = /' -e '/DONOTSUBMIT/s/{/ { /' -e '/DONOTSUBMIT/s/\s*$//' -e '/DONOTSUBMIT/s/DONOTSUBMIT/ fun/g' {} The breakdown is as follows: - rg queries for any file that contains a function which begins with "fun `" - xargs to execute `gsed` on every file Now for the transformation. Loosely what we do is: - Replace "fun `" with an easily spottable tag - Every command henceforth is filtered to lines starting with our tag - Make the following transforms: 1. replace " - " with a regular underscore 2. replace the few "--" also with an underscore 3. Any word following a space is uppercased 4. Strip all whitespce from the whole line 5. Remove the backtick 6a. Add a space after our tag (important for the next step) 6b. Any function starting with UpperCamelCase is now lowerCamelCase 7. replace any <letter>-<letter> occurences with <letter><UPPERLETTER>. Because I figure "word-pair" is probably better represented as "wordPair" rather than "word_pair" 8. re-add whitespace around the equals sign (if any) 9. re-add whitespace around the opening bracket (if any) 10. trim tailing whitespace 11. replace our token with the corect " fun" line starter -e '/fun `/s/\(\s*\)fun /\1DONOTSUBMIT/' #step 0 -e '/DONOTSUBMIT/s/ - /_/g' #step 1 -e '/DONOTSUBMIT/s/--/_/g' #step 2 -e '/DONOTSUBMIT/s/\([a-z]\) \([a-z]\)/\1 \U\2/g' #step 3 -e '/DONOTSUBMIT/s/\s//g' #step 4 -e '/DONOTSUBMIT/s/`//g' #step 5 -e '/DONOTSUBMIT/s/DONOTSUBMIT/DONOTSUBMIT /g' #step 6a -e '/DONOTSUBMIT/s/ \([A-Z]\)\([a-z]\)/ \L\1\2/' #step 6b -e '/DONOTSUBMIT/s/-\(\S\)/\U\1/g' #step 7 -e '/DONOTSUBMIT/s/=/ = /' #step 8 -e '/DONOTSUBMIT/s/{/ { /' #step 9 -e '/DONOTSUBMIT/s/\s*$//' #step 10 -e '/DONOTSUBMIT/s/DONOTSUBMIT/ fun/g' {} #step 11 NOTE: This CL skipped ktfmt since that only modified lines unrelated to the change Test: run all of the tests Bug: 277739595 Change-Id: I673ebf8992f56f0220652e15534acdb91e60a9dc
Loading
Please register or sign in to comment