@@ -319,11 +319,22 @@ func getToolName(toolName string, version string) string {
319319func runEslintAnalysis (workDirectory string , pathsToCheck []string , autoFix bool , outputFile string , outputFormat string ) error {
320320 // Ensure ESLint tool is configured and installed
321321 eslint := config .Config .Tools ()["eslint" ]
322- if eslint == nil || ! config .Config .IsToolInstalled ("eslint" , eslint ) {
322+ isToolInstalled := config .Config .IsToolInstalled ("eslint" , eslint )
323+
324+ // Also check if the runtime is installed
325+ var isRuntimeInstalled bool
326+ if eslint != nil {
327+ nodeRuntime := config .Config .Runtimes ()["node" ]
328+ isRuntimeInstalled = nodeRuntime != nil && config .Config .IsRuntimeInstalled ("node" , nodeRuntime )
329+ }
330+
331+ if eslint == nil || ! isToolInstalled || ! isRuntimeInstalled {
323332 if eslint == nil {
324333 fmt .Println ("Eslint tool configuration not found, adding and installing..." )
325- } else {
334+ } else if ! isToolInstalled {
326335 fmt .Println ("Eslint tool is not installed, installing..." )
336+ } else if ! isRuntimeInstalled {
337+ fmt .Println ("Node.js runtime is not installed, installing eslint (which will install the runtime)..." )
327338 }
328339
329340 err := config .InstallTool ("eslint" , eslint , "" )
@@ -358,10 +369,15 @@ func runEslintAnalysis(workDirectory string, pathsToCheck []string, autoFix bool
358369func runTrivyAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
359370 // Ensure Trivy tool is configured and installed
360371 trivy := config .Config .Tools ()["trivy" ]
361- if trivy == nil || ! config .Config .IsToolInstalled ("trivy" , trivy ) {
372+ isToolInstalled := config .Config .IsToolInstalled ("trivy" , trivy )
373+
374+ // Trivy is a download-based tool (no runtime dependency), so runtime is always "installed"
375+ isRuntimeInstalled := true
376+
377+ if trivy == nil || ! isToolInstalled || ! isRuntimeInstalled {
362378 if trivy == nil {
363379 fmt .Println ("Trivy tool configuration not found, adding and installing..." )
364- } else {
380+ } else if ! isToolInstalled {
365381 fmt .Println ("Trivy tool is not installed, installing..." )
366382 }
367383
@@ -391,11 +407,22 @@ func runTrivyAnalysis(workDirectory string, pathsToCheck []string, outputFile st
391407func runPmdAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
392408 // Ensure PMD tool is configured and installed
393409 pmd := config .Config .Tools ()["pmd" ]
394- if pmd == nil || ! config .Config .IsToolInstalled ("pmd" , pmd ) {
410+ isToolInstalled := config .Config .IsToolInstalled ("pmd" , pmd )
411+
412+ // Also check if the runtime is installed
413+ var isRuntimeInstalled bool
414+ if pmd != nil {
415+ javaRuntime := config .Config .Runtimes ()["java" ]
416+ isRuntimeInstalled = javaRuntime != nil && config .Config .IsRuntimeInstalled ("java" , javaRuntime )
417+ }
418+
419+ if pmd == nil || ! isToolInstalled || ! isRuntimeInstalled {
395420 if pmd == nil {
396421 fmt .Println ("PMD tool configuration not found, adding and installing..." )
397- } else {
422+ } else if ! isToolInstalled {
398423 fmt .Println ("PMD tool is not installed, installing..." )
424+ } else if ! isRuntimeInstalled {
425+ fmt .Println ("Java runtime is not installed, installing PMD (which will install the runtime)..." )
399426 }
400427
401428 err := config .InstallTool ("pmd" , pmd , "" )
@@ -430,11 +457,22 @@ func runPmdAnalysis(workDirectory string, pathsToCheck []string, outputFile stri
430457func runPylintAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
431458 // Ensure Pylint tool is configured and installed
432459 pylint := config .Config .Tools ()["pylint" ]
433- if pylint == nil || ! config .Config .IsToolInstalled ("pylint" , pylint ) {
460+ isToolInstalled := config .Config .IsToolInstalled ("pylint" , pylint )
461+
462+ // Also check if the runtime is installed
463+ var isRuntimeInstalled bool
464+ if pylint != nil {
465+ pythonRuntime := config .Config .Runtimes ()["python" ]
466+ isRuntimeInstalled = pythonRuntime != nil && config .Config .IsRuntimeInstalled ("python" , pythonRuntime )
467+ }
468+
469+ if pylint == nil || ! isToolInstalled || ! isRuntimeInstalled {
434470 if pylint == nil {
435471 fmt .Println ("Pylint tool configuration not found, adding and installing..." )
436- } else {
472+ } else if ! isToolInstalled {
437473 fmt .Println ("Pylint tool is not installed, installing..." )
474+ } else if ! isRuntimeInstalled {
475+ fmt .Println ("Python runtime is not installed, installing Pylint (which will install the runtime)..." )
438476 }
439477
440478 err := config .InstallTool ("pylint" , pylint , "" )
@@ -469,11 +507,22 @@ func runPylintAnalysis(workDirectory string, pathsToCheck []string, outputFile s
469507func runDartAnalyzer (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
470508 // Ensure Dart Analyzer tool is configured and installed
471509 dartanalyzer := config .Config .Tools ()["dartanalyzer" ]
472- if dartanalyzer == nil || ! config .Config .IsToolInstalled ("dartanalyzer" , dartanalyzer ) {
510+ isToolInstalled := config .Config .IsToolInstalled ("dartanalyzer" , dartanalyzer )
511+
512+ // Also check if the runtime is installed
513+ var isRuntimeInstalled bool
514+ if dartanalyzer != nil {
515+ dartRuntime := config .Config .Runtimes ()["dart" ]
516+ isRuntimeInstalled = dartRuntime != nil && config .Config .IsRuntimeInstalled ("dart" , dartRuntime )
517+ }
518+
519+ if dartanalyzer == nil || ! isToolInstalled || ! isRuntimeInstalled {
473520 if dartanalyzer == nil {
474521 fmt .Println ("Dart analyzer tool configuration not found, adding and installing..." )
475- } else {
522+ } else if ! isToolInstalled {
476523 fmt .Println ("Dart analyzer tool is not installed, installing..." )
524+ } else if ! isRuntimeInstalled {
525+ fmt .Println ("Dart runtime is not installed, installing Dart Analyzer (which will install the runtime)..." )
477526 }
478527
479528 err := config .InstallTool ("dartanalyzer" , dartanalyzer , "" )
@@ -507,11 +556,22 @@ func runDartAnalyzer(workDirectory string, pathsToCheck []string, outputFile str
507556func runSemgrepAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
508557 // Ensure Semgrep tool is configured and installed
509558 semgrep := config .Config .Tools ()["semgrep" ]
510- if semgrep == nil || ! config .Config .IsToolInstalled ("semgrep" , semgrep ) {
559+ isToolInstalled := config .Config .IsToolInstalled ("semgrep" , semgrep )
560+
561+ // Also check if the runtime is installed
562+ var isRuntimeInstalled bool
563+ if semgrep != nil {
564+ pythonRuntime := config .Config .Runtimes ()["python" ]
565+ isRuntimeInstalled = pythonRuntime != nil && config .Config .IsRuntimeInstalled ("python" , pythonRuntime )
566+ }
567+
568+ if semgrep == nil || ! isToolInstalled || ! isRuntimeInstalled {
511569 if semgrep == nil {
512570 fmt .Println ("Semgrep tool configuration not found, adding and installing..." )
513- } else {
571+ } else if ! isToolInstalled {
514572 fmt .Println ("Semgrep tool is not installed, installing..." )
573+ } else if ! isRuntimeInstalled {
574+ fmt .Println ("Python runtime is not installed, installing Semgrep (which will install the runtime)..." )
515575 }
516576
517577 err := config .InstallTool ("semgrep" , semgrep , "" )
@@ -546,11 +606,22 @@ func runSemgrepAnalysis(workDirectory string, pathsToCheck []string, outputFile
546606func runLizardAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
547607 // Ensure Lizard tool is configured and installed
548608 lizardTool := config .Config .Tools ()["lizard" ]
549- if lizardTool == nil || ! config .Config .IsToolInstalled ("lizard" , lizardTool ) {
609+ isToolInstalled := config .Config .IsToolInstalled ("lizard" , lizardTool )
610+
611+ // Also check if the runtime is installed
612+ var isRuntimeInstalled bool
613+ if lizardTool != nil {
614+ pythonRuntime := config .Config .Runtimes ()["python" ]
615+ isRuntimeInstalled = pythonRuntime != nil && config .Config .IsRuntimeInstalled ("python" , pythonRuntime )
616+ }
617+
618+ if lizardTool == nil || ! isToolInstalled || ! isRuntimeInstalled {
550619 if lizardTool == nil {
551620 fmt .Println ("Lizard tool configuration not found, adding and installing..." )
552- } else {
621+ } else if ! isToolInstalled {
553622 fmt .Println ("Lizard tool is not installed, installing..." )
623+ } else if ! isRuntimeInstalled {
624+ fmt .Println ("Python runtime is not installed, installing Lizard (which will install the runtime)..." )
554625 }
555626
556627 err := config .InstallTool ("lizard" , lizardTool , "" )
@@ -604,10 +675,15 @@ func runLizardAnalysis(workDirectory string, pathsToCheck []string, outputFile s
604675func runEnigmaAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
605676 // Ensure Enigma tool is configured and installed
606677 enigma := config .Config .Tools ()["codacy-enigma-cli" ]
607- if enigma == nil || ! config .Config .IsToolInstalled ("codacy-enigma-cli" , enigma ) {
678+ isToolInstalled := config .Config .IsToolInstalled ("codacy-enigma-cli" , enigma )
679+
680+ // Enigma is a download-based tool (no runtime dependency), so runtime is always "installed"
681+ isRuntimeInstalled := true
682+
683+ if enigma == nil || ! isToolInstalled || ! isRuntimeInstalled {
608684 if enigma == nil {
609685 fmt .Println ("Enigma tool configuration not found, adding and installing..." )
610- } else {
686+ } else if ! isToolInstalled {
611687 fmt .Println ("Enigma tool is not installed, installing..." )
612688 }
613689
0 commit comments