@@ -320,11 +320,22 @@ func getToolName(toolName string, version string) string {
320320func runEslintAnalysis (workDirectory string , pathsToCheck []string , autoFix bool , outputFile string , outputFormat string ) error {
321321 // Ensure ESLint tool is configured and installed
322322 eslint := config .Config .Tools ()["eslint" ]
323- if eslint == nil || ! config .Config .IsToolInstalled ("eslint" , eslint ) {
323+ isToolInstalled := config .Config .IsToolInstalled ("eslint" , eslint )
324+
325+ // Also check if the runtime is installed
326+ var isRuntimeInstalled bool
327+ if eslint != nil {
328+ nodeRuntime := config .Config .Runtimes ()["node" ]
329+ isRuntimeInstalled = nodeRuntime != nil && config .Config .IsRuntimeInstalled ("node" , nodeRuntime )
330+ }
331+
332+ if eslint == nil || ! isToolInstalled || ! isRuntimeInstalled {
324333 if eslint == nil {
325334 fmt .Println ("Eslint tool configuration not found, adding and installing..." )
326- } else {
335+ } else if ! isToolInstalled {
327336 fmt .Println ("Eslint tool is not installed, installing..." )
337+ } else if ! isRuntimeInstalled {
338+ fmt .Println ("Node.js runtime is not installed, installing eslint (which will install the runtime)..." )
328339 }
329340
330341 err := config .InstallTool ("eslint" , eslint , "" )
@@ -359,10 +370,15 @@ func runEslintAnalysis(workDirectory string, pathsToCheck []string, autoFix bool
359370func runTrivyAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
360371 // Ensure Trivy tool is configured and installed
361372 trivy := config .Config .Tools ()["trivy" ]
362- if trivy == nil || ! config .Config .IsToolInstalled ("trivy" , trivy ) {
373+ isToolInstalled := config .Config .IsToolInstalled ("trivy" , trivy )
374+
375+ // Trivy is a download-based tool (no runtime dependency), so runtime is always "installed"
376+ isRuntimeInstalled := true
377+
378+ if trivy == nil || ! isToolInstalled || ! isRuntimeInstalled {
363379 if trivy == nil {
364380 fmt .Println ("Trivy tool configuration not found, adding and installing..." )
365- } else {
381+ } else if ! isToolInstalled {
366382 fmt .Println ("Trivy tool is not installed, installing..." )
367383 }
368384
@@ -392,11 +408,22 @@ func runTrivyAnalysis(workDirectory string, pathsToCheck []string, outputFile st
392408func runPmdAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
393409 // Ensure PMD tool is configured and installed
394410 pmd := config .Config .Tools ()["pmd" ]
395- if pmd == nil || ! config .Config .IsToolInstalled ("pmd" , pmd ) {
411+ isToolInstalled := config .Config .IsToolInstalled ("pmd" , pmd )
412+
413+ // Also check if the runtime is installed
414+ var isRuntimeInstalled bool
415+ if pmd != nil {
416+ javaRuntime := config .Config .Runtimes ()["java" ]
417+ isRuntimeInstalled = javaRuntime != nil && config .Config .IsRuntimeInstalled ("java" , javaRuntime )
418+ }
419+
420+ if pmd == nil || ! isToolInstalled || ! isRuntimeInstalled {
396421 if pmd == nil {
397422 fmt .Println ("PMD tool configuration not found, adding and installing..." )
398- } else {
423+ } else if ! isToolInstalled {
399424 fmt .Println ("PMD tool is not installed, installing..." )
425+ } else if ! isRuntimeInstalled {
426+ fmt .Println ("Java runtime is not installed, installing PMD (which will install the runtime)..." )
400427 }
401428
402429 err := config .InstallTool ("pmd" , pmd , "" )
@@ -431,11 +458,22 @@ func runPmdAnalysis(workDirectory string, pathsToCheck []string, outputFile stri
431458func runPylintAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
432459 // Ensure Pylint tool is configured and installed
433460 pylint := config .Config .Tools ()["pylint" ]
434- if pylint == nil || ! config .Config .IsToolInstalled ("pylint" , pylint ) {
461+ isToolInstalled := config .Config .IsToolInstalled ("pylint" , pylint )
462+
463+ // Also check if the runtime is installed
464+ var isRuntimeInstalled bool
465+ if pylint != nil {
466+ pythonRuntime := config .Config .Runtimes ()["python" ]
467+ isRuntimeInstalled = pythonRuntime != nil && config .Config .IsRuntimeInstalled ("python" , pythonRuntime )
468+ }
469+
470+ if pylint == nil || ! isToolInstalled || ! isRuntimeInstalled {
435471 if pylint == nil {
436472 fmt .Println ("Pylint tool configuration not found, adding and installing..." )
437- } else {
473+ } else if ! isToolInstalled {
438474 fmt .Println ("Pylint tool is not installed, installing..." )
475+ } else if ! isRuntimeInstalled {
476+ fmt .Println ("Python runtime is not installed, installing Pylint (which will install the runtime)..." )
439477 }
440478
441479 err := config .InstallTool ("pylint" , pylint , "" )
@@ -470,11 +508,22 @@ func runPylintAnalysis(workDirectory string, pathsToCheck []string, outputFile s
470508func runDartAnalyzer (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
471509 // Ensure Dart Analyzer tool is configured and installed
472510 dartanalyzer := config .Config .Tools ()["dartanalyzer" ]
473- if dartanalyzer == nil || ! config .Config .IsToolInstalled ("dartanalyzer" , dartanalyzer ) {
511+ isToolInstalled := config .Config .IsToolInstalled ("dartanalyzer" , dartanalyzer )
512+
513+ // Also check if the runtime is installed
514+ var isRuntimeInstalled bool
515+ if dartanalyzer != nil {
516+ dartRuntime := config .Config .Runtimes ()["dart" ]
517+ isRuntimeInstalled = dartRuntime != nil && config .Config .IsRuntimeInstalled ("dart" , dartRuntime )
518+ }
519+
520+ if dartanalyzer == nil || ! isToolInstalled || ! isRuntimeInstalled {
474521 if dartanalyzer == nil {
475522 fmt .Println ("Dart analyzer tool configuration not found, adding and installing..." )
476- } else {
523+ } else if ! isToolInstalled {
477524 fmt .Println ("Dart analyzer tool is not installed, installing..." )
525+ } else if ! isRuntimeInstalled {
526+ fmt .Println ("Dart runtime is not installed, installing Dart Analyzer (which will install the runtime)..." )
478527 }
479528
480529 err := config .InstallTool ("dartanalyzer" , dartanalyzer , "" )
@@ -508,11 +557,22 @@ func runDartAnalyzer(workDirectory string, pathsToCheck []string, outputFile str
508557func runSemgrepAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
509558 // Ensure Semgrep tool is configured and installed
510559 semgrep := config .Config .Tools ()["semgrep" ]
511- if semgrep == nil || ! config .Config .IsToolInstalled ("semgrep" , semgrep ) {
560+ isToolInstalled := config .Config .IsToolInstalled ("semgrep" , semgrep )
561+
562+ // Also check if the runtime is installed
563+ var isRuntimeInstalled bool
564+ if semgrep != nil {
565+ pythonRuntime := config .Config .Runtimes ()["python" ]
566+ isRuntimeInstalled = pythonRuntime != nil && config .Config .IsRuntimeInstalled ("python" , pythonRuntime )
567+ }
568+
569+ if semgrep == nil || ! isToolInstalled || ! isRuntimeInstalled {
512570 if semgrep == nil {
513571 fmt .Println ("Semgrep tool configuration not found, adding and installing..." )
514- } else {
572+ } else if ! isToolInstalled {
515573 fmt .Println ("Semgrep tool is not installed, installing..." )
574+ } else if ! isRuntimeInstalled {
575+ fmt .Println ("Python runtime is not installed, installing Semgrep (which will install the runtime)..." )
516576 }
517577
518578 err := config .InstallTool ("semgrep" , semgrep , "" )
@@ -547,11 +607,22 @@ func runSemgrepAnalysis(workDirectory string, pathsToCheck []string, outputFile
547607func runLizardAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
548608 // Ensure Lizard tool is configured and installed
549609 lizardTool := config .Config .Tools ()["lizard" ]
550- if lizardTool == nil || ! config .Config .IsToolInstalled ("lizard" , lizardTool ) {
610+ isToolInstalled := config .Config .IsToolInstalled ("lizard" , lizardTool )
611+
612+ // Also check if the runtime is installed
613+ var isRuntimeInstalled bool
614+ if lizardTool != nil {
615+ pythonRuntime := config .Config .Runtimes ()["python" ]
616+ isRuntimeInstalled = pythonRuntime != nil && config .Config .IsRuntimeInstalled ("python" , pythonRuntime )
617+ }
618+
619+ if lizardTool == nil || ! isToolInstalled || ! isRuntimeInstalled {
551620 if lizardTool == nil {
552621 fmt .Println ("Lizard tool configuration not found, adding and installing..." )
553- } else {
622+ } else if ! isToolInstalled {
554623 fmt .Println ("Lizard tool is not installed, installing..." )
624+ } else if ! isRuntimeInstalled {
625+ fmt .Println ("Python runtime is not installed, installing Lizard (which will install the runtime)..." )
555626 }
556627
557628 err := config .InstallTool ("lizard" , lizardTool , "" )
@@ -605,10 +676,15 @@ func runLizardAnalysis(workDirectory string, pathsToCheck []string, outputFile s
605676func runEnigmaAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
606677 // Ensure Enigma tool is configured and installed
607678 enigma := config .Config .Tools ()["codacy-enigma-cli" ]
608- if enigma == nil || ! config .Config .IsToolInstalled ("codacy-enigma-cli" , enigma ) {
679+ isToolInstalled := config .Config .IsToolInstalled ("codacy-enigma-cli" , enigma )
680+
681+ // Enigma is a download-based tool (no runtime dependency), so runtime is always "installed"
682+ isRuntimeInstalled := true
683+
684+ if enigma == nil || ! isToolInstalled || ! isRuntimeInstalled {
609685 if enigma == nil {
610686 fmt .Println ("Enigma tool configuration not found, adding and installing..." )
611- } else {
687+ } else if ! isToolInstalled {
612688 fmt .Println ("Enigma tool is not installed, installing..." )
613689 }
614690
0 commit comments