@@ -312,7 +312,6 @@ func checkIfConfigExistsAndIsNeeded(toolName string, cliLocalMode bool) error {
312312 // Use the configuration system to get the tools config directory
313313 toolsConfigDir := config .Config .ToolsConfigDirectory ()
314314 toolConfigPath := filepath .Join (toolsConfigDir , configFileName )
315-
316315 // Check if the config file exists
317316 if _ , err := os .Stat (toolConfigPath ); os .IsNotExist (err ) {
318317 // Config file does not exist - create it if we have the means to do so
@@ -347,14 +346,10 @@ func checkIfConfigExistsAndIsNeeded(toolName string, cliLocalMode bool) error {
347346}
348347
349348func runToolByName (toolName string , workDirectory string , pathsToCheck []string , autoFix bool , outputFile string , outputFormat string , tool * plugins.ToolInfo , runtime * plugins.RuntimeInfo , cliLocalMode bool ) error {
350- err := checkIfConfigExistsAndIsNeeded (toolName , cliLocalMode )
351- if err != nil {
352- return err
353- }
354-
355349 var t * domain.Tool
356350 var usesConfigurationFile = false
357351
352+ //Check if the user is using the repository configuration file
358353 // If the user doesn't provide init flags, we skip fetching repository tools
359354 if initFlags != (domain.InitFlags {}) {
360355 // Get the tool name with the right version e.g. ESLint9, PMD7, etc.
@@ -364,7 +359,6 @@ func runToolByName(toolName string, workDirectory string, pathsToCheck []string,
364359 repositoryTools , _ := codacyclient .GetRepositoryTools (initFlags )
365360
366361 // Find the matching tool in repositoryTools
367-
368362 for i , tool := range repositoryTools {
369363 if tool .Name == toolRightVersion {
370364 t = & repositoryTools [i ]
@@ -374,6 +368,14 @@ func runToolByName(toolName string, workDirectory string, pathsToCheck []string,
374368 }
375369 }
376370
371+ // If the user is not using configuration file from repository, we check if there's a local one
372+ if ! usesConfigurationFile {
373+ err := checkIfConfigExistsAndIsNeeded (toolName , cliLocalMode )
374+ if err != nil {
375+ return err
376+ }
377+ }
378+
377379 switch toolName {
378380 case "eslint" :
379381 binaryPath := runtime .Binaries [tool .Runtime ]
0 commit comments