xref: /aosp_15_r20/external/leakcanary2/hooks/pre-push (revision d9e8da70d8c9df9a41d7848ae506fb3115cae6e6)
1*d9e8da70SAndroid Build Coastguard Worker#!/bin/sh
2*d9e8da70SAndroid Build Coastguard Worker
3*d9e8da70SAndroid Build Coastguard Workerecho "Running static analysis..."
4*d9e8da70SAndroid Build Coastguard Worker
5*d9e8da70SAndroid Build Coastguard Worker# Run static analysis tools
6*d9e8da70SAndroid Build Coastguard Worker./gradlew detekt
7*d9e8da70SAndroid Build Coastguard Worker
8*d9e8da70SAndroid Build Coastguard Workerstatus=$?
9*d9e8da70SAndroid Build Coastguard Worker
10*d9e8da70SAndroid Build Coastguard Workerif [ "$status" = 0 ] ; then
11*d9e8da70SAndroid Build Coastguard Worker    echo "Static analysis found no problems."
12*d9e8da70SAndroid Build Coastguard Worker    exit 0
13*d9e8da70SAndroid Build Coastguard Workerelse
14*d9e8da70SAndroid Build Coastguard Worker    echo 1>&2 "Static analysis found violations! Fix them before pushing your code!"
15*d9e8da70SAndroid Build Coastguard Worker    echo "See generated reports above or in /<project_dir>/build/reports folder"
16*d9e8da70SAndroid Build Coastguard Worker    exit 1
17*d9e8da70SAndroid Build Coastguard Workerfi
18