Docker container for running IntelliJ IDEA code inspections. If the analysis detects inspection violations, a human-readable report is printed and an exit code of 1 is returned. Otherwise, an exit code of 0 is returned if the analysis does not detect any inspection violations.
[OPTIONS] PROJECT PROFILE
Options:
-d, --directory TEXT Absolute path to directory within project to be
inspected
-l, --levels TEXT Inspection severity levels to analyze (default:
ERROR,WARNING)
-o, --output TEXT Absolute path to output inspection analysis results
(default: inspection-results)
-s, --scope TEXT Name of IntelliJ scope to use
-h, --help Show this message and exit
Arguments:
PROJECT Absolute path to IntelliJ project directory, pom.xml, or
build.gradle, etc. to analyze
PROFILE Absolute path to inspection profile to use
Note that absolute paths must be specified.
These examples assume the working directory is the project to analyze.
Run analysis on IntelliJ IDEA project (i.e., contains .idea
directory and .iml
files):
docker run --rm \
-v $(pwd):/project \
ccaominh/intellij-inspect:1.0.0 \
/project \
/project/.idea/inspectionProfiles/Project_Default.xml
Example analysis output with violations reported:
Starting up IntelliJ IDEA 2018.3 (build IC-183.4284.148) ...done.
Opening project...done.
Initializing project...Loaded profile 'Project Default' from file '/project/.idea/inspectionProfiles/Project_Default.xml'
done.
Inspecting with profile 'Project Default'
Scanning scope ...
Processing project usages in .../src/main/java/com/company/Main.java [dirty]
Processing project usages in .../src/test/resources/expected.json [dirty]
Analyzing code in .../src/test/resources/expected.json [dirty]
Analyzing code in .../src/main/java/com/company/Main.java [dirty]
Done.
[WARNING] src/main/java/com/company/Main.java:21 -- Unnecessary semicolon <code>;</code> #loc
[WARNING] src/main/java/com/company/Main.java:19 -- Can be package-private
[ERROR] src/main/java/com/company/Main.java:17 -- Package name 'org.company' does not correspond to the file path 'com.company'
Run analysis on Maven project (after doing mvn install
on host):
docker run --rm \
-v "$(pwd):/project" \
-v ~/.m2:/home/inspect/.m2 \
ccaominh/intellij-inspect:1.0.0 \
/project/pom.xml \
/project/intellij_inspection_profile.xml
Run analysis on Gradle project:
docker run --rm \
-v "$(pwd):/project" \
ccaominh/intellij-inspect:1.0.0 \
/project/build.gradle \
/project/intellij_inspection_profile.xml
Run analysis only for ERROR
inspection severity level:
docker run --rm \
-v "$(pwd):/project" \
ccaominh/intellij-inspect:1.0.0 \
/project \
/project/.idea/inspectionProfiles/Project_Default.xml \
--levels ERROR
Run analysis for particular directory (e.g., src/main/java
) within project:
docker run --rm \
-v "$(pwd):/project" \
ccaominh/intellij-inspect:1.0.0 \
/project \
/project/.idea/inspectionProfiles/Project_Default.xml \
--directory /project/src/main/java
Run analysis for a particular scope:
docker run --rm \
-v "$(pwd):/project" \
ccaominh/intellij-inspect:1.0.0 \
/project \
/project/.idea/inspectionProfiles/Project_Default.xml \
--scope MY_SCOPE
Output raw inspection analysis results to build/inspect
directory (e.g., for viewing the results of an offline inspection in IntelliJ IDEA later):
docker run --rm \
-v "$(pwd):/project" \
-v "$(pwd)/build/inspect:/inspect" \
ccaominh/intellij-inspect:1.0.0 \
/project \
/project/.idea/inspectionProfiles/Project_Default.xml \
--output /inspect