Skip to content

Commit

Permalink
Issue #4682: add scripts for checking idea inspections
Browse files Browse the repository at this point in the history
  • Loading branch information
Nimfadora authored and romani committed Sep 4, 2017
1 parent d371c34 commit e7adccf
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .ci/idea_inspection.bat
@@ -0,0 +1,39 @@
@echo off

::----------------------------------------------------------------------
:: IntelliJ IDEA inspections for checkstyle.
::
:: Example:
:: SET IDEA_PATH=C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2017.2.1\bin\idea.bat
:: .ci\idea_inspection.bat
::----------------------------------------------------------------------

SET PROJECT_DIR=%CD%\
SET INSPECTIONS_PATH=%CD%\config\intellij-idea-inspections.xml
SET RESULTS_DIR=%CD%\target\inspection-results
SET NOISE_LVL=v1
SET IDEA_LOCATION=
SET IDEA_PROPERTIES=%CD%\config\idea.properties

::Check IDEA_PATH env variable
IF EXIST %IDEA_PATH% SET (
SET IDEA_LOCATION=%IDEA_PATH%
goto run
) ELSE (
echo IDEA_PATH variable not found.
)

::Try to search in path
FOR /f "delims=" %%i IN ('"where idea.bat"') DO SET IDEA_LOCATION="%%i"
if [%IDEA_LOCATION%] NEQ [] (
goto run
) ELSE (
echo IntelliJ IDEA was not found in path.
exit /b
)

:run
mkdir .idea\scopes
copy config\intellij-idea-inspection-scope.xml .idea\scopes

"%IDEA_LOCATION%" inspect %PROJECT_DIR% %INSPECTIONS_PATH% %RESULTS_DIR% -%NOISE_LVL%
53 changes: 53 additions & 0 deletions .ci/idea_inspection.sh
@@ -0,0 +1,53 @@
#!/bin/bash -e

#################################################
# IntelliJ IDEA inspections for checkstyle.
#
# Example Mac OS:
# export IDEA_PATH="/Applications/IntelliJ IDEA.app/Contents/MacOS/idea"
# bash ./.ci/idea_inspection.sh
#
# Example Linux:
# export IDEA_PATH=/opt/idea-IC-171.4694.70/bin/idea.sh
# export IDEA_PROPERTIES=$PWD/config/idea.properties
# ./.ci/idea_inspection.sh
#################################################

PROJECT_DIR=$PWD/
INSPECTIONS_PATH=$PWD/config/intellij-idea-inspections.xml
RESULTS_DIR=$PWD/target/inspection-results
NOISE_LVL=v1
IDEA_LOCATION=
export IDEA_PROPERTIES=$PWD/config/idea.properties

# Check IDEA_PATH env variable

if [[ ! -z $IDEA_PATH ]]; then
IDEA_LOCATION=$IDEA_PATH
else
echo "IDEA_PATH variable not found."
# Try to search in path
IDEA_LOCATION="$(which idea)"
if [ -z $IDEA_LOCATION ]; then
echo "IntelliJ IDEA was not found in path."
exit -1
fi
fi

mkdir -p $RESULTS_DIR
rm -rf $RESULTS_DIR/*
mkdir -p $PWD/.idea/scopes
cp $PWD/config/intellij-idea-inspection-scope.xml $PWD/.idea/scopes

echo "Validation is about to start ... progress output will be flushed at end. Validation is in progress ..."
IDEA_OUTPUT=`exec "$IDEA_LOCATION" inspect $PROJECT_DIR $INSPECTIONS_PATH $RESULTS_DIR -$NOISE_LVL`
echo $IDEA_OUTPUT

echo "Checking results ..."
if [[ $(grep "problems" $RESULTS_DIR/* --exclude="UnusedProperty.xml" --exclude="RedundantSuppression.xml" | cat | wc -l ) > 0 ]]; then
echo "There are inspection problems. Review results at $RESULTS_DIR folder. Files:"
grep -l "problems" $RESULTS_DIR/* --exclude="UnusedProperty.xml" --exclude="RedundantSuppression.xml"
exit 1;
else
echo "Inpection did not found any problems"
fi
1 change: 1 addition & 0 deletions config/idea.properties
@@ -0,0 +1 @@
idea.exclude.patterns=src/test/resources/**;src/site/resources/js/google-analytics.js;src/test/java/com/puppycrawl/tools/checkstyle/checks/javadoc/ParseTreeBuilder.java;src/test/java/com/puppycrawl/tools/checkstyle/grammars/javadoc/ParseTreeBuilder.java;

0 comments on commit e7adccf

Please sign in to comment.