forked from checkstyle/checkstyle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidea_inspection.sh
executable file
·53 lines (45 loc) · 1.66 KB
/
idea_inspection.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash -e
#################################################
# IntelliJ IDEA inspections for checkstyle.
#
# Example Mac OS:
# IDEA_PATH="/Applications/IntelliJ IDEA.app/Contents/MacOS/idea" ./.ci/idea_inspection.sh
#
# Example Linux:
# export IDEA_PATH=$HOME/java/idea-IU-172.4574.11 && ./.ci/idea_inspection.sh
#################################################
PROJECT_DIR=$PWD/
INSPECTIONS_PATH=$PWD/config/intellij-idea-inspections.xml
RESULTS_DIR=$PWD/target/inspection-results
NOISE_LVL=v1
# we need to export this variable as it is required for idea.sh script
export IDEA_PROPERTIES=$PWD/config/intellij-idea-inspections.properties
# Check IDEA_PATH env variable
if [[ -z $IDEA_PATH ]]; then
echo "IDEA_PATH variable not found."
# Try to search in path
IDEA_PATH="$(which idea)"
if [ -z $IDEA_PATH ]; then
echo "IntelliJ IDEA was not found in path."
exit -1
fi
fi
#Execute compilation of Checkstyle to generate all source files
mvn -e clean compile
mkdir -p $RESULTS_DIR
rm -rf $RESULTS_DIR/*
echo "Intellij Idea validation is about to start"
echo "Progress output will be flushed at end. Validation is in progress ..."
IDEA_OUTPUT=`$IDEA_PATH/bin/inspect.sh $PROJECT_DIR $INSPECTIONS_PATH $RESULTS_DIR -$NOISE_LVL`
if [[ $IDEA_OUTPUT == "Already running" ]]; then
echo "It might be that Intellij Idea is running, please close it."
exit 1;
fi
echo "Checking results ..."
if [[ $(grep -R "<problems" $RESULTS_DIR/ | cat | wc -l ) > 0 ]]; then
echo "There are inspection problems. Review results at $RESULTS_DIR folder. Files:"
grep -Rl "<problems" $RESULTS_DIR/
exit 1;
else
echo "Inspection did not found any problems"
fi