Skip to content

Instantly share code, notes, and snippets.

@dafi
Last active February 11, 2018 15:35
Show Gist options
  • Save dafi/aa76122e0eea10775f523a39b7cc18db to your computer and use it in GitHub Desktop.
Save dafi/aa76122e0eea10775f523a39b7cc18db to your computer and use it in GitHub Desktop.
Show ktlint results on logcat to simplify navigation between warnings
#/bin/bash
# Run klint (https://github.com/shyiko/ktlint) and then write the result to logcat
# The file names are clickeable from Android Studio
tag_name="klint"
tmpfile=$(mktemp)
chmod +x $tmpfile
dquote='"'
ktlint "app/src/**/*kt" \
| sed -nE 's/^.*\/(.*):([0-9]+):([0-9]+):/$tag_name: (\1:\2) column \3/p' \
| sed -e 's/(/\\(/g' -e 's/)/\\)/g' \
| while read -r line; do echo adb shell "log -p v -t $tag_name ${dquote}${line}${dquote}" >> $tmpfile; done
$tmpfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment