@@ -188,42 +188,33 @@ func getToolName(toolName string, version string) string {
188188 return toolName
189189}
190190
191- func runEslintAnalysis (workDirectory string , pathsToCheck []string , autoFix bool , outputFile string , outputFormat string ) {
191+ func runEslintAnalysis (workDirectory string , pathsToCheck []string , autoFix bool , outputFile string , outputFormat string ) error {
192192 eslint := config .Config .Tools ()["eslint" ]
193193 eslintInstallationDirectory := eslint .InstallDir
194194 nodeRuntime := config .Config .Runtimes ()["node" ]
195195 nodeBinary := nodeRuntime .Binaries ["node" ]
196196
197- tools .RunEslint (workDirectory , eslintInstallationDirectory , nodeBinary , pathsToCheck , autoFix , outputFile , outputFormat )
197+ return tools .RunEslint (workDirectory , eslintInstallationDirectory , nodeBinary , pathsToCheck , autoFix , outputFile , outputFormat )
198198}
199199
200- func runTrivyAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) {
200+ func runTrivyAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
201201 trivy := config .Config .Tools ()["trivy" ]
202202 trivyBinary := trivy .Binaries ["trivy" ]
203203
204- err := tools .RunTrivy (workDirectory , trivyBinary , pathsToCheck , outputFile , outputFormat )
205- if err != nil {
206- log .Fatalf ("Error running Trivy: %v" , err )
207- }
204+ return tools .RunTrivy (workDirectory , trivyBinary , pathsToCheck , outputFile , outputFormat )
208205}
209206
210- func runPmdAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) {
207+ func runPmdAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
211208 pmd := config .Config .Tools ()["pmd" ]
212209 pmdBinary := pmd .Binaries ["pmd" ]
213210
214- err := tools .RunPmd (workDirectory , pmdBinary , pathsToCheck , outputFile , outputFormat , config .Config )
215- if err != nil {
216- log .Fatalf ("Error running PMD: %v" , err )
217- }
211+ return tools .RunPmd (workDirectory , pmdBinary , pathsToCheck , outputFile , outputFormat , config .Config )
218212}
219213
220- func runPylintAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) {
214+ func runPylintAnalysis (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) error {
221215 pylint := config .Config .Tools ()["pylint" ]
222216
223- err := tools .RunPylint (workDirectory , pylint , pathsToCheck , outputFile , outputFormat )
224- if err != nil {
225- log .Fatalf ("Error running Pylint: %v" , err )
226- }
217+ return tools .RunPylint (workDirectory , pylint , pathsToCheck , outputFile , outputFormat )
227218}
228219
229220func runDartAnalyzer (workDirectory string , pathsToCheck []string , outputFile string , outputFormat string ) {
@@ -273,7 +264,9 @@ var analyzeCmd = &cobra.Command{
273264 for toolName := range toolsToRun {
274265 log .Printf ("Running %s...\n " , toolName )
275266 tmpFile := filepath .Join (tmpDir , fmt .Sprintf ("%s.sarif" , toolName ))
276- runTool (workDirectory , toolName , args , tmpFile )
267+ if err := runTool (workDirectory , toolName , args , tmpFile ); err != nil {
268+ log .Printf ("Tool failed to run: %s: %v\n " , toolName , err )
269+ }
277270 sarifOutputs = append (sarifOutputs , tmpFile )
278271 }
279272
@@ -304,25 +297,27 @@ var analyzeCmd = &cobra.Command{
304297 // Run tools without merging outputs
305298 for toolName := range toolsToRun {
306299 log .Printf ("Running %s...\n " , toolName )
307- runTool (workDirectory , toolName , args , outputFile )
300+ if err := runTool (workDirectory , toolName , args , outputFile ); err != nil {
301+ log .Printf ("Tool failed to run: %s: %v\n " , toolName , err )
302+ }
308303 }
309304 }
310305 },
311306}
312307
313- func runTool (workDirectory string , toolName string , args []string , outputFile string ) {
308+ func runTool (workDirectory string , toolName string , args []string , outputFile string ) error {
314309 switch toolName {
315310 case "eslint" :
316- runEslintAnalysis (workDirectory , args , autoFix , outputFile , outputFormat )
311+ return runEslintAnalysis (workDirectory , args , autoFix , outputFile , outputFormat )
317312 case "trivy" :
318- runTrivyAnalysis (workDirectory , args , outputFile , outputFormat )
313+ return runTrivyAnalysis (workDirectory , args , outputFile , outputFormat )
319314 case "pmd" :
320- runPmdAnalysis (workDirectory , args , outputFile , outputFormat )
315+ return runPmdAnalysis (workDirectory , args , outputFile , outputFormat )
321316 case "pylint" :
322- runPylintAnalysis (workDirectory , args , outputFile , outputFormat )
317+ return runPylintAnalysis (workDirectory , args , outputFile , outputFormat )
323318 case "dartanalyzer" :
324- runDartAnalyzer (workDirectory , args , outputFile , outputFormat )
319+ return runDartAnalyzer (workDirectory , args , outputFile , outputFormat )
325320 default :
326- log . Printf ( "Warning: Unsupported tool: %s\n " , toolName )
321+ return fmt . Errorf ( "unsupported tool: %s" , toolName )
327322 }
328323}
0 commit comments