@@ -283,6 +283,7 @@ func validateToolName(toolName string) error {
283283 return nil
284284}
285285
286+ // checkIfConfigExistsAndIsNeeded validates if a tool has config file and creates one if needed
286287func checkIfConfigExistsAndIsNeeded (toolName string , cliLocalMode bool ) error {
287288 configFileName := constants .ToolConfigFileNames [toolName ]
288289 if configFileName == "" {
@@ -296,19 +297,33 @@ func checkIfConfigExistsAndIsNeeded(toolName string, cliLocalMode bool) error {
296297
297298 // Check if the config file exists
298299 if _ , err := os .Stat (toolConfigPath ); os .IsNotExist (err ) {
299- // Only show error if we're in remote mode and need the config file
300+ // Config file does not exist - create it if we have the means to do so
300301 if (! cliLocalMode && initFlags .ApiToken != "" ) || cliLocalMode {
301302 fmt .Printf ("Creating new config file for tool %s\n " , toolName )
302303 if err := configsetup .CreateToolConfigurationFile (toolName , initFlags ); err != nil {
303304 return fmt .Errorf ("failed to create config file for tool %s: %w" , toolName , err )
304305 }
306+
307+ // Ensure .gitignore exists FIRST to prevent config files from being analyzed
308+ if err := configsetup .CreateGitIgnoreFile (); err != nil {
309+ logger .Warn ("Failed to create .gitignore file" , logrus.Fields {
310+ "error" : err ,
311+ })
312+ }
305313 } else {
306- fmt .Printf ("Config file not found for tool %s: %s and no API token provided\n " , toolName , toolConfigPath )
314+ logger .Debug ("Config file not found for tool, using tool defaults" , logrus.Fields {
315+ "tool" : toolName ,
316+ "toolConfigPath" : toolConfigPath ,
317+ "message" : "No API token provided" ,
318+ })
307319 }
308320 } else if err != nil {
309321 return fmt .Errorf ("error checking config file for tool %s: %w" , toolName , err )
310322 } else {
311- fmt .Printf ("Config file found for %s: %s\n " , toolName , toolConfigPath )
323+ logger .Info ("Config file found for tool" , logrus.Fields {
324+ "tool" : toolName ,
325+ "toolConfigPath" : toolConfigPath ,
326+ })
312327 }
313328 return nil
314329}
0 commit comments