@@ -62,20 +62,14 @@ if (cliOpts.t) {
6262// timeout
6363// if (cliOpts.to) ideaTimeout = cliOpts.to.toInteger();
6464// IDEA home
65- def scriptExtension = (System . properties[' os.name' ]. toLowerCase(). contains(' windows' )) ? " .bat" : " .sh"
66- def pathSep = File . separator
67- def ideaHome = cliOpts. i ?: (System . getenv(" IDEA_HOME" ) ?: " idea" )
68- def ideaPath = new File (ideaHome + pathSep + " bin" + pathSep + " idea" + scriptExtension)
69- assertPath(ideaPath, " IDEA Installation directory" ,
70- " Use a IDEA_HOME environment variable or the `ideahome` property in `.ideainspect` \n " +
71- " or the `-i` command line option to point me to a valid IntelliJ installation" )
65+ File ideaPath = findIdeaExecutable(cliOpts)
7266// Passed project root Directory or working directory
7367def rootDir = cliOpts. r ? new File (cliOpts. r) : Paths . get(" ." ). toAbsolutePath(). normalize(). toFile()
7468def dotIdeaDir = new File (rootDir, " .idea" )
7569assertPath(dotIdeaDir, " IDEA project directory" , " Please set the `rootdir` property to the location of your `.idea` project" )
7670// Inspection Profile
7771def profileName = cliOpts. p ?: " Project_Default.xml"
78- def profilePath = new File (dotIdeaDir. path + pathSep + " inspectionProfiles" + pathSep + profileName)
72+ def profilePath = new File (dotIdeaDir. path + File . separator + " inspectionProfiles" + File . separator + profileName)
7973assertPath(profilePath, " IDEA inspection profile file" )
8074
8175// Prepare result directory
@@ -221,6 +215,28 @@ private OptionAccessor parseCli(configArgs) {
221215 opt
222216}
223217
218+ private File findIdeaExecutable (OptionAccessor cliOpts ) {
219+ def platform = System . properties[' os.name' ], scriptPath
220+ def ideaHome = cliOpts. i ?: (System . getenv(" IDEA_HOME" ) ?: " idea" )
221+
222+ switch (platform) {
223+ case ~/ ^Windows.*/ :
224+ scriptPath = " bin" + File . separator + " idea.bat"
225+ break ;
226+ case " Mac OS X" :
227+ scriptPath = " Contents/MacOS/idea
228+ break;
229+ default:
230+ scriptPath = " bin/ idea. sh"
231+ break;
232+ }
233+
234+ def ideaExecutable = new File(ideaHome + File.separator + scriptPath)
235+ assertPath(ideaExecutable, " IDEA Installation directory" ,
236+ " Use a IDEA_HOME environment variable or the `ideahome` property in `. ideainspect` \n" +
237+ " or the `- i` command line option to point me to a valid IntelliJ installation" )
238+ ideaExecutable
239+ }
224240
225241private analyzeResult(File resultPath, List<String> acceptedLeves,
226242 List skipResults, List skipIssueFilesRegex) {
0 commit comments